this was a very nasty problem that has cost me some time

the hardware was perfectly fine… but somehow an employee managed to kill the /boot partition (improper shutdown?

what the user then ends up with is the grub2 prompt:

solution:

  1. boot from an bootable USB stick (preferably with an image similar to that system installed Debian and Ubuntu and Mint users check this image 🙂
    • make sure the system has LAN internet
  2. unlock existing (lvm2 encrypted root partition (boot is not encrypted)
  3. run a filesystem check on the root (standard double check procedure)
  4. chroot into the broken system
  5. rebuild the /boot partition
# unlock for filesystem check
udisksctl unlock -b /dev/sda5
fsck -y -v -f /dev/mapper/remote7--vg-root

# reboot... no luck?

# 2. unlock
cryptsetup luksOpen /dev/sda5 sda5_crypt

# 2.1. make broken root partition accessible
vgscan --mknodes
#  Reading all physical volumes.  This may take a while...
#  Found volume group "remote7-vg" using metadata type lvm2

vgchange -ay
#  2 logical volume(s) in volume group "remote7-vg" now active

mount /dev/mapper/remote7--vg-root /mnt

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

# depending on where the /root partition is mounted
for i in /dev /dev/pts /proc /sys /run; do mount -B $i /media/user/md2/$i; done
# also mount the root partition to chroot env
mount /dev/sda1 /mnt/boot

# do the chroot
chroot /mnt

# inspect boot partition (there was nothing there like reformatted?)
ll /boot/

# might be good idea to backup /boot before erasing it
tar fcvz /some/usb/stick/boot.tar.gz /boot/

# kill all files in boot partition
rm -rf /boot/*

# reinstall grub2
grub-install /dev/sda
# Installing for i386-pc platform.
# Installation finished. No error reported.

# what images are installed
apt list --installed linux-image-*
# linux-image-4.19.0-14-amd64/stable,stable,now 4.19.171-2 amd64 [installed,automatic]
# linux-image-4.19.0-16-amd64/stable,now 4.19.181-1 amd64 [installed,automatic]
# linux-image-4.19.0-8-amd64/stable,now 4.19.98-1+deb10u1 amd64 [installed]
# linux-image-amd64/stable,now 4.19+105+deb10u11 amd64 [installed]

# re installing two kernels
apt install linux-image-4.19.0-8-amd64 --reinstall
apt install linux-image-4.19.0-14-amd64 --reinstall
# Error: GDBus.Error:org.freedesktop.DBus.Error.ServiceUnknown: The name org.freedesktop.PackageKit was not provided by any .service files

update-initramfs -u -k all

update-grub2

# if it says
/usr/sbin/grub-mkconfig: 253: /usr/sbin/grub-mkconfig: cannot create /boot/grub/grub.cfg.new: Directory nonexistent

mkdir /boot/grub/

# and run again
update-grub2
# reboot and hold fingers crossed
sync
reboot

hints:

# alternative way to mount
udisksctl unlock -b /dev/sda5
udisksctl mount -b /dev/mapper/remote7--vg-root

liked this article?

  • only together we can create a truly free world
  • plz support dwaves to keep it up & running!
  • (yes the info on the internet is (mostly) free but beer is still not free (still have to work on that))
  • really really hate advertisement
  • contribute: whenever a solution was found, blog about it for others to find!
  • talk about, recommend & link to this blog and articles
  • thanks to all who contribute!
admin