TL;DR This article just demonstrate how to live boot alpine linux with QEMU and doesn't guide you how to install it with QEMU.
Why I'm doing this?
Sometimes I want to mess around with Linux to test something, and QEMU will definitely come in handy for this purpose.
It depends on what you need on the linux system, just playing with kernel? maybe busybox+kernel or OneFileLinux is sufficient, need a package manager? maybe minimalist distribution like arch linux or alpine linux will fulfill the needs.
Alpine linux
In this article, we will use alpine linux as an example to live boot linux system.
qemu-system-x86_64 -cdrom ./alpine-standard-3.20.2-x86_64.iso -m 128 -nographic -enable-kvm
setup network:
echo "auto eth0
iface eth0 inet dhcp" > /etc/network/interfaces
rc-service networking start
or you can just setup the whole thing by exec: setup-alpine
.
after setup some stuff, you might want to install bash
, bash-completion
and curl
, since the live boot environment only provide busybox utility as default program (which use ash
shell by default).
Bonus
alpine linux installer program is pretty convenient, it's like Windows installer where you can press next button multiple times until you've finished :P
you just need to prepare a virtual disk:
qemu-img -f qcow2 alpine_linux.qcow2 10G
and after installation, you can boot it:
qemu-system-x86_64 \
-drive file=./alpine.qcow2,media=disk,if=virtio \
-m 1024 \
-cpu host \
-enable-kvm \
-nographic
Alternative
I've heard about docker and it gives me a weird impression with an idea of one process per container.
TODO: discuss how to build simplest and naive linux system from scratch
What next?
I will leave what to do with the rest of system up to you, happy hacking! ^^
unrelated note:
if you trying to setup live boot linux system on virt-manager and libvirt, good luck dealing with dns resolve problem ^^
also see:
- minimum requirement for alpine linux - wiki.alpinelinux.org
- OpenRC - wiki.alpinelinux.org
- Configure Networking - wiki.alpinelinux.org
- What is the difference between
ash
andsh
shell on Linux? - unix.stackexchange.com