سؤال

I want to work on linux kernel development on Qemu. I want to modify few kernel files as part of my project. I am only able to find ISO files of the linux distros online which I think we cannot edit. Could anyone please point me in the right direction regarding this?

هل كانت مفيدة؟

المحلول 2

Download Linux kernel source code from kernel.org, then modify, configure, build your kernel. After building you'll get a kernel image usually located at arch/x86/boot/bzImage (if your arch is x86, look at appropriate location for your arch), and this is what you need to test your modified kernel on Qemu. You'll also need a rootfs (use busybox) to run it properly. Use qemu's '-kernel' parameter to pass the bzImage. An example:

 `qemu-system-x86_64 -m 1024 -smp 4 -kernel arch/x86/boot/bzImage -initrd initramfs.gz -append "rdinit=/ root=/dev/ram`

it tells qemu to use 1024 of ram, use 4 cpu.

نصائح أخرى

Buildroot to the rescue

Buildroot is a set of scripts that generates tiny distros with rootfs images smaller than 10MiB.

It downloads everything from source and compiles it, so it is trivial to patch packages up. There is a supported patching mechanism with BR2_GLOBAL_PATCH_DIR https://buildroot.org/downloads/manual/manual.html#customize-patches

The generated images are so tiny, that it becomes possible to understand the entire userland setup, which will make it easier to focus on the kernel.

I have created this setup to automate things as much as possible: https://github.com/cirosantilli/linux-kernel-module-cheat

This setup also works great for ARM: How to use QEMU for learning ARM Linux kernel development?

The best way I would recommend is to you ubuntu-vm-builder.

sudo ubuntu-vm-builder qemu precise --arch 'amd64'  --mem '1024'  --rootsize '4096'  --swapsize '1024'  --kernel-flavour 'generic'  --hostname 'ubuntu'  --components 'main'  --name 'Srikanth'  --user 'ubuntu'  --pass 'ubuntu' --bridge 'br0'  --libvirt 'qemu:///system'

and then run it in qemu.

This would build a qcow2 file, which is copy on write and would be faster than getting a kernel from the source and compiling it.

If you want to modify linux kernel, You can download kernel source from https://www.kernel.org/ . Install on Linux system after modifying code.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top