Saturday, November 17, 2012

openSUSE: GRUB2 Configuration and Recovery


OpenSUSE 12.2 uses GRUB2 by default. It is configured in two ways:
  1. Yast -> System -> Boot Loader -> Boot Loader Options
  2. Editing configuration files; see Chapter 10 of the openSUSE 12.2 Reference, and especially:
    Section 10.2. Configuration File Structure.

Useful note: A useful thing to know about GRUB in general is that you can edit the command line Grub uses to run the kernel by pressing 'e' at boot time, when Grub is running.

Recovery via YaST

The really fool-proof way to do it is to use YaST. The only problem is, YaST needs to be running on the system which doesn't boot. Turns out this isn't such an insurmountable problem as it may seem:

First, boot a rescue system.
Second, mount your non-booting machine's root and boot under /mnt (in the rescue system)
Third, prepare a chroot environment:
# mount -o bind /proc /mnt/proc 
# mount -o bind /dev /mnt/dev
# mount -o bind /sys /mnt/sys

Fourth, chroot into the non-booting system and run YaST:
# chroot /mnt
# yast

Fifth, go to System -> Boot Loader and reinstall GRUB2.

Sixth, exit to leave the chroot environment.

Seventh, umount /mnt and reboot.

Another possibility

If your system becomes unbootable due to a problem with GRUB2 (bootloader), try the following:
  • Boot to "another" openSUSE 12.2 (for example, the installation DVD is capable of booting a live system
  • Using commands like fdisk -l, blkid, etc., determine the device name of the root filesystem of the non-booting system.
  • Mount the non-booting system root (here, we're assuming it's /dev/sda1):
    # mount /dev/sda1 /mnt
    (If you have a separate boot partition, make sure to mount it to /mnt/boot as well!)
  • Now, you need to know exactly where the bootloader is supposed to reside. This will become the sole argument (DEST) to the grub2-install command. Use /dev/sda as DEST, for example, if you want to install the bootloader in the MBR:
    # grub2-install --force --root-directory=/mnt DEST

    Another (probably safer) approach is to use YaST -> System -> Boot Loader. But I don't know if it works from a Live DVD boot.

If all else fails


No comments:

Post a Comment