Skip to content

Instantly share code, notes, and snippets.

@B4nd1
Created May 23, 2025 16:13
Show Gist options
  • Save B4nd1/718785ca64cf401eafb09c6d1fc83398 to your computer and use it in GitHub Desktop.
Save B4nd1/718785ca64cf401eafb09c6d1fc83398 to your computer and use it in GitHub Desktop.
GRUB Recovery on VPS via Rescue Mode

GRUB Repair

Broken apt upgrade output

grub-pc: Running grub-install ...
Installing for i386-pc platform.
grub-install: warning: File system 'ext2' doesn't support embedding.
grub-install: warning: Embedding is not possible. GRUB can only be installed in this setup by using blocklists. However, blocklists are UNRELIABLE and their use is discouraged.
Installation finished. No error reported.
grub-install succeeded for /dev/vda2

Start rescue environment

I am using 4.x (Roaring Lionus) Kernel – 64bit

Disk Layout

rescue # lsblk -l
NAME   MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sr0     11:0    1 1024M  0 rom
vda    254:0    0   20G  0 disk
vda1   254:1    0    1M  0 part
vda2   254:2    0   20G  0 part
vdb    254:16   0  1.1G  0 disk
vdb1   254:17   0  1.1G  0 part

Note: This setup uses Legacy BIOS boot mode.

Step 1: Mount and Chroot into Your System

# Mount the root partition
mkdir /mnt/rescue
mount /dev/vda2 /mnt/rescue

# Bind system directories
for d in /dev /dev/pts /proc /sys /run; do
  mount --bind $d /mnt/rescue$d
done

# Chroot into the installed system
chroot /mnt/rescue /bin/bash

Step 2: Reinstall GRUB

grub-install --target=i386-pc --recheck /dev/vda

Expected Output

Installing for i386-pc platform.
Installation finished. No error reported.

Step 3: Update GRUB Configuration

update-grub

Expected Output

Sourcing file `/etc/default/grub'
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-6.8.0-60-generic
Found initrd image: /boot/initrd.img-6.8.0-60-generic
Found linux image: /boot/vmlinuz-6.8.0-59-generic
Found initrd image: /boot/initrd.img-6.8.0-59-generic
Warning: os-prober will not be executed to detect other bootable partitions.
Systems on them will not be added to the GRUB boot configuration.
Check GRUB_DISABLE_OS_PROBER documentation entry.
Adding boot menu entry for UEFI Firmware Settings ...
done

Step 4: Exit and Reboot

# Exit chroot environment
exit

# Unmount bound directories
for d in /run /sys /proc /dev/pts /dev; do
  umount /mnt/rescue$d
done

# Unmount root partition
umount /mnt/rescue

Exit from rescue mode and reboot.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment