Repair grub2 boot after OpenSuse 12.3 update messed it up

After my OpenSuse 12.3 installation ran an automatic update on a few packages I wasn't able to boot the system anymore. Instead I ended up in a minimal grub2 shell without any clue what to do next in order to reboot my system again.

Browsing around the internet from another computer I found that things are getting more difficult as I had my root partition encrypted in a LUKS container. But - there is always hope and so I eventually collected enough information from various blogs and news groups to get my system up and running again.

Here are the instructions that have worked for me.

Boot with OpenSuse 12.3 installation DVD

In order to be able to do anything I started up the installation DVD. Since I needed to get access to my encrypted root file system the smartest way is to choose "Installation" when the DVD provides the initial menu. Don't worry, nothing is installed yet, and it won't, because we will jump out in time.

After choosing "Installation" the system asks to confirm the EULA. Click 'Accept' to continue. Next it will find your LUKS partition - and asks you whether you want to provide the passphrase for decrypting it. So yes, choose decryption and enter your password.

Wait until the decryption is done and the installer is waiting for new input from you. At this point the magic stuff starts. Click Ctrl-Alt-F2 to switch to a text console. You will be already logged in as root (the #-prompt is your friend!).

Mount your system partitions

Type the following command to see your partition setup:

# fdisk -l
[... some output omitted ...]
Device Boot         Start         End      Blocks   Id  System
/dev/sda1            2048    87472127    43735040    7  HPFS/NTFS/exFAT
/dev/sda2   *    87472128    87795711      161792   83  Linux
/dev/sda3        87795712   488396799   200300544   8e  Linux LVM

In my case partition 2 contains my boot system, partition 3 my encrypted root and home partitions.

Type another command to look into the encrypted (only accessible because we did the decryption step above):

# lvscan
ACTIVE            '/dev/system/home' [100.00 GiB] inherit
ACTIVE            '/dev/system/root' [25.00 GiB] inherit
ACTIVE            '/dev/system/swap' [4.00 GiB] inherit

Now lets glue together the original system with some mount commands, using the information above:

# mount /dev/system/root /mnt
# mount /dev/sda2 /mnt/boot
# mount --bind /dev /mnt/dev
# mount -o bind /sys /mnt/sys
# mount -t proc /proc /mnt/proc
# cp /proc/mounts /mnt/etc/mtab

Change the root directory into the mounted filesystem and run grub

# sudo chroot /mnt /bin/bash
# grub2-install /dev/sda

The update-grub command mentioaned in some other blogs does not exist any longer, so use grub2-mkconfig instead to finally generate a new grub.cfg file:

# grub2-mkconfig -o /boot/grub2/grub.cfg

This should print a list of added partitions to your screen.

Quit the chroot environment with ctrl-d and reboot your system (reboot or ctrl-alt-del). Hopefully it boots up again as before.

References

http://wiki.ubuntuusers.de/GRUB_2/Reparatur
https://fedoraproject.org/wiki/GRUB_2?rd=Grub2
http://www.gargi.org/showthread.php?4215-openSUSE-12-2-Grub2-Bootloader-wiederherstellen