Fixing the Bootloader of a Ubuntu RAID System
Posted on Mon 19 August 2019 in Sysadmin
If the remote Ubuntu machine does not boot showing the following error
error: unknown filesystem
Entering rescue mode...
grub rescue>
the GRUB bootloader is broken and can be fixed in one of the following ways.
Using the GRUB rescue concole
Follow the steps described in this blog post.
Using a Live System
- Boot into a rescue system (can be done via your server provider's web interface).
- Connect via ssh using
ssh root@ip.address
. -
Once connected, make sure the mdadm tools are installed and assembled:
apt-get install mdadm mdadm --assemble --scan
-
Mount the system partition (e.g.
/dev/md2
):sudo mount /dev/md2 /mnt
-
Check the mdadm.conf entries by looking at
mdadm --examine --scan
-
Mount the boot partition (e.g
/dev/md1
):mount /dev/md1 /mnt/boot
-
Set up the other required mounts:
mount -o bind /dev /mnt/dev mount -o bind /sys /mnt/sys mount -t proc /proc /mnt/proc cp /proc/mounts /mnt/etc/mtab
-
Switch into the chroot environment:
chroot /mnt /bin/bash
-
Install GRUB 2 into the MBR of all relevant disks (e.g.
/dev/sda
and/dev/sdb2
in case of a RAID system with one mirror disk):grub-install /dev/sda grub-install /dev/sdb
-
If any error occur during the last operation, try:
grub-install --recheck /dev/sdX
-
Recreate the file
/boot/grub/grub.cfg
using:update-grub
-
Leave the chroot environment using
CTRL+D
. - Reboot.