linux: running self compiled kernel in qemu: VFS: Unable to mount root fs on unknown wn-block(0,0)

Konstantin picture Konstantin · Jun 21, 2013 · Viewed 12.6k times · Source

I try to get this running and don't know what I'm doing wrong. I have created an Debian.img (disk in raw format with virtual device manager - gui to libvirt I guess) and installed debian with no troubles. Now I want to get this running with a self compiled kernel. I copied the .config-file from my working (virtual) debian and made no more changes at all. This is what I do:

    qemu-system-x86_64 -m 1024M -kernel /path/to/bzImage -hda /var/lib/libvirt/images/Debian.img -append "root=/dev/sda1 console=ttyS0" -enable-kvm -nographic

But during boot I always get this error message.

    [    0.195285] Initializing network drop monitor service
    [    0.196177] List of all partitions:
    [    0.196641] No filesystem could mount root, tried: 
    [    0.197292] Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(0,0)
    [    0.198355] Pid: 1, comm: swapper/0 Not tainted 3.2.46 #7
    [    0.199055] Call Trace:
    [    0.199386]  [<ffffffff81318c30>] ? panic+0x95/0x19e
    [    0.200049]  [<ffffffff81680f7d>] ? mount_block_root+0x245/0x271
    [    0.200834]  [<ffffffff8168112f>] ? prepare_namespace+0x133/0x169
    [    0.201590]  [<ffffffff81680c94>] ? kernel_init+0x14c/0x151
    [    0.202273]  [<ffffffff81325a34>] ? kernel_thread_helper+0x4/0x10
    [    0.203022]  [<ffffffff81680b48>] ? start_kernel+0x3c1/0x3c1
    [    0.203716]  [<ffffffff81325a30>] ? gs_change+0x13/0x13

What I'm doing wrong? Please someone help. Do I need to pass the -initrd option? I tried this already but had no luck yet.

Answer

Konstantin picture Konstantin · Nov 12, 2014

I figured it out by myself. Some time has passed, but as I recall the solution was to provide an initial ramdisk. This is how I got it working with hardware acceleration.

Compiling

make defconfig

CONFIG_EXT4_FS=y
CONFIG_IA32_EMULATION=y
CONFIG_VIRTIO_PCI=y (Virtualization -> PCI driver for virtio devices)
CONFIG_VIRTIO_BALLOON=y (Virtualization -> Virtio balloon driver)
CONFIG_VIRTIO_BLK=y (Device Drivers -> Block -> Virtio block driver)
CONFIG_VIRTIO_NET=y (Device Drivers -> Network device support -> Virtio network driver)
CONFIG_VIRTIO=y (automatically selected)
CONFIG_VIRTIO_RING=y (automatically selected)

---> see http://www.linux-kvm.org/page/Virtio

Enable paravirt in config

Disable NMI watchdog on HOST for using performance counters on GUEST. You may ignore this.

cat /proc/sys/kernel/nmi_watchdog

---> see http://kvm.et.redhat.com/page/Guest_PMU

Start in Qemu

sudo qemu-system-x86_64 -m 1024M -hda /var/lib/libvirt/images/DEbian.img -enable-kvm -initrd /home/username/compiled_kernel/initrd.img-3.2.46 -kernel /home/username/compiled_kernel/bzImage -append "root=/dev/sda1 console=ttyS0" -nographic -redir tcp:2222::22 -cpu host -smp cores=2

Start in KVM

Kernal path: /home/username/compiled_kernel/bzImage
Initrd path: /home/username/compiled_kernel/initrd.img-3.2.46
Kernel arguments: root=/dev/sda1

Hope this helps if someone has the same issues.