Setup
Linux Kernel Hacking
Linux: Mainline (/linux_work/linux_mainline)
Hardware: QEMU (qemu-system-x86_64)
Steps
- Install necessary tools
- Build tools: gcc, make
- Kernel configuration: menuconfig dependencies
- QEMU: emulator
- Git: version control
-
Clone Linux mainline repository using
git clone. - Configure and build the Kernel
cd /linux_work/linux_mainline
make mrproper
Configure and build the kernel:
make x86_64_defconfig
make menuconfig
make -j$(nproc)
Detailed instructions here.
- Setup QEMU for kernel testing
Boot on QEMU:
qemu-system-x86_64 -kernel arch/x86/boot/bzImage -drive file=../qemu.img,index=0,media=disk,format=raw -append "root=/dev/sda console=ttyS0" --enable-kvm --nographic
Kill QEMU using Ctrl-A x.
Other
Show and modify contents of qemu-image.img:
sudo losetup -f --show --partscan qemu.img
Detailed instructions here.
Is there other process using the image?
qemu-system-x86_64 -kernel arch/x86/boot/bzImage -drive file=../qemu-image.img,index=0,media=disk,format=raw -append "root=/dev/sda console=ttyS0" --enable-kvm --nographic
qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.80000001H:ECX.svm [bit 2]
qemu-system-x86_64: Failed to get "write" lock
Is another process using the image [../qemu-image.img]?
Fix here.