From: Aneesh K. K.V <ane...@di...> - 2002-12-09 09:06:12
|
On Thu, 2002-12-05 at 06:35, Brian J. Watson wrote: > > Also there > > is some difference in the option supported by swapon ( -e ) between what > > i found in redhat and the mount code base( from debian ). So redhat > > startup script may need a close check. > <snip> > > Also, I think we want to have the commands use /etc/fstab, not > /etc/fstab.ssi. That would be less surprising to a new user. IIUC, no > modifications need to be made to /etc/fstab for the first node. Perhaps > the original /etc/fstab can be saved when addnode or chnode is first > used to add entries for other nodes. It can then be restored if > mount-ssi and e2fsprogs-ssi are uninstalled. > I guess we need to have fstab.ssi . Otherwise user is going to be more confused. I am attaching below a small perl script that will auto generate the needed fstab.ssi. Run it on the first node. One can also import the already existing fstab( new fstab with entires node=x will be auto generated ). The output file name is taken as the argument. If one is not importing already existing fstab ( which will be case for other nodes ) the script will ask certain set of questions depending on the hardware configuration and file system supported. ( I am reading this from /proc ). Hope the script will be useful. -aneesh #! /usr/bin/perl -w # # # Date : Dec 09 2002 # Authors: Aneesh Kumar K.V ( ane...@di... ) # # # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License as # published by the Free Software Foundation; either version 2 of # the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE # or NON INFRINGEMENT. See the GNU General Public License for more # details. # # use strict; sub generate_fstab_ssi { my($node_num,$fstab,$fstab_out) = @_; my($input_line); my(@line_entry); my($i); open(INFILE,$fstab) || die ("Unable to open the file $fstab"); open(OUTFILE,">>$fstab_out") || die ("Unable to open the file $fstab_out"); while(! eof(INFILE) ) { $input_line = <INFILE>; @line_entry = split(/[\t ]+/ ,$input_line); if ($line_entry[0] =~ /^#/ ) { print OUTFILE $input_line; next ; } if (@line_entry != 6 ) { next; } $i = 0; while( $i < @line_entry ) { if( $i == 3) { if ($line_entry[2] =~ /proc/ || $line_entry[2] =~ /devfs/ ) { print OUTFILE $line_entry[$i].",node=*\t"; } else { print OUTFILE $line_entry[$i].",node=$node_num\t"; } } else { print OUTFILE "$line_entry[$i]\t"; } $i++; } print OUTFILE "\n"; } close(INFILE); close(OUTFILE); } sub partition_print { my(@ex_list) = @_; my($input_line); my(@line_entry); my($ex); open(PROC_PARTITION,"/proc/partitions") || die( "/proc/partitions not found"); # Skip the starting line $input_line = <PROC_PARTITION>; print "\nAvailable partions are:\n"; read_proc: while(! eof(PROC_PARTITION) ) { $input_line = <PROC_PARTITION>; @line_entry = split(/[\t ]+/ ,$input_line); if (@line_entry == 5) { chop($line_entry[4]); if( $line_entry[4] =~ /[0-9]$/ ) { foreach $ex (@ex_list) { if( $ex eq $line_entry[4]) { next read_proc; } } print "$line_entry[4]\n"; } } } close(PROC_PARTITION); } sub filesystem_print { my($input_line); my(@line_entry); open(PROC_FILESYSTEM,"/proc/filesystems") || die( "/proc/filesystems not found"); print "\nAvailable filesystems are:\n"; print "swap\n"; while(! eof(PROC_FILESYSTEM) ) { $input_line = <PROC_FILESYSTEM>; @line_entry = split(/[\t ]+/ ,$input_line); if ($line_entry[0] ne "nodev" ) { print @line_entry; } } close(PROC_FILESYSTEM); } sub write_fstab_entry { my($partition_name,$file_system,$node_num,$fstab_out)=@_; my($mount_point,$create_mount); open(OUTFILE,">>$fstab_out") || die ( "Unable to open $fstab_out"); if( $file_system eq "swap" ) { print OUTFILE "/dev/$partition_name\tnone\t$file_system\t"; print OUTFILE "sw,node=$node_num\t\t0\t0\n"; }else { print "Enter the mount point for /dev/$partition_name :"; $mount_point = <STDIN>; chop($mount_point); unless ( -d $mount_point ) { print "\n"; print "$mount_point not found "; print "Shall I create it ?[y/n] :"; $create_mount = <STDIN>; chop($create_mount); if ( $create_mount eq "y") { mkdir($mount_point,0755); }else { print "Mount point not created !!!!\n"; } } print OUTFILE "/dev/$partition_name\t$mount_point\t$file_system\t"; print OUTFILE "defaults,node=$node_num\t\t0\t2\n"; } close (OUTFILE); } sub usage() { print "\n"; print "Usage:\n"; print "perl $0 <out_file_name>"; print "\n"; } sub main { my($node_num); my($import_fstab,@ex_list,$partition_name,$more,$file_system); $node_num = `/sbin/clusternode_num`; chop($node_num); # Anything other than digit if ($node_num =~ /\D/) { die(" This Program need to run on a SSI cluster!!!!"); } if (@ARGV < 1 ) { usage(); exit(); } print "Cluster fstab generation script\n"; if ( -e "/etc/fstab" ){ print "Found /etc/fstab Do you want to import[y/n]:"; $import_fstab = <STDIN>; chop($import_fstab); if ( $import_fstab eq "y" ) { generate_fstab_ssi($node_num,"/etc/fstab",$ARGV[0]); return; } } while (1) { partition_print(@ex_list); print "Select a partition : "; $partition_name = <STDIN>; chop($partition_name); filesystem_print(); print "Select the file system on "; print "the partion /dev/$partition_name :"; $file_system =<STDIN>; chop($file_system); write_fstab_entry($partition_name,$file_system, $node_num,$ARGV[0]); @ex_list = (@ex_list,$partition_name); print "Add another entry[y/n]:"; $more = <STDIN>; chop($more); if ($more ne "y" ) { last; } } } main |
From: Brian J. W. <Bri...@hp...> - 2002-12-13 02:11:14
|
> I guess we need to have fstab.ssi . Otherwise user is going to be more > confused. My thinking is that the user may not know about fstab.ssi. They'll make a change to fstab and be frustrated that their change isn't having any effect. I have a similar problem with my cluster_lilo command. It should be called lilo, and behave like the base lilo when running on a non-ssi kernel. > I am attaching below a small perl script that will auto > generate the needed fstab.ssi. Run it on the first node. Cool! Feel free to check it in with your util-linux stuff so people can play with it. Also, can you briefly document our changes to fstab and how to use the script to automate the changes. Feel free to check that description in, as well. Thanks, Brian |