This guide shows how to boot an User-Mode Linux (UML) kernel with a Linux cloudimg using SLIRP for network connectivity.
Make sure you have in the same directory:
linux→ UML kernel binaryslirp→ static SLIRP binarydisk.img→ Any Linux cloudimg
Run the following command from the directory containing the files:
./linux \
mode=skas0 \
mem=2048M \
ubd0=disk.img \
root=/dev/ubda1 \
rw \
init=/lib/systemd/systemd \
eth0=slirp,,./slirp \
con0=fd:0,fd:1 \
con=nullmode=skas0→ required for SKAS0 mode for UMLmem=2048M→ allocate 2GB memory to the guestubd0=...→ the root filesystem imageroot=/dev/ubda1 rw→ use first partition (partition 1) of UML disk as root, read-write modeinit=/lib/systemd/systemd→ start systemd as initeth0=slirp,,./slirp→ connect guesteth0to SLIRP for networkcon0=fd:0,fd:1→ console attached to current terminalcon=null→ disable other consoles
Once inside the UML guest, configure the network to access the internet:
# Configure eth0 IP and bring it up
ip a add dev eth0 10.0.2.1
ip l set eth0 up
# Set default route
ip r add default dev eth0
# Configure DNS
echo "nameserver 10.0.2.3" > /etc/resolv.confAfter this, the guest should be able to access the internet via SLIRP.
For port forwarding, create a file named slirp_config in same folder and add forwarded port in format [guest_port]:[host_port] like this:
22:2222
80:8080
...
- You can use any Linux Cloud Image compatible with UML.
- Adjust
memparameter according to your host's available RAM. - SLIRP allows network access without needing root privileges.