pass options to sfdisk?

Cristian Ionescu-Idbohrn cristian.ionescu-idbohrn at axis.com
Tue Oct 15 11:52:08 CEST 2002


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

--------------------------------------------------------------------------
--- /home/fai/fai-2.3.4/usr/lib/fai/sbin/setup_harddisks        Thu May 16 14:44:08 2002
+++ /usr/lib/fai/sbin/setup_harddisks   Tue Aug 27 14:21:36 2002
@@ -149,6 +149,9 @@ my $sectorsize = 512;

 # used programs
 my $sfdisk_options = "-q";     # be quiet
+$sfdisk_options = $sfdisk_options . " $ENV{sfdisk_optextra}"
+  if $ENV{sfdisk_optextra};
+my $sfdisk_ignore_errors = $ENV{sfdisk_ignerrors} ? $ENV{sfdisk_ignerrors} : 0;
 my $mke2fs_options = "-q";     # be quiet
 my $mkreiserfs_options = "";
 my $mkswap_options = "";
@@ -248,10 +251,21 @@ sub PartName {
 #****************************************************
 # Read all partition tables of this machine
 #****************************************************
+sub get_all_devices {
+       my @devs;
+       open(PROC, "/proc/partitions") || return '';
+       while(<PROC>) {
+               push(@devs, "/dev/$1") if /([sh]d[a-z])$/;
+       }
+       close(PROC);
+       join(' ', @devs);
+}
+
 sub GetAllDisks{
     my $line=""; my $disk=""; my $device=""; my $rest; my $result; my $divi;
     print "disks found:";
-    $result = `sh -c "LC_ALL=C sfdisk -g -q"`;
+    my $all_part = &get_all_devices;
+    $result = `sh -c "LC_ALL=C sfdisk -g -q $all_part"`;
     foreach my $line(split(/\n/,$result)){
        if($line =~ m'^/dev/(.+?):\s+(\d+)\s+cylinders,\s+(\d+)\s+heads,\s+(\d+)\s+sectors'i){
            $disk = $1;
@@ -712,6 +726,7 @@ sub PartitionPersfdisk{
            close(FILE);
         }
        $command = "LC_ALL=C sfdisk $sfdisk_options /dev/$disk < $filename";
+       $command = $command . " || true" if $sfdisk_ignore_errors;
        if($test != 1){
             print "  $command\n";
            $result = `sh -c "$command"`;
--------------------------------------------------------------------------



More information about the linux-fai mailing list