- Create the disk
Let's create a raw disk (you can use other tools like dd
too)
qemu-img create -f raw kernel-dev.img 20G
Now install the system
qemu-system-x86_64 -drive format=raw,file=kernel-dev.img -enable-kvm -boot d -cdrom your.iso
- Create the initrd
We will use dracut
to create a custom initrd with our kenel parameters
dracut --no-compress --no-kernel --kernel-cmdline 'root=/dev/sda rw' -f initramfs.img
Qemu allows you to boot the system without a initrd but I have found it to be very hard to setup
- Done!
Now you should be able to run it
qemu-system-x86_64 -kernel path/to/your/kernel/linux/arch/x86/boot/bzImage -drive format=raw,file=kernel-dev.img -initrd initramfs.img -enable-kvm
Some extra options to add:
-append console=ttyS0
: redirects the console to the serial port-m 4G
: sets the RAM to use (in this case 4GB)-smp 2
: sets the number of cores to use (in this case 2)