“A man falling from the 70th floor might think he can fly when passing the 20th floor” – that’s basically the feeling when accidentally /boot
folder is deleted and the PC keeps working as everything is okay. The harsh truth hits after the next reboot.
Things become tougher when the disk is encrypted, so attempt to recover this folder with kernel package isn’t a valid solution. Here is a list of steps to eventually recover your PC with Fedora 29 installed:
- Boot with Fedora live-CD
- Install grub related packages:
$ yum install *grub* boom-boot
- Create a directory for mounting encrypted partition
$ mkdir /mnt/root
- List partitions
$ fdisk -l /dev/nvme0n1 Disk /dev/nvme0n1: 477 GiB, 512110190592 bytes, 1000215216 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disklabel type: dos Disk identifier: 0x30c3a181 Device Boot Start End Sectors Size Id Type /dev/nvme0n1p1 * 2048 2099199 2097152 1G 83 Linux /dev/nvme0n1p2 2099200 1000214527 998115328 476G 83 Linux</pre>
- Open the encrypted partition
$ cryptsetup luksOpen /dev/nvme0n1p2 crypted_root Enter passphrase for /dev/nvme0n1p2:
- List all logical volumes to find the root volume on the encrypted disk
$ lvscan ACTIVE '/dev/fedora/pool00' [<444.46 GiB] inherit ACTIVE '/dev/fedora/root' [100.00 GiB] inherit ACTIVE '/dev/fedora/home' [<344.46 GiB] inherit ACTIVE '/dev/fedora/swap' [<15.47 GiB] inherit ACTIVE '/dev/fedora/docker-pool' [6.12 GiB] inherit
- Mount
root
andboot
directories
mount /dev/fedora/root /mnt/root mount /dev/nvme0n1p1 /mnt/root/boot
- Chroot to the mounted directory
sudo mount -o bind /dev /mnt/root/dev sudo mount -o bind /proc /mnt/root/proc sudo mount -o bind /sys /mnt/root/sys sudo mount -o bind /run /mnt/root/run sudo chroot /mnt/root
- Use grub2 tools for recreating the /boot directory deleted content
- This isn’t sufficient since the
vmlinuz
andinitrd
files might be missing. To make sure they reappear, removing and installing the kernel will re-create them on the /boot folder
sudo grub2-install --no-floppy --recheck /dev/nvme0n1 sudo grub2-mkconfig -o /boot/grub2/grub.cfg
- Use grub2 tools for recreating the /boot directory deleted content including creating the grub.cfg with menu entries according to the existing files
I’ve encountered an issue with an issue with the boom-boot-grub2, skipped by disabling it from /etc/defaults/boom_42
- Unmount and close the encrypted partition
umount /mnt/root/boot umount /mnt/root cryptsetup closeLuks /dev/fedora/root
- Remove installation media and reboot – boot menu should appear