Skip to content

Instantly share code, notes, and snippets.

@pojntfx
Last active May 1, 2021 12:19
Show Gist options
  • Save pojntfx/6d81b9ebe8b801e024d81fa9f3f3a4b2 to your computer and use it in GitHub Desktop.
Save pojntfx/6d81b9ebe8b801e024d81fa9f3f3a4b2 to your computer and use it in GitHub Desktop.
Pet Alpine Linux in QEMU

Also see https://gist.github.com/pojntfx/9ed00ff118fc1894abc83061491c252f for a cattle Alpine Linux in QEMU

On macOS? See https://gist.github.com/pojntfx/c41e9daed0a087a11eb83e786a15b199

Download

curl -o ~/Downloads/alpine.iso https://dl-cdn.alpinelinux.org/alpine/v3.13/releases/x86_64/alpine-virt-3.13.0-x86_64.iso

Installation

mkdir -p ~/Pets/Alpine
qemu-img create -f qcow2 ~/Pets/Alpine/alpine.qcow2 20G
qemu-system-x86_64 -accel hvf -m 4096 -smp $(sysctl -n hw.ncpu) -boot d -cdrom ~/Downloads/alpine.iso -drive format=qcow2,file=$HOME/Pets/Alpine/alpine.qcow2

Startup (with SSH access on localhost:10022)

qemu-system-x86_64 -accel hvf -m 4096 -smp $(sysctl -n hw.ncpu) -drive format=qcow2,file=$HOME/Pets/Alpine/alpine.qcow2 -nic user,hostfwd=tcp::10022-:22
  • To disable the GUI, append -nographic.
  • To pass through a USB device, append -device nec-usb-xhci -device usb-host,vendorid=0x18d1,productid=0xd00d. On macOS, you can find vendorid and productid in About This Mac/System Report/Hardware/USB.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment