and I'm not surprised.  rhel3 uses grub 0.93 and this is the very 
version I had to make patches for to run earlier versions of 
SystemImager.  I tried running 3.7.3 w/o my patches and the system 
wouldn't boot, with them it would.

To back up, here's the problem - and it's NOT with system imager, it's 
with grub and systemconfigurator!

I've had to patch 3 files, 2 in systemconfigurator and 1 grub-install.  
The thing I've done is to NOT change the image, but rather put the 
patched files into my overrides.  Furthermore, the files I've patched 
are from an earlier systemconfigurator - 2.0.6 but they seem to work 
just fine when I overlay them on top of 2.2.2.  I hope this makes sense...

The problem stems from several thing, mainly that grub incorrectly 
generates a grub.devices file and so cannot be allowed to do so.  This 
means that in Grub.pm you need to see if you're dealing with cciss (or 
ida) and if so do not tell it to generate a new file.  There's also a 
place where grub gets called with --recheck. and this cannot be allowed 
either.  In the older versions of systemimager, it didn't populate 
/etc/mtab which caused systemconfigurator to blow up but that may no 
longer be necessary.  Anyhow, here's what I did for this one:

--- /usr/lib/systemconfig/Boot/Grub.pm  2002-12-18 11:29:31.000000000 -0500
+++ Grub.pm     2004-06-11 14:51:51.000000000 -0400
@@ -173,16 +173,25 @@
 sub device_map {
     my $grub = shift;
     my $device_map = {};
-
+    my $smartArrayFlag = 0;  # assume NOT Compaq SmartArrary device
+
     my $file = "/tmp/grub.devices";
     if(-e $file) {
         unlink $file;
     }

-    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");
+    # prevent generation of new/wrong device map for smart array devices
+    if (`grep -E "cciss|ida" /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 {
+       $smartArrayFlag=1;
+        $file="/boot/grub/device.map";
+        verbose("using existing map file $file");
+       croak("$file doesn't contain required 'hd' entry for SmartArray 
devices")    if `grep hd $file` eq '';
+    }

     open(IN,"<$file");

@@ -194,7 +203,7 @@
         $device_map->{$real} = $grub;
     }
     close(IN);
-    unlink $file;
+    unlink $file    unless $smartArrayFlag;
     return $device_map;
 }

@@ -228,14 +237,31 @@
 sub install_loader {
     my $this = shift;
     my $bootdev = $this->{bootdev};
-    system("$$this{bootloader_exe} --recheck '$$this{bootdev}'");
+
+    # if a smart array device present we need to do special things!
+    my $recheck='--recheck';
+    my $smartArrayFlag=`grep -E "cciss|ida" /proc/partitions` eq '' ? 0 
: 1;
+    if ($smartArrayFlag)
+    {
+        $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}'");

     my $grubroot = find_grub_root();

     verbose("Grub root set to '$grubroot'");

+    # apparently we only need the device map if smart array (because 
this wasn't originally done)
+    my $devmap = $smartArrayFlag ? '--device-map=/boot/grub/device.map' 
: '';
     my $install_cmd = <<END_GRUB;
-$$this{grub} <<EOF > /dev/null
+$$this{grub} $devmap <<EOF > /dev/null
 root $grubroot
 setup $bootdev
 EOF

A second problem is in Labels.pm where again, the wrong this gets done 
for cciss.  These are my changes to it, noting that since device formats 
have changed in 3.7.3 it may no longer be necessary, but I didn't want 
to start playing around with different permutations of patches (at least 
not yet):

--- /usr/lib/systemconfig/Boot/Label.pm 2003-04-10 17:57:56.000000000 -0400
+++ Label.pm    2004-06-11 14:57:22.000000000 -0400
@@ -64,8 +64,10 @@
         my ($junk, $major, $minor, $blocks, $name, $rio, $rmerge, 
$rsect, $ruse, $wio, $wmerge, $wsect, $wuse, $runn,  $ng, $use, $aveq) = 
split (/\s+/,$_);
         my $device = "/dev/". devfs_lookup($name);
         # only get labels for partitions
+        # if Compaq SmartArray we need to convert device name format
         if($device =~ /\d+$/) {
             verbose("getting label for $device");
+           $device=smartArrayCvt($device)    if $device 
=~/cciss\/disc|ida\/disc/;
             my $label = dev2label($device);
             if($label) {
                 verbose("label is $label");
@@ -121,4 +123,19 @@
     return $struct;
 }

+# Map cciss or ida devices to the format /dev/cciss/c0d0p0 OR 
/dev/ida/c0d0p0
+sub smartArrayCvt
+{
+  my $device=shift;
+  my ($type,$p1,$p2,$disk,$part);
+
+  # This will map /dev/cciss/disc0/part1 OR /dev/ida/disc0/part1
+  ($type,$p1,$p2)=(split(/\//,$device))[2..4];
+  $p1=~/(\d+)/;
+  $disk=$1;
+  $p2=~/(\d+)/;
+  $part=$1;
+  return("/dev/$type/c0d${disk}p${part}");
+}
+
 1;

And finally, here's what I did to grub-install:

--- /sbin/grub-install  2004-05-21 13:35:15.000000000 -0400
+++ grub-install        2004-06-14 10:29:10.000000000 -0400
@@ -79,22 +79,30 @@
 # Convert an OS device to the corresponding GRUB drive.
 # This part is OS-specific.
 convert () {
+
+    # patch to remap /dev/cciss/discY/partZ or /dev/ida/discY/partZ to 
c0dYpZ
+    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%' \
+                          -e 's%ida/disc\([0-9]\)$%ida/c0d\1p1%' \
+                           -e 
's%ida/disc\([0-9]\)/part\([0-9]\)%ida/c0d\1p\2%'`
+
     # First, check if the device file exists.
-    if test -e "$1"; then
+    if test -e "$tmp_1"; then
        :
     else
-       echo "$1: Not found or not a block device." 1>&2
+       echo "$tmp_1: Not found or not a block device." 1>&2
        exit 1
     fi

     # Break the device name into the disk part and the partition part.
     case "$host_os" in
     linux*)
-       tmp_disk=`echo "$1" | sed -e 's%\([sh]d[a-z]\)[0-9]*$%\1%' \
+       tmp_disk=`echo "$tmp_1" | sed -e 's%\([sh]d[a-z]\)[0-9]*$%\1%' \
                                  -e 's%\(fd[0-9]*\)$%\1%' \
                                  -e 's%/part[0-9]*$%/disc%' \
                                  -e 's%\(c[0-7]d[0-9]*\).*$%\1%'`
-       tmp_part=`echo "$1" | sed -e 's%.*/[sh]d[a-z]\([0-9]*\)$%\1%' \
+       tmp_part=`echo "$tmp_1" | sed -e 's%.*/[sh]d[a-z]\([0-9]*\)$%\1%' \
                                  -e 's%.*/fd[0-9]*$%%' \
                                  -e 's%.*/floppy/[0-9]*$%%' \
                                  -e 's%.*/\(disc\|part\([0-9]*\)\)$%\2%' \
@@ -127,7 +135,7 @@

     # If not found, print an error message and exit.
     if test "x$tmp_drive" = x; then
-       echo "$1 does not have any corresponding BIOS drive." 1>&2
+       echo "$tmp_1 does not have any corresponding BIOS drive." 1>&2
        exit 1
     fi

@@ -331,6 +339,10 @@
 if test -f "$device_map"; then
     :
 else
+    # This is only an error for cciss/ida devices, but if we don't say 
something the user won't
+    # know what's going on if things fail for unknown reasons
+    echo "*** grub-install can't find device.map.  if /dev/cciss or 
/dev/ida device something is seriouslyong"
+
     # Create a safe temporary file.
     test -n "$mklog" && log_file=`$mklog`

I had actually tracked down where grub itself was in error, but did't 
want to get into trying to patch it so I simply sent the fixes to the 
developers and perhaps that's why the latest version of grub does seem 
to work correctly.

I hope all this makes sense because  I did this work a loooong time ago 
and probably don't remember every little subtlety

-mark



Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Sisuite-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/sisuite-devel

Reply via email to