我尝试使用 febootstrap 为 qemu-kvm 制作屋顶图像。
我首先用命令生成了一个屋顶
febootstrap -i coreutils -i vim centos79 centos_7.9 https://mirrors.163.com/centos/7/os/x86_64/
之后,我得到了如下目录
> tree centos_7.9/ -L 1
centos_7.9/
├── bin -> usr/bin
├── boot
├── dev
├── etc
├── home
├── lib -> usr/lib
├── lib64 -> usr/lib64
├── media
├── mnt
├── opt
├── proc
├── root
├── run
├── sbin -> usr/sbin
├── srv
├── sys
├── tmp
├── usr
└── var
然后,我创建了一个 qemu 映像并将所有文件从 centos_7.9 复制到该映像。
qemu-img create centos79.img 1g
mkfs.ext4 centos79.img
mkdir mnt_dir
sudo mount -o loop centos79.img mnt_dir
cp centos_7.9/* mnt_dir
umount mnt_dir
然而,当我跑步时
qemu-system-x86_64 -kernel /boot/vmlinuz-`uname -r` \
-hda=centos79.img \
-append "root=/dev/sda console=ttyS0" \
-enable-kvm -nographic
或者
qemu-system-x86_64 -kernel /boot/vmlinuz-`uname -r` \
-drive file=centos79.img \
-append "root=/dev/hda console=ttyS0" \
-enable-kvm -nographic
报道称
[ 1.766919] Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(0,0)
[ 1.767906] CPU: 0 PID: 1 Comm: swapper/0 Not tainted 5.14.0-3.1.0.kwai+ #10
[ 1.767906] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 0.5.1 01/01/2011
[ 1.767906] Call Trace:
[ 1.767906] dump_stack_lvl+0x34/0x48
[ 1.767906] panic+0xfb/0x2cd
[ 1.767906] mount_block_root+0x28c/0x29f
[ 1.767906] prepare_namespace+0x13b/0x16a
[ 1.767906] kernel_init_freeable+0x17f/0x1a4
[ 1.767906] ? rest_init+0xc0/0xc0
[ 1.767906] kernel_init+0x16/0x130
[ 1.767906] ret_from_fork+0x22/0x30
[ 1.767906] Kernel Offset: disabled
[ 1.767906] ---[ end Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(0,0) ]---
我应该怎么做才能解决这个问题?