Skip to content

yrougy/MicroDebian

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 

Repository files navigation

MicroDebian

Configuration to have a MicroVM on Debian on GNU/Linux

This project has mainly been done online, in French, on my Twitch Channel (Yorzian) and Youtube Channel (YvesRougyFR). We booted an even lighter kernel in around 200ms. The Debian image has been modified on my own time.

The Kernel

The kernel used is compiled from the kernel directory config file. No modules at all, and it's pretty minimal (I'm pretty sure we can do even better). I tested it from linux-6.10.3 but it can be adapted to the current kernel.

The image disk

[WIP]

I've started from the Debian Cloud images, specifically the "nocloud" one on https://cloud.debian.org/images/cloud/bookworm The QCOW2 format is the one I've used, but it should work with the RAW one with minimal adaptations.

I've removed a few things to make it boot quickly. I need to document what target, timers and services I've removed from systemd

How to use

You need qemu installed, with the microvm architecture.

qemu-system-x86_64 -M microvm -enable-kvm -cpu host -m 512m -kernel ../linux-6.10.3/arch/x86/boot/bzImage  -append "earlyprintk=ttyS0 console=ttyS0 root=/dev/vda1 debug  ip=on" -nodefaults -no-user-config -nographic -serial mon:stdio -drive id=test,file=deb12.qcow2,format=qcow2,if=none -device virtio-blk-device,drive=test -netdev tap,id=tap0,ifname=tap0,script=no,downscript=no -device virtio-net-device,netdev=tap0 # ip=172.16.34.2:::255.255.255.0:micro1 #-netdev tap,id=tap0,script=no,downscript=no    -device virtio-net-device,netdev=tap0
  • -M microvm: The microvm architecture which is minimal hardware (no PCI bus, no ACPI power management for example)
  • -enable-kvm: Use of the KVM hypervisor from the Linux Kernel on the host machine
  • -kernel ../linux-6.10.3/arch/x86/boot/bzImage: This is the path to the kernel you've compiled from the configuration file
  • -append "earlyprintk=ttyS0 console=ttyS0 root=/dev/vda1 debug ip=on: The kernel parameters. debug can be safely removed. Remove also ip=on if you don't need network. You can also add init=/bin/sh to only boot the kernel and see how long it takes (less than a second hopefully)
  • -nodefaults: gives us the minimal hardware, and not the default one
  • -no-user-config: only the configuration from the command line is used, any configuration file from the user is discarded
  • -nographic: cli mode, no graphics
  • -serial mon:stdio: the output and the console is on the serial port. -serial stdio can be used and SIGINT (Ctrl-C) will hard stop the microvm
  • -drive id=test,file=deb12.qcow2,format=qcow2,if=none -device virtio-blk-device,drive=test: defines the drive we use. Replace deb12.qcow2 with the name of your qcow2 file from the cloud debian archive
  • -netdev tap,id=tap0,ifname=tap0,script=no,downscript=no -device virtio-net-device,netdev=tap0: defines the network device. Here, we connect to the tap0 interface from the host.

About

Configuration to have a MicroVM on Debian

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published