SUSE Conversations


Fixing the MBR on SLE 10

mrlinux

By: mrlinux

January 4, 2008 7:09 pm

Reads:460

Comments:1

Rating:0

Reinstalling the GRUB MBR on SLE 10

Background

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.

Procedure

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:

cat /proc/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-2.6.16.46-0.12-smp root=/dev/sda1 vga=0x31a    resume=/dev/system/swap0 splash=silent showopts
    initrd /boot/initrd-2.6.16.46-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

chroot /mnt

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

grub-install /dev/sda

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

exit

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.

VN:F [1.9.22_1171]
Rating: 0.0/5 (0 votes cast)

Tags: ,
Categories: SUSE Linux Enterprise Server, Technical Solutions

Disclaimer: As with everything else at SUSE Conversations, this content is definitely not supported by SUSE (so don't even think of calling Support if you try something and it blows up).  It was contributed by a community member and is published "as is." It seems to have worked for at least one person, and might work for you. But please be sure to test, test, test before you do anything drastic with it.

1 Comment

  1. By:sschapiro

    The method explained here does not only install a new MBR but also the GRUB boot loader.

    If all you want to do is actually install a new MBR (like fdisk /mbr in DOS), then you should use

    lilo -M /dev/sda

    which installs a generic MBR that will boot the active partition.

Comment

RSS