You are not logged in.

#1 2024-04-15 15:01:19

automaticcc
Member
Registered: 2024-04-15
Posts: 2

restore systemd-boot entries / repair bootconfig

Hello,

I use a Dualboot setup (Windows 10 and Arch) with Bitlocker / Luks encrypted drives. I set this up about two years ago, unfortunately I didn't document how I finally set it up back then. Now I want to repair it and I have an idea how, but I'd rather ask beforehand to avoid making the situation worse.

The Problem:
Sometimes the bootloader just disappearing (often triggered by windows update or shutdown in bitlocker decryption screen), Linux is no longer available as boot option / systemd is not loading in this case. Then the system booting directly into Windows and I have to unlock bitlocker with the recovery key bc decryption with password dont work anymore. Normally was able to fix this simply mounting the /dev/sdc1 (linux boot partition) to /mnt/efi, bootctl install and rebooting.

Mistake:
But this time I think I made a mistake, I mounted /dev/sdc1 (linux boot partition) to /boot and did bootctl install. Then I was able to select "Linux Boot Manager" as boot option. After that I rebooted and systemd was loaded again but only with the "reboot into firmware interface" entry. After some research I think the reason is bc the arch.conf is missing as entry in /mnt/efi/loader/entries and the loader.conf isnt setup correctly (when mounted /dev/sdc1, linux boot partition).

The loader.conf in /mnt/efi/loader contained only

timeout 3
console-mode keep

I remember that there was an default arch.conf line in the past. And arch wiki ressources and some threads confirming this with their example conifgs. So I suspect that I have overwritten my config with some defaults.

First question: Is there any easy way to restore my old arch.conf or the old bootloader config in general (with windows)?

I tried find / -name arch.conf, but I only find the default config without the correct / old "options" param and some unrelated arch config files in sysusers.d / tmpfiles.d. In the directory with mounted /dev/sdc1 I dont find any arch.conf Files.

If there is no better way, I think I have to recreate my arch.conf manually like this:

1. mkdir /mnt/efi
2. mount /dev/sdc1 /mnt/efi
3. edit the /mnt/efi/loader/loader.conf like this

default  arch.conf
timeout  4
console-mode max
editor   no

4. Create arch.conf with nano /mnt/efi/loader/entries/arch.conf like this

title   Arch Linux
linux   /vmlinuz-linux
initrd  /initramfs-linux.img
options cryptdevice=UUID=XXXXXXXXXXXXXXXXXXX cryptlvm root=???????? quiet rw

So here is my first problem: I dont know anymore how to configure the options here. If think I get the UUID with blkid /dev/sdc2 (arch linux system partition) but what is the correct root= value?

I really hope for some tipps to repair the systemd-boot config..

thanks in advance

Edit 1: When I run bootctl the "Linux Boot Manager" entry points to Partition /dev/disk-by-partuuid/XXXXXXXX-XXXX-XXXX-XXXX-XXXXXX where XXX is the partuuid of the linux boot partition (confirmed with blkid /dev/sdc1). Like it should be, I think.

Last edited by automaticcc (2024-04-15 15:09:02)

Offline

#2 2024-04-16 10:05:08

automaticcc
Member
Registered: 2024-04-15
Posts: 2

Re: restore systemd-boot entries / repair bootconfig

Okay, I was able to fix it myself.

root cause: The Kernel and initramfs were missing under /boot

1. cryptsetup luksOpen /dev/sdc2 cryptvol
2. mount /dev/mapper/cryptvol /mnt
3. mount /dev/sdc1 /mnt/boot
4. arch-chroot /mnt
5. pacman -S linux

After that I confirmed that the vmlinuz-linux and initramfs-linux.img Files are under boot and the config files are there and correct.

Config /boot/loader/loader.conf

default arch.conf
timeout 5

Config /boot/loader/entries/arch.conf

title Arch Linux
linux /vmlinuz-linux
initrd /initramfs-linux.img
options cryptdevice=PARTUUID=<UUID-OF-SYSTEM-PARTITION>:cryptroot root=/dev/mapper/cryptroot rw (you can get the UUID of the System Partition with blkid)

Then

6. exit (to leave chroot)
7. umount /mnt/boot
8. umount /mnt/
9. cryptsetup luksClose cryptvol
10. shutdown

After that I reactivated the linux boot manager and set it as first boot option, then I rebootet again and was able to select Arch Linux as boot-Option and the system booted successfully. Now I only have to repair the windows boot entry for systemd-boot and everything is fine again.

Maybe this helps someone.. smile

Offline

#3 2024-04-29 09:05:46

basemt
Member
Registered: 2021-12-07
Posts: 20

Re: restore systemd-boot entries / repair bootconfig

Thanks for the update! I had a similar issue, but not from dual-booting, but from accidentally closing the terminal while an update was running, so I still had the conf files, but the images were corrupted.

So I booted from an arch iso, mounted the Luks volume (I have an nvme drive, so for me they were `/dev/nvme0n1p2` for root and `p2` for boot).

I also had to install `linux-zen`, as that is the kernel I am using.

Just leaving this here for the next person having this issue. smile

Offline

Board footer

Powered by FluxBB