Reinstalling GRUB / kernel on a LUKS-encrypted Manjaro install

Hello all,

Today I was updating my Manjaro install, when my computer ran out of battery out of the blue (I know, noob mistake, my battery is moody but it’s still my fault). And upon rebooting I got the following error:

error: file '/vmlinuz-[version number]-generic' not found  
error: you need to load the kernel first

So I did what was recommended in other forum posts. I got the Manjaro live USB, booted onto it.
Now, I also have a LUKS-encrypted system on my computer (as set up by the Manjaro installer). So I opened the LUKS filesystem and chrooted into it.

cryptsetup -v luksOpen /dev/nvme0n1p1 cryptDrive
mount /dev/mapper/cryptDrive /mnt
manjaro-chroot /mnt

This all went OK. Now comes the rub. My intent was to go into the chrooted filesystem, update everything using pacman, and also reinstall GRUB.

pacman -Syu

Runs fine, but the problem arises when I try to fix the GRUB install.

sh-5.1# grub-install
Installing for x86_64-efi platform.
grub-install: error: cannot find EFI directory

And I have checked, there is no EFI partition on this system. I have also tried specifying the EFI folder but GRUB still gets upset. So I am a bit at a loss for what to do, and the forum posts I find don’t seem to have advice for my specific technical issue.

Also, trying to reboot after only updating packages with pacman is insufficient. It seems my grub is still broken.

Any help would be appreciated! Thanks

What is your partition layout?

Were you actually using legacy-bios (rather than EFI) when you installed Manjaro for the first time?

EDIT: If so, look at the –target option for grub-install.

--target=TARGET        install GRUB for TARGET platform
                             [default=x86_64-efi]; available targets:
                             arm-coreboot, arm-efi, arm-uboot, arm64-efi,
                             i386-coreboot, i386-efi, i386-ieee1275,
                             i386-multiboot, i386-pc, i386-qemu, i386-xen,
                             i386-xen_pvh, ia64-efi, mips-arc, mips-qemu_mips,
                             mipsel-arc, mipsel-loongson, mipsel-qemu_mips,
                             powerpc-ieee1275, riscv32-efi, riscv64-efi,
                             sparc64-ieee1275, x86_64-efi, x86_64-xen

Notice the option i386-pc

Thank you! My partition layout is:

sh-5.1# fdisk -l
Disk /dev/nvme0n1: 238.47 GiB, 256060514304 bytes, 500118192 sectors
Disk model: INTEL SSDPEKKF256G8L                    
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: 0x020fa066

Device         Boot     Start       End   Sectors   Size Id Type
/dev/nvme0n1p1 *         2048 481648510 481646463 229.7G 83 Linux
/dev/nvme0n1p2      481648511 500103449  18454939   8.8G 83 Linux


Disk /dev/sda: 58.44 GiB, 62746787840 bytes, 122552320 sectors
Disk model: Extreme         
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: 0x00000000

Device     Boot   Start     End Sectors  Size Id Type
/dev/sda1  *         64 5071551 5071488  2.4G  0 Empty
/dev/sda2       5071552 5079743    8192    4M ef EFI (FAT-12/16/32)


Disk /dev/loop0: 84.7 MiB, 88817664 bytes, 173472 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


Disk /dev/loop1: 388.55 MiB, 407420928 bytes, 795744 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


Disk /dev/loop2: 1.22 GiB, 1306087424 bytes, 2550952 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



Disk /dev/loop3: 691.13 MiB, 724705280 bytes, 1415440 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


Disk /dev/mapper/cryptDisk: 229.66 GiB, 246600891904 bytes, 481642367 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


Disk /dev/mapper/cryptboot: 8.8 GiB, 9446831616 bytes, 18450843 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

in the setup above, /dev/sda is the USB stick I am booting onto but everything else is the local disk.

I have tried your suggestion, and I get the following output:

sh-5.1# sudo grub-install --target=i386-pc /dev/nvme0n1p1
Installing for i386-pc platform.
grub-install: error: unable to identify a filesystem in hostdisk//dev/nvme0n1; safety check can't be performed.

Alternatively, I’ve tried

sh-5.1# sudo grub-install --recheck /dev/mapper/cryptDisk                 
Installing for x86_64-efi platform.
grub-install: error: cannot find EFI directory.

EDIT:
I made a mistake and called grub-install on the partition, not the device. However, changing that doesn’t seem to fix things. This seemingly positive message

sh-5.1# grub-install --target=i386-pc /dev/nvme0n1
Installing for i386-pc platform.
Installation finished. No error reported.

still resulted in a boot menu that did not contain the partition I wanted to boot to.

I then tried calling

sh-5.1# update-grub
Generating grub configuration file ...
Found theme: /usr/share/grub/themes/manjaro/theme.txt
Warning: os-prober will be executed to detect other bootable partitions.
Its output will be used to detect bootable binaries on them and create new boot entries.
grub-probe: error: cannot find a GRUB drive for /dev/sda1.  Check your device.map.
grub-probe: error: cannot find a GRUB drive for /dev/sda1.  Check your device.map.
Adding boot menu entry for UEFI Firmware Settings ...
Found memtest86+ image: /boot/memtest86+/memtest.bin
done

Which still results in a grub menu without my desired partitions visible.

What is sda? I’m assuming nvme0n1 contains your LUKS-encrypted system partition (nvme0n1p1)?

What is the 8GB partition of nvme0n1p2? Cryptboot? Why is there an 8GB partition for “boot”?

When you first boot up, before you are greeted to a Grub menu, you are prompted for the LUKS passphrase? After which you see a Grub menu, but it does not have the entries for Manjaro?

sda is the USB stick I am currently booted on

nvme0n1 indeed contains my LUKS-encrypted system partition

The 8GB partition of nvme0n1p2 is a swap partition. I stupidly loaded it on /dev/mapper/cryptboot, but that’s my mistake

I am indeed greeted by a LUKS passphrase, which works and then brings me to a grub menu with no Manjaro entries.

Thanks again for your help!

Try again in this order, after you boot with a live USB and manjaro-chroot into your system, then from within the chroot:

  1. Force an update via pamac / pacman
  2. Force re-install the kernel packages (i.e, linux510, linux54, linux513, whatever you’re using)
    2a. Optionally, force re-install all installed packages ← (future readers, this was the key solution!)
  3. Check everything in
    3a. /etc/mkinitcpio.conf
    3b. /etc/default/grub
    3c. /etc/fstab
    3d. Look for initramfs and vmlinuz files under /boot/ (while still in the chroot)
    3e. Double-check for presets under /etc/mkinitcpio.d/
  4. Rebuild the initrd with mkinitcpio -P
  5. Re-install Grub to the correct device (as i386-pc target)
  6. Update-grub again (to generate a menu)
    6a. Keep an eye out for messages like "Found linux image: /boot/vmlinuz-5.10-x86_64"
  7. Double-check grub.cfg (under /boot, while still in chroot) to make sure it looks correct
  8. Exit manjaro-chroot and reboot

EDIT: Updated and added a couple steps

I was about to say, that’s OVERKILL for a boot partition! :rofl:

Amazing, this worked! Kind of.

The critical step was to force reinstall the kernel. It turns out I was missing a few files under /boot, which were added when the kernel was reinstalled.

But now I have a new problem. It seems some of the startup programs are failing to start, which is preventing me from actually logging in. The top message I see is “failed to start Modem Manager”, but I think some others are failing to start too. I assume they also got messed up during this failed update. Is there a way to fix packages / daemons using a liveUSB?

That was my suspicion and hence why I made sure to emphasize to force re-install the kernels. :+1:

Looks like you might have to boot back into the live USB, manjaro-choot, and then force a re-install of all packages while in the chroot environment.

Lesson of the century: Make sure you don’t lose power during an update. :wink: (Heck, I think even Apple’s iPhones refuse to update iOS if your battery is below a certain percentage.)

I know T.T I should have known.
in my defense my laptop battery is broken and claimed to have 60% battery when it was actually close to running out.

That’s the risk of using an old / faulty / dying battery, since they cannot accurately report how much charge remains. Keep your laptop plugged into AC power when running updates to play it safe going forwards.


EDIT: I’ve never had to resort to re-installing all packages with pamac, but I believe the -a flag will work:

pamac reinstall -a

It all worked! Everything boots and works great now. Thanks so much!

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.