Restoring Grub Boot on a remote server with RAID1

How you can reinstall Grub on a system with RAID1 that is not booting anymore.

The assumption is that things already have gone southward and you have recovered the server with a rescue system.

Checking whether server boots via UEFI or BIOS

Check if a folder /sys/firmware/efi is present and if you can find the string “EFI v” in the Kernel ringbuffer via dmesg|grep “EFI v”. The latter one only produces safe results if the bootup sequence is still contained in the ringbuffer. The first one will be a pretty safe indication that the server is using UEFI.

RAID1 layout

Find out with lsblk which blockdevices do exist and how many RAID partitions there are.

Check all /dev/mdX partitions and find out what their mountpoints are. When you locate the partition for / you can check the filesystem table in /etc/fstab to doublecheck your findings.

Let’s asume partiotions and mountpoints look like this:

/dev/md0 SWAP
/dev/md1 /boot
/dev/md2 /
/dev/md3 /extra

Reasemble your original system under /mnt

Mount / and /boot under /mnt.

mount /dev/md2 /mnt
mount /dev/md1 /mnt/boot

If your system runs with UEFI you also have an UEFI partion that you need to mount instead of the /boot partition. As I found myself on a BIOS system I will continue with this case only.

Include the rescue system’s /dev, /proc, /sys, and /run folders under /mnt.

#mount --bind /dev /mnt/dev
#mount --bind /proc /mnt/proc
#mount --bind /sys /mnt/sys
#mount --bind /run /mnt/run

Change root to /mnt

#chroot /mnt

Reinstall GRUB on all physical disks

#grub-install /dev/sda
#grub-install /dev/sdb

Update GRUB

#update-grub

Exit chroot environment, unmount all devices under /mnt and reboot

#exit

#umount /mnt/dev
#umount /mnt/proc
#umount /mnt/sys
#umount /mnt/run
#umount /mnt/boot
#umount /mnt

#reboot