-
Run with Qemu. (keep inline, new lines does not work in windows terminal)
- Create virtual disk - 'qcow2', 'raw' or other format supported by Qemu (35 GB atleast).
qemu-system-x86_64 -accel whpx -drive file='Ubuntu Server.qcow2,format=qcow2',if=virtio,discard=unmap -cdrom ubuntu-server.iso -m 8G -smp 10 -netdev user,id=net0,hostfwd=tcp::2222-:22 -device virtio-net,netdev=net0 -vga virtio -boot order=c -nographic -monitor telnet:127.0.0.1:4444,server,nowait -
SSH into the VM. (enable SSH via optional-features)
ssh -p 2222 username@localhost
-
Clone the Linux kernel.
git clone https://kernel.googlesource.com/pub/scm/linux/kernel/git/torvalds/linux
| I thought it would be faster to download from google rather than github —less traffic, maybe? Who knows? :p
-
Copy the source code (optional, to avoid re-downloading if something is misconfigured badly).
mv linux linux-base cp -r linux-base linux cd linux -
Uncomment the
deb-srclines and update package lists.vim /etc/apt/sources.list sudo apt update
On Ubuntu, edit
/etc/apt/sources.list.d/ubuntu.sourcesinstead:vim /etc/apt/sources.list.d/ubuntu.sources
-
Enable source repositories (if missing).
vi /etc/apt/sources.list.d/ubuntu.sources
Add the following if it's missing:
Types: deb deb-src URIs: http://archive.ubuntu.com/ubuntu Suites: noble noble-updates noble-security Components: main restricted universe multiverseUpdate package lists and install kernel build deps:
sudo apt update sudo apt build-dep linux
-
Install additional deps.
sudo apt install libncurses-dev gawk flex bison openssl libssl-dev dkms libelf-dev libudev-dev libpci-dev libiberty-dev autoconf llvm
-
Use the current kernel's configuration as a starting point.
cat /boot/config-$(uname -r) > .config
-
Configure the kernel using
menuconfig.make menuconfig
- Navigate to General setup →
- Select to save the configuration.
- Select .
Remove Debian-specific configurations:
-
Go to Cryptographic API → Certificates for signature checking.
-
Remove
debian/canonical-certs.pemfrom:(debian/canonical-certs.pem) Additional X.509 keys for default system keyringChange it to:
() Additional X.509 keys for default system keyring -
Remove
debian/canonical-revoked-certs.pemfrom:(debian/canonical-revoked-certs.pem) X.509 certificates to be preloaded into the system blacklist keyringChange it to:
() X.509 certificates to be preloaded into the system blacklist keyring -
Save and Exit.
-
Build the kernel.
make -j$(nproc)-j$(nproc): Uses all CPU cores for faster compilation.
Install stripped kernel modules:
sudo make INSTALL_MOD_STRIP=1 modules_install
-
Buildroot (optional)
- Create 'ext2' image with buildroot.
-
Run the kernel in VM.
qemu-system-x86_64 -kernel linux/arch/x86/boot/bzImage -drive file=buildroot/output/images/rootfs.ext2,format=raw -append "root=/dev/sda console=ttyS0" -nographic -no-reboot