Manual booting linux with LVM (and fixing grub)

GRUB boot loader

Just a short notice, so that I know it if I need it again…and others could find it.

Recently, upgrading a VM to Debian 10 resulted in a broken bootloader. The error message was:

symbol ‘grub_calloc’ not found

And the grub resuce shell did prompt.

Manual boot with an LVM file system

The VM was patitioned using a LVM (Locigal Volume Manager) setup. Hence, the default root partition is not just /dev/sda or so.

So, here are the steps to boot the VM manually:

# see list of available partitions
# smth like (hd0) (hd0,2) (hd0,gpt1)
set prefix=(hd0,gpt1)/boot/grub
set root=(hd0,gpt1)
insmod normal

Now, the “normal” grub shell starts, we continue:

insmod linux
ls /
# list the boot partition, could also be 'ls (hd0,gpt1)/'
linux /vmlinux-<version> root=/dev/mapper/<hostname>-root
initrd /initrd-<version>.img


The right root partition can also be found in the grub.cfg file, e.g. by executing cat /boot/grub/grub.cfg.

Repair grub

Once, the system did boot, grub can be repaired with:

# as root...
$ update-grub
$ grub-install /dev/sda   # not /dev/sdaX!
# should finish with the statement 'Installation finished. No error reported.'
# the right device can be found with 'fdisk -l'

# afterwards
$ reboot

Yes, I know there are ways to boot a VM without a boot loader, but the setup was like this, when I had to fix the problem…

You have another opinion?
Great! Then let's reduce the fallacy together!

Why are there no comments?