This is a follow on from the article describing how to mirror your disks using LVM and mdadm. While I was testing booting off each mirror, I managed to screw up grub. This is how I recovered it. The procedure is slightly more complicated than if you used standard partitions due to the fact I was using both LVM and mdadm. However, it just requires a couple of extra steps.

1. Boot your PC/server from a live CD. Be sure to use a 64bit live CD if your OS is 64bit.

2. Mount the root filesystem from your server disk (in this case, a logical volume)

 mount /dev/vg-mint/root /mnt

3. Now bind the directories that grub may need

 mount --bind /dev /mnt/dev
 mount --bind /dev/pts /mnt/dev/pts
 mount --bind /proc /mnt/proc
 mount --bind /sys /mnt/sys

4. Now we need to mount /boot . However, it is a metadevice so first we need to install mdadm

 apt-get install mdadm

5. Now discover the metadevice and mount it

 mdadm --assemble --scan
 mount /dev/md0 /mnt/boot

6. chroot the /mnt environment

 chroot /mnt

7. Now fix grub (mirrors are /dev/sda & /dev/sdb in this example)

 grub-install /dev/sda
 grub-install /dev/sdb
 grub-install --recheck /dev/sda
 grub-install --recheck /dev/sdb

8. Now reboot

Recent Changes

Contribute to this wiki

Why not help others by sharing your knowledge? Contribute something to this wiki and join out hall of fame!
Contact us for a user name and password