detecting multi-controller disk drives

Cristian Ionescu-Idbohrn cristian.ionescu-idbohrn at axis.com
Tue Jun 4 21:51:25 CEST 2002


'sfdisk -q -g' will only show disks drives on the first
scsi-controller.

This patch will list find the first 16 disk drives on all controllers
and pass them over to sfdisk. This can be further generalized for up
to 128 disk drives by matching with /([sh]d[a-z]+)$/.

To really take advantage of it, I believe the block devices must be
somehow created both on the 'nfsroot' and on the target. The default
seems to be /dev/sd[a-h].


--- /usr/lib/fai/nfsroot/sbin/setup_harddisks	Thu May 16 14:44:08 2002
+++ /usr/lib/fai/nfsroot/sbin/setup_harddisks2	Tue Jun  4 12:53:45 2002
@@ -248,10 +248,21 @@
 #****************************************************
 # 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;


Cheers,
Jörgen and Cristian




More information about the linux-fai mailing list