Rescue Mode

How can we help?

Guides and technical documentation for your Server4You dedicated server or VPS.

Repairing the GRUB Bootloader

GRUB (GRand Unified Bootloader) starts your Linux operating system — if it is damaged or misconfigured, the server cannot boot. This guide shows how to reinstall GRUB from the Linux rescue system via chroot, including on software RAID.

Prerequisite: This guide assumes your server is already running in rescue mode and you are connected via SSH. → Starting rescue mode

Step 1: Mount the System Partitions

Identify your root and boot partitions and mount them into the rescue environment.

First, identify your partition device names using lsblk:

Terminal
lsblk

Then mount the root partition to /mnt and the boot partition to /mnt/boot — adjust the device names to match your lsblk output:

Terminal
mount /dev/sda3 /mnt mount /dev/sda1 /mnt/boot

This example assumes a non-RAID setup. Device names such as sda1, sda3 may differ on your server.

Step 2: Prepare the chroot Environment

Bind-mount essential system directories so commands run in the context of your installed OS.

Bind-mount the essential system directories from the rescue system into your mounted filesystem:

Terminal
for i in /dev /dev/pts /proc /sys /run; do mount -B $i /mnt$i; done

Step 3: Enter chroot and Reinstall GRUB

Switch into your system and write the bootloader to the boot drive.

Enter the chroot environment:

Terminal
chroot /mnt

Reinstall GRUB on the primary boot drive — replace /dev/sda with your actual device name. Do not include a partition number:

Terminal
grub-install --recheck /dev/sda

If you are using a software RAID (RAID1), you must install GRUB on both drives — e.g. grub-install /dev/sda followed by grub-install /dev/sdb.

Step 4: Update GRUB Config and Reboot

Regenerate the configuration file, exit chroot, and cancel rescue mode.

Regenerate the GRUB configuration file (while still inside the chroot). On AlmaLinux and Rocky Linux, use grub2-install /dev/sda in step 3 and grub2-mkconfig -o /boot/grub2/grub.cfg here instead:

Terminal
update-grub

Exit the chroot and the SSH session:

Terminal
exit

Finally, go to your PowerPanel and cancel rescue mode so the server reboots normally. → Cancelling rescue mode

Further Documentation

For more information on GRUB configuration options, refer to the official GNU GRUB documentation.