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.