You are not logged in.

#1 2021-02-26 22:56:43

ispanos
Member
From: Athens, Greece
Registered: 2019-06-18
Posts: 23

[SOLVED] Unified kernel image can't "Switch Root"

# Edit: The issue had nothing to do with the Unified kernel image.
The first issue was that I hadn't installed cryptsetup, so busybox couldn't unlock the target system ( I think).

This made me switch to  systemd for my initramfs and I couldn't get to a shell to troubleshoot.
After many hours, I installed cryptsetup and after a few more hours, I reverted to busybox.
There, I run ls /new_root and I could see the top level btrfs subvolume. That was when I figured out the issue.
I forgot to run

btrfs subvolume set-default /mnt/@

Grub was working fine, so I couln't understand what the issue was.

---

I'm trying to create a Unified Kernel Image and ultimately enable Secure Boot.
Either the documentation is missing something, or I'm missing something in the documentation.

I am getting the following error message when booting:

---
Please enter passphrase for disk root: ****
[FAILED] Failed to start Switch Root.
You are in emergency mode. After logging in, type "journalctl -xb" to view
system logs, "systemctl reboot" to reboot, "systemctl default" or "exit"
to boot into default mode

Cannot open access to console, the root account is locked.
See sulogin(8) man page for more details.

Press enter to continue.
---

After that any time I press enter I get the same message. (except the line that says [failed])

My partition scheme is the following:

  • /dev/vda1 - mounted at /efi

  • /dev/vda2 - encrypted with luks1 - named root

  • /dev/mapper/root has a btrfs partition with multiple subvolumes.

/etc/mkinitcpio.conf  - Just the modified lines

HOOKS=(base systemd autodetect keyboard sd-vconsole modconf block sd-encrypt filesystems fsck)
MODULES=(btrfs)

/etc/vconsole.conf

vconsole.font=
vconsole.keymap=us
FONT=
KEYMAP=us

/root/kernel-command-line.txt

rw loglevel=3 rd.luks.name=UUID_of_vda2=root rd.luks.options=timeout=90s,cipher=aes-xts-plain64:sha256,size=512 root=/dev/mapper/root
objcopy \
    --add-section .osrel="/usr/lib/os-release" --change-section-vma .osrel=0x20000 \
    --add-section .cmdline="/root/kernel-command-line.txt" --change-section-vma .cmdline=0x30000 \
    --add-section .splash="/usr/share/systemd/bootctl/splash-arch.bmp" --change-section-vma .splash=0x40000 \
    --add-section .linux="/boot/vmlinuz-linux" --change-section-vma .linux=0x2000000 \
    --add-section .initrd="/boot/initramfs-linux.img" --change-section-vma .initrd=0x3000000 \
    "/usr/lib/systemd/boot/efi/linuxx64.efi.stub" "/efi/EFI/Linux/linux.efi"

btrfs-progs and amd-ucode are installed.

Now, after this issue is resolved, I need to add the microcode to the kernel.
No hook is provide for either the microcode or rebuilding the Unified Kernel Image.
These are what I came up with. I am not sure they will work properly, so I could use some help.

/etc/pacman.d/hooks/91-microcode.hook

[Trigger]
Type = Package
Operation = Upgrade
Target = linux
Target = amd-ucode

[Action]
Description = Updating microcode in initramfs
When = PostTransaction
Exec =  cat /boot/amd-ucode.img /boot/initramfs-linux.img > /boot/my_new_initrd.img

/etc/pacman.d/hooks/92-uka.hook

[Trigger]
Type = Package
Operation = Upgrade
Target = linux
Target = amd-ucode

[Action]
Description = Updating Unified Kernel Image.
When = PostTransaction
Exec = objcopy \
    --add-section .osrel="/usr/lib/os-release" --change-section-vma .osrel=0x20000 \
    --add-section .cmdline="/root/kernel-command-line.txt" --change-section-vma .cmdline=0x30000 \
    --add-section .splash="/usr/share/systemd/bootctl/splash-arch.bmp" --change-section-vma .splash=0x40000 \
    --add-section .linux="/boot/vmlinuz-linux" --change-section-vma .linux=0x2000000 \
    --add-section .initrd="/boot/my_new_initrd.img" --change-section-vma .initrd=0x3000000 \
    "/usr/lib/systemd/boot/efi/linuxx64.efi.stub" "/efi/EFI/Linux/linux.efi"

Last edited by ispanos (2021-02-28 07:04:20)

Offline

#2 2021-02-27 11:20:45

Lone_Wolf
Member
From: Netherlands, Europe
Registered: 2005-10-04
Posts: 11,868

Re: [SOLVED] Unified kernel image can't "Switch Root"

I know nothing about unified kernel images (or systemd-boot) , but maybe you can simplify things by testing with a non-encrypted root ?


Disliking systemd intensely, but not satisfied with alternatives so focusing on taming systemd.


(A works at time B)  && (time C > time B ) ≠  (A works at time C)

Offline

#3 2021-02-27 16:30:53

Head_on_a_Stick
Member
From: London
Registered: 2014-02-20
Posts: 7,680
Website

Re: [SOLVED] Unified kernel image can't "Switch Root"

I can't help with the "Switch Root" error (sorry) but:

ispanos wrote:

Now, after this issue is resolved, I need to add the microcode to the kernel.
No hook is provide for either the microcode or rebuilding the Unified Kernel Image.
These are what I came up with. I am not sure they will work properly, so I could use some help.

You don't actually need to add amd-ucode.img separately because it's added automatically by /usr/lib/tmpfiles.d/linux-firmware.conf: https://bugs.archlinux.org/task/59840

If you want it loaded early by the initramfs then the µcode can be included in the initramfs image by adding them to the FILES array in /etc/mkinitcpio.conf, like this:

FILES=(/lib/firmware/amd-ucode/microcode_amd.bin /lib/firmware/amd-ucode/microcode_amd_fam15h.bin /lib/firmware/amd-ucode/microcode_amd_fam16h.bin /lib/firmware/amd-ucode/microcode_amd_fam17h.bin)

^ That example adds all of the µcode files but your processor will only need one of the families.

Offline

#4 2021-02-27 17:12:05

loqs
Member
Registered: 2014-03-06
Posts: 17,196

Re: [SOLVED] Unified kernel image can't "Switch Root"

Head_on_a_Stick wrote:
ispanos wrote:

Now, after this issue is resolved, I need to add the microcode to the kernel.
No hook is provide for either the microcode or rebuilding the Unified Kernel Image.
These are what I came up with. I am not sure they will work properly, so I could use some help.

You don't actually need to add amd-ucode.img separately because it's added automatically by /usr/lib/tmpfiles.d/linux-firmware.conf: https://bugs.archlinux.org/task/59840

This is no longer accurate as none of the kernels Arch ships have CONFIG_MICROCODE_OLD_INTERFACE enabled so late loading is not supported and the reload triggered by linux-firmware does nothing.

Offline

#5 2021-02-27 17:18:46

Head_on_a_Stick
Member
From: London
Registered: 2014-02-20
Posts: 7,680
Website

Re: [SOLVED] Unified kernel image can't "Switch Root"

Thanks for the correction loqs.

@OP: looks like you didn't set the COMPRESSION option to "cat" in /etc/mkinitcpio.conf, perhaps that's why you see the "Switch Root" error.

Offline

#6 2021-02-27 21:27:41

ispanos
Member
From: Athens, Greece
Registered: 2019-06-18
Posts: 23

Re: [SOLVED] Unified kernel image can't "Switch Root"

Head_on_a_Stick wrote:

Thanks for the correction loqs.

@OP: looks like you didn't set the COMPRESSION option to "cat" in /etc/mkinitcpio.conf, perhaps that's why you see the "Switch Root" error.

Could you kindly use Strike-through on the previous messages that loqs was refering to?
As far as compression, I've left it to its default value. It not "not set", its set to the defaults. If there was any issue with the compression of the initramfs, I think I wouldn't get that far in the boot process.

Lone_Wolf wrote:

I know nothing about unified kernel images (or systemd-boot) , but maybe you can simplify things by testing with a non-encrypted root ?

I will test that after I check  this out. I found it right before I had to go to sleep.

Whoever is interested, I will soon publish my asnible playbook. If anyone wants to help me troubleshoot it, it doens't take much time to get it running. I can share it a bit earlier. Using a separate partition for pacmans cache, it takes me 1around 150 seconds to reboot to the newly installed system.

Offline

Board footer

Powered by FluxBB