Linux – Unable to run Linux kernel images on qemu

Unable to run Linux kernel images on qemu… here is a solution to the problem.

Unable to run Linux kernel images on qemu

I’ve compiled the linux kernel (stable version) from the tree and got initrd and bzImage. I tried running it on the qemu emulator, but I can’t specify the root filesystem partition. (I know this is the partition that loads to run initrd).

My system is Ubuntu 12.04 installed via Wubi on Windows.

The command I’ve been using is

:

qemu-system-x86_64 -kernel bzImage  -initrd initrd.img-3.11 -append "root=/no-clue-what-to-put"

I know root is a parameter that specifies the location of the root partition. Any help to get this image running on qemu would be appreciated.

Solution

Do you really have disk images and root filesystems for qemu and your kernel?

To boot a Linux system, you need more than just a Linux kernel. For QEMU, you also need a root file system that is included in the virtual disk image. This will contain programs that the kernel “controls” when it finishes booting, usually “init” or “systemd”.

So you must generate a qemu-disk image that contains the root file system. If you create it so that the root file system is on the first partition of the virtual disk, you can use -hda/path/to/qemu/disk/image to specify the virtual disk as an argument to qemu, and you can tell the kernel to use the first partition of the virtual disk by -append "root=/dev/sda1" (it can also be /dev/ vda1 or /dev/hda1 depends on the type of disk image you create).

So your final command looks like this:

qemu-system-x86_64 -kernel bzImage -initrd initrd.img-3.11 -hda /path/to/your/qemu/disk/image -append "root=/dev/sda1"

Related Problems and Solutions