compaq array controllers

Marc Martinez lastxit+fai at technogeeks.org
Sat Dec 1 06:03:11 CET 2001


bad form replying to myself, but I have a diff this time.. :)

this is done with the extra subroutine method, making it easier to add
in other styles of naming convention later on (regexes will still need
adjusting as well)..

the first hunk defines the PartName function, and the last hunk does
some sanitizing on the output logfile name, so instead of writing (or
attempting to, at least, since it will fail) out to the filename
/tmp/ida/c0d0.sfdisk it goes to /tmp/ida_c0d0.sfdisk .. everything in
the middle is one-line adjustments either for a regex or variable
setting to use the new PartName interface.

the only remaining holdup I have with what I want to do, and it's not
even totally mandatory, but very desirable, is to be able to preserve
the compq system utilities partition.  unfortunately it creates it as
partition3, leaving the first 2 empty.  this really confuses the script,
and it wants to create my first 2 partitions starting at 1 with a -1
size.  the already defined partition 3 starts at 32 and ends at 73408.

after the partition 3 has been passed, the logical area on 4 gets
created with the start sector of 73440, and everything past there is
normal.

also if I comment out the preserve line and let it create everything
from scratch sizes come out as expected.  I'm not sure if this is due
to the partition offset being at 32 instead of 1 (where it wants to
start when I comment out the preserve line) or if just having the
first 2 partitions empty is throwing it off..

in any case, diff attached for what I have so far, please comment on
my changes when you have a chance to review them.

Marc
-------------- next part --------------
--- setup_harddisks.orig	Thu Nov 29 15:46:04 2001
+++ setup_harddisks	Fri Nov 30 20:36:08 2001
@@ -221,6 +221,19 @@
 #****************************************************
 
 #****************************************************
+# get a partition pathname
+#****************************************************
+sub PartName ($$;) {
+    my ($disk, $partno) = splice(@_, 0, 2);
+    my $ppath;
+    for ($disk) {
+	/^[a-z]+$/ and $ppath = "${disk}${partno}";
+	/\d$/ and $ppath = "${disk}p${partno}";
+    }
+    return $ppath;
+}
+
+#****************************************************
 # Read all partition tables of this machine
 #****************************************************
 sub GetAllDisks{
@@ -238,7 +251,7 @@
     }
     $result = `sh -c "LC_ALL=C sfdisk -d -q"`;
     foreach $line(split(/\n/,$result)){
-	if($line =~ /# partition table of \/dev\/([a-z]+)/i){
+	if($line =~ /# partition table of \/dev\/(ida\/c\dd\d|[a-z]+)/i){
 	   $disk = $1;
         }
 	if($line =~ /^\/dev\/(.+?)\s*:\s+start=\s*(\d+),\s+size=\s*(\d+),\s+Id=\s*([a-z0-9]+)\b(.*)$/i){
@@ -306,7 +319,7 @@
 	    if ($paras =~ / end/i){
 		$disk = "";
 	    } else {
-		if($paras =~ / (\/dev\/)?([a-z]+)/i){
+		if($paras =~ / (\/dev\/)?(ida\/c\dd\d|[a-z]+)/i){
 		    $disk = "$2";
 		    ($DiskMountpoints{$disk})
 		      && die "ERROR: there are more than one configuration of disk $disk.\n";
@@ -368,7 +381,7 @@
 		    ($PrimPartNo == 3) && ($disk =~ /^sd/) && ($PrimPartNo++);
                     ($PrimPartNo >4 ) && die "ERROR: Too much primary partitions (max 4).".
                                 " All logicals together need one primary too.\n";
-		    $MountpointPart{$mountpoint} = "$disk$PrimPartNo";
+		    $MountpointPart{$mountpoint} = PartName($disk,$PrimPartNo);
 		    if($options =~ /\bboot\b/i){
 		        ($BootPartition) && die "ERROR: only one partition can be bootable at a time.";
 			$BootPartition = $MountpointPart{$mountpoint};
@@ -378,7 +391,7 @@
 		    ($NoMoreLogicals != 0) && die "ERROR: the logical partitions must be together.\n";
 		    $MPPrimary{$mountpoint} = "";
 		    $LogPartNo++;
-		    $MountpointPart{$mountpoint} = "$disk$LogPartNo";
+		    $MountpointPart{$mountpoint} = PartName($disk,$LogPartNo);
 		    if (!$MPPrimary{$extmp}){
 		        $MPPreserve{$extmp} = "";
 		        $MPPrimary{$extmp} = "yes";
@@ -390,7 +403,7 @@
                         ($PrimPartNo >4 ) 
 			  && die "ERROR: too much primary partitions (max 4).".
                                " All logicals together need one primary too.\n";
-			$MountpointPart{$extmp} = "$disk$PrimPartNo";
+			$MountpointPart{$extmp} = PartName($disk,$PrimPartNo);
 			$DiskMountpoints{$disk} .= " $extmp";
 		    }
 		    ($options =~ /\bboot\b/i) && die "ERROR: line $a, only primary partitions can be bootable.\n";
@@ -403,7 +416,7 @@
 		    || die "SYNTAX ERROR in config file line $a, size: $size\n$line\n";
 		if($size =~ /^preserve(\d+)$/i){
 		    $number = $1;
-		    $device = "$disk$number";
+		    $device = PartName($disk,$number);
 		    ($OldNotAligned{$device} eq "yes")
 		      && die "ERROR: unable to preserve partition /dev/$device. Partition is not DOS aligned.";
 		    ($command eq "primary") && ($number != $PrimPartNo)
@@ -669,7 +682,7 @@
 	    ($1 < 5) && ($PrimaryNo++);
 	    if ( ($1 == 5) && ($PrimaryNo < 5) ){
 	        for $number($PrimaryNo..4) {
-		    $sfdiskTables{$disk} .= BuildsfdiskDumpLine("$disk$number",0,0,0)."\n";
+		    $sfdiskTables{$disk} .= BuildsfdiskDumpLine(PartName($disk,$number),0,0,0)."\n";
 	        }
 	    }
 	    $line = BuildsfdiskDumpLine($MountpointPart{$mountpoint},$MPStart{$mountpoint},$MPSize{$mountpoint},$MPID{$mountpoint});
@@ -677,7 +690,7 @@
             $sfdiskTables{$disk} .= "$line\n";
 	}
 	print $sfdiskTables{$disk};
-	$filename = "/tmp/$disk.sfdisk";
+	$filename = "/tmp/" . (($disk=~ m/\//) ? join('_', split('/', $disk)) : $disk) . ".sfdisk";
 	if(($test != 1) && ($filename)){
 	    open(FILE, ">$filename") || die "unable to write temporary file $filename\n";
 	    print FILE $sfdiskTables{$disk};


More information about the linux-fai mailing list