无法在 QEMU 中启动自定义构建的内核(修改后的 kconfig 内核)

无法在 QEMU 中启动自定义构建的内核(修改后的 kconfig 内核)

我已经从 defconfig 构建了一个内核,并在 QEMU 中启动它,它工作得很好。但是当我尝试在 QEMU 中启动自定义构建的内核时,它抛出了一些错误:

[    1.039137] /dev/root: Can't open blockdev
[    1.039498] VFS: Cannot open root device "UUID=64ca6276-cee4-4339-9b83-3867a5c50a6e" or unknown-block(0,0): error -6
[    1.040393] Please append a correct "root=" boot option; here are the available partitions:
[    1.041109] Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(0,0)
[    1.041933] CPU: 0 PID: 1 Comm: swapper/0 Not tainted 6.1.19-zos-v4 #6.1.19
[    1.042523] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.15.0-1 04/01/2014
[    1.043227] Call Trace:
[    1.043449]  <TASK>
[    1.043637]  dump_stack_lvl+0x34/0x48
[    1.043961]  panic+0x102/0x274
[    1.044234]  mount_block_root+0x15e/0x1f8
[    1.044582]  prepare_namespace+0x136/0x165
[    1.044933]  kernel_init_freeable+0x1e9/0x1f4
[    1.045309]  ? rest_init+0xc0/0xc0
[    1.045603]  kernel_init+0x11/0x120
[    1.045976]  ret_from_fork+0x22/0x30
[    1.046288]  </TASK>
[    1.046610] Kernel Offset: 0x1ca00000 from 0xffffffff81000000 (relocation range: 0xffffffff80000000-0xffffffffbfffffff)
[    1.047579] ---[ end Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(0,0) ]---

最初我认为存在一些内核配置问题,但排除了不是因为必要的文件系统已启用,而且我运行的 QEMU 命令也是正确的,因为它与 defconfig 构建的内核完美配合。

QEMU 命令(我用来运行 defconfig 和我的自定义内核):

这个命令很好地启动了我的 defconfig 内核,但它对我的自定义内核不起作用。

sudo qemu-system-x86_64 -enable-kvm -m 1024 -kernel /home/motti/Downloads/kernel-6.1.19/boot/vmlinuz-6.1.19 -drive file=/home/motti/Documents/bullseye.img,format=raw -append "root=/dev/sda console=ttyS0" -nographic

所以我通过尝试使用 mkinitramfs 生成 initrd 文件并将其添加到 QEMU 命令进行交叉检查来进行检查

sudo qemu-system-x86_64 -enable-kvm -m 1024 -kernel /home/motti/Downloads/kernel-6.1.19/boot/vmlinuz-6.1.19-zos-v4 -initrd /home/motti/Downloads/kernel-6.1.19/boot/initrd.img-6.1.19 -drive file=/home/motti/Documents/bullseye.img,format=raw -append "root=UUID=64ca6276-cee4-4339-9b83-3867a5c50a6e console=ttyS0" -nographic

其中 root 参数具有对应于 bullseye.img 的 UUID(我一开始也尝试使用 /dev/sda 而不是 UUID,但它不起作用),并且 -initrd 标记具有从 mkinitramfs 生成的 initrd 文件。

启动时出现此错误:

[    1.179948] cfg80211: Loading compiled-in X.509 certificates for regulatory database
[    1.181050] cfg80211: Loaded X.509 cert 'sforshee: 00b28ddf47aef9cea7'
[    1.181853] platform regulatory.0: Direct firmware load for regulatory.db failed with error -2
[    1.182942] cfg80211: failed to load regulatory.db
[    1.184226] Freeing unused kernel image (initmem) memory: 1400K
[    1.187600] Write protecting the kernel read-only data: 22528k
[    1.189014] Freeing unused kernel image (text/rodata gap) memory: 2044K
[    1.189640] Freeing unused kernel image (rodata/data gap) memory: 44K
[    1.227933] x86/mm: Checked W+X mappings: passed, no W+X pages found.
[    1.228515] x86/mm: Checking user space page tables
[    1.264742] x86/mm: Checked W+X mappings: passed, no W+X pages found.
[    1.265336] Run /init as init process
Loading, please wait...
Starting version 249.11-0ubuntu3.7
[    1.413971] tsc: Refined TSC clocksource calibration: 2591.510 MHz
[    1.415249] clocksource: tsc: mask: 0xffffffffffffffff max_cycles: 0x255ae81315d, max_idle_ns: 440795291724 ns
[    1.418906] clocksource: Switched to clocksource tsc
Begin: Loading essential drivers ... done.
Begin: Running /scripts/init-premount ... done.
Begin: Mounting root file system ... Begin: Running /scripts/local-top ... done.
Begin: Running /scripts/local-premount ... done.
[    1.767632] input: ImExPS/2 Generic Explorer Mouse as /devices/platform/i8042/serio1/input/input3
Begin: Waiting for root file system ... Begin: Running /scripts/local-block ... done.
done.
Gave up waiting for root file system device.  Common problems:
 - Boot args (cat /proc/cmdline)
   - Check rootdelay= (did the system wait long enough?)
 - Missing modules (cat /proc/modules; ls /dev)
ALERT!  UUID=64ca6276-cee4-4339-9b83-3867a5c50a6e does not exist.  Dropping to a shell!


BusyBox v1.30.1 (Ubuntu 1:1.30.1-7ubuntu3) built-in shell (ash)
Enter 'help' for a list of built-in commands.

(initramfs) 

你能帮我解决这个问题吗?

相关内容