/proc/partitions: ide/host0/bus0/target0/lun0/disc ide/host0/bus0/target0/lun0/part1 etc
but in /proc/mounts /dev/hda1 /dev/hda2
note that the names in /proc/mounts are the real names the system knows the disks by. however, when I look on my machine with the SmartArray controller, I see
/proc/partitions cciss/disc0/disc cciss/disc0/part1
but in /prop/mounts /dev/cciss/disc0/part2 etc
as many of you may recall, I'm seeing lots of problems with smart arrays, particularly because the device special file for them is /dev/cciss/c0d0pX and none of the above mappings refer to it. as a result when systemconfigurator calles 'e2label' with a device name like /dev/cciss/disc0/part2 it blows up.
what has me mystified is why for ide devices are the device special file names in /proc/mounts and for ccis devices they're not? is this something systeminager/systemconfigiurator is doing? should I even care?
my fix to all this is to just remap device names into the same format as the device special files, both in systemconfigurator's lable() function and in grub-install as well. I admit the ideal situation would be to do it cleaner, but I think that would start with figuring out why /proc/mounts (and perhaps other files) aren't consistent.
I'd really like to just see this fixed and when I get a chance will post the changes I had to make to get this all to work.
I'm including the changes I had to make to grub-install, Grub.pm, and Label.pm. I left in some of my debugging code because if anyone actually tries this out it'll provide a little more info about what's going on. you'll also see the code in there to fix /etc/mtab which is being discussed in a different thread and once fixed, that code would no longer be needed in my patches.
-mark
--- Label.pm 2004-05-07 13:55:17.000000000 -0400
+++ /usr/lib/systemconfig/Boot/Label.pm 2003-04-10 17:57:56.000000000 -0400
@@ -66,7 +66,6 @@
# only get labels for partitions
if($device =~ /\d+$/) {
verbose("getting label for $device");
- $device=mjscvt($device) if $device =~/cciss\/disc/;
my $label = dev2label($device);
if($label) {
verbose("label is $label");
@@ -83,7 +82,6 @@
my $struct;
my %labels;
local *IN;
-
open(IN,"<$file") or (carp ("Couldn't open $file for reading"), return undef);
while(<IN>) {
# get rid of starting spaces
@@ -123,18 +121,4 @@
return $struct;
}
-sub mjscvt
-{
- my $device=shift;
- my ($p1,$p2,$disk,$part);
-
- # This will map /dev/cciss/disc0/part1 to /dev/cciss/c0d0p1
- ($p1,$p2)=(split(/\//,$device))[3,4];
- $p1=~/(\d+)/;
- $disk=$1;
- $p2=~/(\d+)/;
- $part=$1;
- return("/dev/cciss/c0d${disk}p${part}");
-}
-
1;
--- Grub.pm 2004-05-13 11:32:28.000000000 -0400
+++ /usr/lib/systemconfig/Boot/Grub.pm 2002-12-18 11:29:31.000000000 -0500
@@ -155,7 +155,6 @@
if($devpath =~ m{^/dev/(.+?)p*(\d*)$}) {
my ($dev, $part) = ($1,$2);
- ###MJS $dev="/$dev"; ###
verbose("Device: $dev; Part: $part");
$biosdev = $DEVICE_MAP->{$dev};
verbose("Biosdev: $biosdev");
@@ -174,25 +173,16 @@
sub device_map {
my $grub = shift;
my $device_map = {};
- my $ccissFlag = 0; # assume NOT cciss device
+
my $file = "/tmp/grub.devices";
-
if(-e $file) {
unlink $file;
}
- # prevent generation of new/wrong device map for cciss devices
- if (`grep cciss /proc/partitions` eq '') {
- my $cmd = "$grub --batch --device-map=$file < /dev/null > /dev/null";
- system($cmd) or croak("Couldn't run $cmd");
- verbose("generated device map file $file");
- }
- else {
- $ccissFlag=1;
- $file="/boot/grub/device.map";
- verbose("using existing map file $file");
- croak("$file doesn't contain required 'hd' entry for cciss devices") if
`grep hd $file` eq '';
- }
+ my $cmd = "$grub --batch --device-map=$file < /dev/null > /dev/null";
+ !system($cmd) or croak("Couldn't run $cmd");
+
+ verbose("generated device map file $file");
open(IN,"<$file");
@@ -204,7 +194,7 @@
$device_map->{$real} = $grub;
}
close(IN);
- unlink $file unless $ccissFlag;
+ unlink $file;
return $device_map;
}
@@ -215,7 +205,7 @@
sub find_grub_root {
my $fstab = Boot::Label::fstab_struct("/etc/fstab");
-
+
# invert the mapping... now it is mount => device name
my %mounts = map {$fstab->{$_}->{mount} => $_} keys %{$fstab};
@@ -238,38 +228,19 @@
sub install_loader {
my $this = shift;
my $bootdev = $this->{bootdev};
-
- # if a cciss device present we need to do special things!
- my $recheck='--recheck';
- my $ccissFlag=`grep cciss /proc/partitions` eq '' ? 0 : 1;
- if ($ccissFlag)
- {
- $recheck='';
- if (-z "/etc/mtab")
- {
- verbose("creating new /etc/mtab from /proc/mounts");
- system("grep ext /proc/mounts > /etc/mtab");
- }
- }
-
- verbose("$$this{bootloader_exe} $recheck '$$this{bootdev}'");
- system("$$this{bootloader_exe} $recheck '$$this{bootdev}'");
+ system("$$this{bootloader_exe} --recheck '$$this{bootdev}'");
my $grubroot = find_grub_root();
verbose("Grub root set to '$grubroot'");
- # apparently we only need the device map if cciss (because this wasn't originally
done)
- my $devmap = $ccissFlag ? '--device-map=/boot/grub/device.map' : '';
my $install_cmd = <<END_GRUB;
-$$this{grub} $devmap <<EOF > /dev/null
+$$this{grub} <<EOF > /dev/null
root $grubroot
setup $bootdev
EOF
END_GRUB
- print "=====> GRUB INSTALL HAPPENS HERE <======\n$install_cmd\n";
-
!system($install_cmd) or croak("Error: Couldn't setup grub with cmd
'$install_cmd'!\n$!\n");
return 1;
82,88d81 < < # MJS HACK1 - Any way to change value of $1? < # need to force 'p1' when no part so (hd0,0) will be genterated < tmp_1=$1 < tmp_1=`echo "$1" | sed -e 's%cciss/disc\([0-9]\)$%cciss/c0d\1p1%' \ < -e 's%cciss/disc\([0-9]\)/part\([0-9]\)%cciss/c0d\1p\2%'` < 90c83 < if test -e "$tmp_1"; then --- > if test -e "$1"; then 93c86 < echo "$tmp_1: Not found or not a block device." 1>&2 --- > echo "$1: Not found or not a block device." 1>&2 100c93 < tmp_disk=`echo "$tmp_1" | sed -e 's%\([sh]d[a-z]\)[0-9]*$%\1%' \ --- > tmp_disk=`echo "$1" | sed -e 's%\([sh]d[a-z]\)[0-9]*$%\1%' \ 104c97 < tmp_part=`echo "$tmp_1" | sed -e 's%.*/[sh]d[a-z]\([0-9]*\)$%\1%' \ --- > tmp_part=`echo "$1" | sed -e 's%.*/[sh]d[a-z]\([0-9]*\)$%\1%' \ 137c130 < echo "$tmp_1 does not have any corresponding BIOS drive." 1>&2 --- > echo "$1 does not have any corresponding BIOS drive." 1>&2 195d187 < 342,343d333 < echo "*** grub-install can't find device.map. all bets are off!!!" < 354d343 < cat $device_map 360,361d348 < < echo ">>> REMOVE device_map" 377d363 < 384,385c370 < install_drive="$install_device" < ;; --- > install_drive="$install_device" ;; 395d379 < echo "*** ROOTDIR: $rootdir ROOTDEV: $root_device BOOTDIR: $bootdir BOOTDEV: $bootdir_device" 398d381 < # MJS NOTES - at this point, $rootdir=$bootdir=/dev/cciss/disc0 407d389 < echo "*** CONVERTED: $root_device to ROOT DRIVE: $root_drive" 415d396 < echo "*** FIND_DEVICE: $grubdir FOUND GRUB DEVICE: $grubdir_device" 434d414 < 447d426 < 469,470d447 < # setup --stage2=/boot/grub/stage2 --prefix=/boot/grub (hd0) < cat $device_map
