0

I created a qcow2 file using qemu-img create -f qcow2 fedora.qcow2 20G . I installed Fedora 43 on that and I am able to boot it normally using qemu-system-x86_64 -m 2G -smp 2 -enable-kvm -drive file=~/work/vms/fedora.qcow2,format=qcow2 . My root partition is at /dev/sda3 inside this VM.

Next, I built my own (debug enabled) kernel from source. Also built the initramfs using dracut. I am trying to boot my custom kernel using:

qemu-system-x86_64 -kernel ~/work/linux/arch/x86_64/boot/bzImage -initrd ~/work/linux/initramfs-6.19.0+.img -append "root=/dev/sda3 rw console=ttyS0 nokaslr" -drive file=~/work/vms/fedora.qcow2,format=qcow2 -m 2G -s -S -nographic

From another terminal I run gdb vmlinux and then:

(gdb) target remote :1234
Remote debugging using :1234
0x000000000000fff0 in ?? ()
(gdb) c

At this point my expectation was that the kernel should boot successfully. However, I am seeing the following error:

[  OK  ] Reached target initrd-switch-root.target - Switch Root.
         Starting initrd-switch-root.service - Switch Root...
[FAILED] Failed to start initrd-switch-root.service - Switch Root.
See 'systemctl status initrd-switch-root.service' for details.

Generating "/run/initramfs/rdsosreport.txt"


Entering emergency mode. Exit the shell to continue.
Type "journalctl" to view system logs.
You might want to save "/run/initramfs/rdsosreport.txt" to a USB stick or /boot
after mounting them and attach it to a bug report.



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

Press Enter to continue.

What am I missing here?

Also, is there a way to create a blank qcow2 file and use my bzImage and initramfs file to boot and debug the kernel? I don't want to install a linux distro inside the VM.

2 Answers 2

0

The kernel is happy enough; it's fully "booted." You're now in the more distro-specific parts of the boot process where it was trying to switch from the root in the initramfs image to the one on your drive and that failed.

To access the logs its talking about, I believe you need to properly set the root password when you're booted with the stock kernel.

Sign up to request clarification or add additional context in comments.

Comments

0

This worked: qemu-system-x86_64 -kernel ~/work/linux/arch/x86_64/boot/bzImage -initrd ~/work/linux/initramfs-6.19.0+.img -append "root=/dev/sda3 rootflags=subvol=root rw console=ttyS0 nokaslr" -drive file=~/work/vms/fedora.qcow2,format=qcow2 -m 2G -s -S -nographic.

BTRFS filesystem creates a subvolume with the name "root". This is evident when looking at the output of findmnt / . The subvolume has to be specified as rootflags=subvol=root

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.