# 系统镜像
curl -Lo alpine-virt-aarch64.iso https://mirrors.tuna.tsinghua.edu.cn/alpine/v3.17/releases/aarch64/alpine-virt-3.17.2-aarch64.iso
# aavmf
curl -Lo aavmf.apk https://mirrors.tuna.tsinghua.edu.cn/alpine/edge/community/aarch64/aavmf-0.0.202211-r0.apk
tar zxvf aavmf.apk --strip-components 2
ls AAVMF
# 准备系统盘
qemu-img create -f qcow2 alpine-aarch64.qcow2 20G
# ISO 启动安装
qemu-system-aarch64 \
-M virt,gic-version=3 \
-cpu cortex-a57 -m 512M \
-net nic -nic user,hostfwd=tcp::2222-:22 \
-drive if=pflash,format=raw,readonly=on,file="AAVMF/AAVMF_CODE.fd" \
-device ramfb -device usb-ehci -device usb-kbd -device usb-mouse \
-drive file=alpine-aarch64.qcow2 \
-cdrom alpine-virt-aarch64.iso
ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null root@127.0.0.1 -p 2222
# 安装好后确保能正常启动
qemu-system-aarch64 \
-M virt,gic-version=3 \
-cpu cortex-a57 -m 512M \
-net nic -nic user,hostfwd=tcp::2222-:22 \
-drive if=pflash,format=raw,readonly=on,file="AAVMF/AAVMF_CODE.fd" \
-device ramfb -device usb-ehci -device usb-kbd -device usb-mouse \
-drive file=alpine-aarch64.qcow2
# 150mb -> 60mb
# qemu-img convert -O qcow2 alpine-aarch64.qcow2 alpine-3.17-aarch64.qcow2 -c