Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save Jiab77/71a2e9e6c60139e562c19d0b36b10607 to your computer and use it in GitHub Desktop.
Save Jiab77/71a2e9e6c60139e562c19d0b36b10607 to your computer and use it in GitHub Desktop.
Once rebooted after patching, you will kindly greated by error: symbol 'grub_calloc' not found, entering rescue mode and way to boot the OS anymore...

Repair GRUB after BootHole broken patch

Once rebooted after patching, you will kindly greated by error: symbol 'grub_calloc' not found, entering rescue mode and way to boot the OS anymore...

The thing become even more horrible if you are using an encrypted partition plus LVM...

You can skip the steps 2 and 4 if you just have a normal partition scheme with no encryption or LVM.

Recovery steps

Step 1: Boot with the OS live-cd

Step 2: Unlock the encrypted disk

Just open the file browser, select your encrypted drive and enter passphrase to unlock it when prompted.

Step 3: Analyze encrypted disk structure

Just use:

# Become root
sudo su -

# List block devices
lsblk

# List all disks / partitions
fdisk -l

It will be usefull for the next steps.

Skip the next step if you have a normal partition and no LVM and go directly to step 5. Just replace /dev/mapper by /dev/your-partition-found-with-fdisk.

Step 4: Load LVM volume

You might need to install the lvm2 package to proceed:

# Update your package cache
apt update

# Install required lvm2 package
apt install lvm2

# Scan volume groups
vgscan -v

# Activate volume group
vgchange -ay -v

# Scan everything
pvs ; vgs ; lvs

# Display logical volume found
lvdisplay

In my case, it was /dev/mapper/data-root that I needed to mount.

Step 5: Mount found LVM partition

Now that the root partition is found, you'll need to map it to your live OS:

# Create the 'rescue' folder
mkdir -v /rescue

# Mount the 'root' partition found
mount -v /dev/mapper/data-root /rescue

# Mount the 'boot' partition found with 'fdisk'
mount -v /dev/vda1 /rescue/boot

# Bind mount required folders for later 'chroot'
for fs in /proc /sys /run /tmp /dev ; do mount -v --bind "$fs" "/rescue${fs}" ; done

Step 6: Repair GRUB

Once everything has been mounted correctly, we can setup the chroot and proceed to the GRUB repair:

# Setup 'chroot'
chroot /rescue

# Repair GRUB (by reinstalling it)
grub-install /dev/vda1

# You should get this as final result
Installing for i386-pc platform.
Installation finished. No error reported.

# Leave 'chroot'
exit

Step 7: Unmount everything and restart

Now that GRUB has been reinstalled, you can unmount everything and restart your computer:

# Move to the root path
cd /

# Unmount everything
for fs in /proc /sys /run /tmp /dev ; do umount "/rescue${fs}" ; done
umount -v /rescue/boot
umount -v /rescue

# Delete 'rescue' folder
rm -v /rescue

# Restart your computer
reboot

Conclusion

If all steps went without any issues, you should get your computer OS booting again as expected 😉.

References

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