Reinstalling the GRUB MBR on SLE 10
Occasionally during an install, the MBR is not written correctly and the server will not boot into the second part of the install.
In SLES 9 this was relatively easy to fix as /dev contained static device entries for all devices. SLE 10 uses a full udev implementation, which means that these device files are created on the fly when the system boots. Therein lies the problem – you cannot simply boot to the rescue system and run grub-install as per SLES 9 as it will complain that your boot disk does not exist. Fear not, the fix is simple.
Boot from your SLE 10 media and select “Rescue System” from the boot menu.
When prompted for login details, log in as root (no password is required).
Now check to see if your boot device has been detected properly. In this case I’m using an IBM ServeRAID so my disk will be presented as /dev/sda. If you’re using an HP Smart RAID the device will be something like /dev/cciss/c0d0. Use the following command to see all available partitions:
and you should see something resembling the following
major minor #blocks name 8 0 142192640 sda 8 1 5245191 sda1 8 2 136946092 sda2
This shows that we have a single disk with 2 partitions – in this case sda1 is the root partition and sda2 is used by LVM. sda1 is the partition that we need to use from here on in.
Mount this partition on /mnt as follows
mount /dev/sda1 /mnt
We can now check /mnt/boot/grub/menu.lst and check that it looks ok:
# Modified by YaST2. Last modification on Wed Jan 2 11:24:53 UTC 2008 default 0 timeout 8 ##YaST - generic_mbr gfxmenu (hd0,0)/boot/message ##YaST - activate ###Don't change this comment - YaST2 identifier: Original name: linux### title SUSE Linux Enterprise Server 10 SP1 root (hd0,0) kernel /boot/vmlinuz-126.96.36.199-0.12-smp root=/dev/sda1 vga=0x31a resume=/dev/system/swap0 splash=silent showopts initrd /boot/initrd-188.8.131.52-0.12-smp
Everything looks in order and sda is indeed the disk that we’re installing on.
The next step is to recreate the disk device files inside our real system as udev will not create them there for us.
mknod /mnt/dev/sda b 8 0 mknod /mnt/dev/sda1 b 8 1 mknod /mnt/dev/sda2 b 8 2
Now, we also need to fool our system into thinking that it’s got filesystems mounted!
cp /etc/mtab /mnt/etc/mtab
OK, so the next step is to change into the root filesystem
You will now have a shell that sees your root filesystem as its root rather than being mounted on /mnt. You can now go ahead and re-install the mbr
You will see some error messages about /usr/lib etc, but these safely be ignored. The important things to look for are the following message and the last line which should show
Installation finished. No error reported. ... (hd0) /dev/sda
i.e. the grub has been written to the MBR of your disk.
Now we need to clean up.
Exit the chroot shell with
Now remove the files we created earlier so that the system can boot correctly
rm /mnt/dev/sda rm /mnt/dev/sda1 rm /mnt/dev/sda2 rm /mnt/etc/mtab umount /mnt
You can now reboot and the bootloader should come up just fine.