3
votes

I have compiled the linux kernel (stable) from the tree and got the initrd and bzImage. I try running it on the qemu emulator but I am having trouble specifying the root file system partition. (I know that this is the partition thats loaded to run initrd from).

My system is Ubuntu 12.04 installed via Wubi on Windows.

The command i have 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 argument that specifies where the root partition is. Any help to get this image running on qemu would be appreciated.

2
try put root=/dev/ram - rakib_
That doesn't work as /dev/ram is not actually a partition and hence its not found - maverick
It'll allow you to use ram as root partition. On your system you don't have it, but it varies upon kernel config. - rakib_
Just try /dev/sda. The append option specifies the kernel command line, which will be run in qemu. Qemu will handle the devices tree and should wire the emulated /dev/sda to something more appropriate. - Rerito

2 Answers

2
votes

Here missing component is kernel parameters to be passed , As you are using -initrd i.e initialramdisk you need to pass rdinit=/(your-app-executable)

you can pass rdinit=/sbin/init or rdinit=/bin/sh try this

qemu-system-x86_64 -kernel bzImage -initrd initrd.img-3.11 -append "root=/dev/ram rdinit=/sbin/init"

2
votes

Do you actually have a disk image and root filesystem to give to qemu and your kernel?

You need more than a linux kernel to boot a linux system. For qemu, you need a root filesystem contained within a virtual disk image as well. This will contain programs to which the kernel "hands control" when it's done booting, usually 'init' or 'systemd'.

So you have to generate a qemu-disk image that contains a root filesystem. If you created it such that the root filesystem is on the first partition of your virtual disk, you can then specify the virtual disk as a parameter to qemu with -hda /path/to/qemu/disk/image, and you can tell the kernel to use the first partition of that virtual disk with -append "root=/dev/sda1" (it could also be /dev/vda1 or /dev/hda1 depending on what kind of disk image you created).

So your final command will look something like:

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