8

I compiled the kernel by doing make menuconfig and make. I was trying to run the bzImage in qemu, by doing qemu -kernel bzImage but it didn't work out with the error message:

Unable to mount root fs on unknown-block(0.0)

Linux kernel error

How can I fix it? How can I run the bzImage in qemu?

  • 5
    The kernel booted fine, but it can't find the root filesystem. What disks have you mounted in the VM? What filesystem type is the root filesystem, what disk type? Are all the necessary drivers compiled in the kernel (forgetting one of the drivers is a common mistake)? – Gilles Sep 16 '12 at 1:59
  • @Gilles I didn't mount a filesystem. After compiling I went straight into the file where the bzImage is located (../arch/x86/boot) and did the command "qemu -kernel bzImage". thats when I got the error. – Coder404 Sep 16 '12 at 13:12
11

It did work out. The kernel booted fine. The error is:

Unable to mount root fs on unknown-block(0.0)

The kernel is looking for a root filesystem. You need to provide one. You can't interact with a kernel without running processes on it, and the initial process has to be loaded from somewhere: when the kernel starts, it mounts a filesystem (the root filesystem) on the directory /, then runs the program /sbin/init. The init program is normally in charge of running boot scripts and starting services including programs that let users log in.

You must make sure that the kernel is able to mount the root filesystem. It must have drivers for the filesystem type and for all the layers involved in the block device (disk controller (SCSI/SATA/IDE/USB/… adapter), partition type, etc.).

Linux offers an additional possibility, which is to load an initial filesystem in RAM that's used during the boot process in order to locate and mount the root filesystem. This initial filesystem can contain modules that handle the device and filesystem type of the root filesystem. There are two slightly different mechanisms: initrd and initramfs.

  • Thanks for the answer! Can I create a virtual filesystem to boot from? If so how would I go about doing that? – Coder404 Jan 2 '13 at 20:27
  • @Coder404 You mean a virtual filesystem to use as the root filesystem? Make it a ram drive. – Gilles Jan 2 '13 at 20:31
  • I do want to use a virtual filesystem as a root filesystem for the kernel that I am building in QEMU. How would I make the virtual filesystem? – Coder404 Jan 3 '13 at 1:06
1

Even though the file sytems will be compiled alone the kernel, an initial file sytem has to be created which will be present in the RAM to run the kernel. To make this inital ram filesystem, mkinitrd is used. In ubuntu mkinitramfs is used instead of that

cd ~/linux/linux-2.6.32.59/arch/i386/boot

mkinitramfs -o initrd.img-2.6.32.59

after that run the kernel on qemu

qemu-system-i386 -kernel bzImage -initrd initrd.img-2.6.32.59 -m 512M

-initrd reprresents the initial ram filesystem

you can find the ram file system under /boot/initramfs-linux.img

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.