Per disk options to sfdisk, patch enclosed

Bruce Edge bedge at troikanetworks.com
Wed Oct 16 18:03:46 CEST 2002


Thanks for the patch, but my needs differed slightly.
I needed to specify an option to one disk only, so I went with adding an arg to the disk_config line in the disk mapping file:

disk_config hda -C 2
primary  /flash        3-               rw,errors=remount-ro    ; ext2

Anything after the disk name, in this case hda ("-C 2" here) is parsed as an option to sfdisk.
I needed to force the cyl count to 2.

This ought to work for the general case too.

-Bruce.

--------------- start -------------
--- /usr/lib/fai/sbin/setup_harddisks.orig      Wed Oct 16 08:53:48 2002
+++ /usr/lib/fai/sbin/setup_harddisks   Wed Oct 16 08:54:32 2002
@@ -57,10 +57,11 @@
 # config-file format:
 #   lines beginning with # are comments
 #
-# "disk_config <device>|end"
+# "disk_config <device> <sfdisk options>|end"
 #   The disk_config command starts the parsing.
 #   It has to be the first command.
 #    <device> is the harddisk to format in short form like "hda" or "sdc".
+#    <sfdisk options> are options to add to the sfdisk command line
 #    "end"    = end parsing here
 #   Example: "disk_config hdb"
 #
@@ -179,6 +180,7 @@
 my $NofSwapPart = 0;       # number of swap partitions
 my $NofNotMoPart = 0;      # number of not mountet partitions
 my %DiskMountpoints = ();  # mountpoints of every disk. separated by spaces
+my %DiskOptions = ();             # sfdisk options for each disk
 my %MountpointPart = ();   # partition of every mountpoint. e.g. "hda2"
 my %PartMountpoint = ();   # mountpoint of every partition.
 my @swaplist;              # list of all swpa devices
@@ -334,12 +336,13 @@
            if ($paras =~ / end/i){
                $disk = "";
            } else {
-               if($paras =~ m# (/dev/)?(cciss/c\dd\d|ida/c\dd\d|rd/c\dd\d|[a-z]+)#i){
+               if($paras =~ m# (/dev/)?(cciss/c\dd\d|ida/c\dd\d|rd/c\dd\d|[a-z]+\b*)(.*)$#i){
                    $disk = "$2";
                    ($DiskMountpoints{$disk})
                      && die "ERROR: there are more than one configuration of disk $disk.\n";
                    ($DiskSize{$disk}) || die "ERROR: could not read device /dev/$disk\n";
-                   ($test != 1) || (print "config: $disk\n");
+                   $DiskOptions{$disk} = "$3";
+                   ($test != 1) || (print "config: $disk, sfdisk options: $DiskOptions{$disk}\n");
                    $DiskMountpoints{$disk} = "";
                    $MPPrimary{"extended$disk"} = "";
                    $LogPartNo = 4;
@@ -353,6 +356,14 @@
            }
        }

+       if ($DiskOptions{$disk}) {
+               print "New options for $disk = $DiskOptions{$disk}\n";
+               if ($DiskOptions{$disk} =~ m/^\s*-C\s*(\d+)/) {
+                       print "New cylinder count = $1\n";
+                       $DiskSize{$disk} = $1;
+               }
+       }
+
        if ($disk){
            # primary|partition - command
            if($line =~ /^(primary|logical)\s+(.*)$/i){
@@ -711,9 +722,10 @@
            print FILE $sfdiskTables{$disk};
            close(FILE);
         }
-       $command = "LC_ALL=C sfdisk $sfdisk_options /dev/$disk < $filename";
+
+       $command = "LC_ALL=C sfdisk $sfdisk_options $DiskOptions{$disk} /dev/$disk < $filename";
+    print "  $command\n";
        if($test != 1){
-            print "  $command\n";
            $result = `sh -c "$command"`;
            (($? >> 8) == 0) || (die "\nSFDISK ERROR:\n $result\n");
        }
--------------- end -------------



> -----Original Message-----
> From: Cristian Ionescu-Idbohrn
> [mailto:cristian.ionescu-idbohrn at axis.com]
> Sent: Tuesday, October 15, 2002 2:52 AM
> To: Thomas Lange
> Cc: Bruce Edge; linux-fai
> Subject: Re: pass options to sfdisk?
> 
> 
> On Tue, 15 Oct 2002, Thomas Lange wrote:
> 
> > >>>>> On Mon, 14 Oct 2002 17:03:15 -0700, "Bruce  Edge" 
> <bedge at troikanetworks.com> said:
> >
> >     > I need to force a different num of cylinders for 
> sfdisk, BIOS is
> >     > getting it wrong, for a 16 Meg. flash IDE disk.  Where can I
> >     > stick this?
> >
> >     > I just need to pass a "-C 2" to sfdisk.
> 
> > You can only change the script setup_harddisks.
> 
> Which reminds me. I had some trouble with a faulty IBM disc 
> which _always_
> returned error when:
> 
>        -R     Only  execute the BLKRRPART ioctl (to make the ker-
>               nel re-read the partition table).
> 
> This patch will enrich setup_harddisks with new external variables:
> 
>   `sfdisk_optextra' and `sfdisk_ignore_errors'
> 
> These variables may be set anywhere prior to executing 
> setup_harddisks.
> 
> 
> This patch also changes the way the disc devices are picked up, mainly
> because sfdisk can't see more than 1 (one) scsi controller.
> 
> 
> Cheers,
> Cristian
> 



More information about the linux-fai mailing list