-
Notifications
You must be signed in to change notification settings - Fork 1
Create an Ubuntu disk image with custom Linux kernel
Tyche runs an unmodified Linux Kernel.
However, it can sometimes be useful to modify Linux for debugging purposes.
At the same time, we would like to benefit from having a full distribution, e.g., Ubuntu, for convenience.
This page describes how to create an Ubuntu disk image with a custom kernel.
Download the distribution you want to use, e.g., Ubuntu.
Assuming the downloaded ISO is ubuntu-desktop.iso, we want a virtual 1TB disk, and we run on x86, type the following in a terminal:
disk_img=ubuntu.qcow2
iso_name=ubuntu-desktop.iso
qemu-img create -f qcow2 "$disk_img" 1T
qemu-system-x86_64 \
-cdrom "$iso_name" \
-drive "file=${disk_img},format=qcow2" \
-enable-kvm \
-m 2G \
-smp 2 \
;
This will run the default Ubuntu installer.
The installer will finish and reboot.
At that point, you can turn down the VM.
You can still run the disk image with built-in kernel.
This is useful to identify the Ubuntu boot drive partition.
qemu-system-x86_64 \
-drive "file=${disk_img},format=qcow2" \
-enable-kvm \
-m 8G \
-smp 8
Once in the VM, open a terminal and type:
df -h
Identify the partition holding /, e.g., /dev/sda3.
Assuming your kernel image is bzImage, and the boot partition is /dev/sda3, you can do the following to check the disk boots with your kernel:
qemu-system-x86_64 \
-hda $disk_img \
-enable-kvm \
-append "root=/dev/sda3" \
-kernel bzImage \
-cpu host \
-m 8G \
-smp 8
All done!