Linux kernel is not finding the initrd correctly

initrdlinux-kernelqemu

I had compiled a linux kernel and I wanted to debug it in QEMU. I created a file to boot from by doing the commands

$ qemu-img create -f raw disk.img 200M
$ mkfs.ext2 -F disk.img
# mkdir /mnt/rootfs
# mount -o loop disk.img /mnt/rootfs

Then I did qemu -kernel bzImage -initrd disk.img and got the screen below which says:

Kernel panic - not syncing: VFS: unable to mount root fs on unknown block

My QEMU screen

What have I done wrong and what can I do to fix it?

Best Answer

The kernel is telling you, that it doesn't know which device holds the root file system. Your loop mount isn't necessary. (Unmount it before continuing).

Try a command like

qemu -kernel bzImage -hda disk.img -append root=/dev/sda

The -hda disk.img parameter tells qemu to simulate a disk device based on your disk.img.

The -append root=/dev/sda switch is used by qemu to tell the kernel about it's root device. This is done by appending the root=/dev/sda to the kernel commandline. You can compare this to the kernel commandline of your own kernel by doing cat /proc/cmdline (This is safe). You should see there a root parameter, too.

Related Question