Manual booting linux with LVM (and fixing grub)
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:
ls
# see list of available partitions
# smth like (hd0) (hd0,2) (hd0,gpt1)
set prefix=(hd0,gpt1)/boot/grub
set root=(hd0,gpt1)
insmod normal
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
boot
Where:
<version>
is the installed Linux kernel version<hostname>
is the name of the partition, which is based on the hostname. In my example, the hostname washome-sys1
, so the correct root partition wasroot=/dev/mapper/home--sys1-root
(please note the--
due to the-
in the hostname).
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…