Raja's Exocortex

Alpine Linux MicroVM

Setting up a micro VM using Alpine Linux - 1 vCPU, 256MB RAM, 256MB disk. This makes a great router VM with iptables for SNAT/DNAT and internal routing.

Alpine ISO Installer

For Proxmox the VIRTUAL variant of Alpine Linux is best as it provides a customized kernel suitable for running as a guest OS.

Download the Alpine Virtual ISO and upload it to the Proxmox ISO storage folder.

Proxmox VM Config for Alpine

root@mox:~# qm config 302
agent: 1
balloon: 0
boot: order=scsi0
cores: 1
cpu: host
machine: q35
memory: 256
meta: creation-qemu=8.1.5,ctime=1707760194
name: igw-alpine-base
net0: virtio=BC:24:11:E2:76:6C,bridge=vmbr0,firewall=1
numa: 0
ostype: l26
scsi0: local-zfs:vm-302-disk-0,discard=on,iothread=1,size=268436K,ssd=1
scsihw: virtio-scsi-single
serial0: socket
smbios1: uuid=616b3695-4961-4bd2-bb92-76c775fee068
sockets: 1
tags: igw
vga: serial0
vmgenid: 7b7d5bf3-94f4-4b62-943e-a3c2e4cdfef5

Note: this config does not have the Alpine Linux Virtual installer ISO attached. This is the final setup of the VM after installation is completed.

Alpine Linux Installation

Boot the VM using the Alpine Linux virtual ISO image and connect to the serial terminal using qm terminal $VMID from the Proxmox SSH console.

Installing Alpine uses the sys disk partitioning method creates 3 partitions /boot, swap, / with generous sizes for /boot and swap. For small 256MB disks, we can reduce /boot to 64MB and disable swap by setting the below environment variables before starting the installer. The other installation steps need not be changed.

# See https://wiki.alpinelinux.org/wiki/Alpine_setup_scripts#setup-disk

export BOOT_SIZE=64   # Set /boot to 64MB
export SWAP_SIZE=0    # Disable swap

setup-alpine

Post First Boot

Install qemu-guest-agent and iptables.

apk add --no-cache qemu-guest-agent iptables
/etc/init.d/qemu-guest-agent start

# start qemu-guest-agent on boot
rc-update add qemu-guest-agent