2020-09-14
install using netboot files
#!/bin/sh
# bios is taken from ovmf in edge repo
#wget http://dl-cdn.alpinelinux.org/alpine/v3.12/community/aarch64/ovmf-0.0.201908-r0.apk
#tar xf ovmf-0.0.201908-r0.apk usr/share/OVMF/QEMU_EFI.fd
#mv usr/share/OVMF/QEMU_EFI.fd .
#rm -rf usr/
TMPDIR="."
MIRROR=http://dl-cdn.alpinelinux.org/alpine
FLAVOR=lts
DISK=aarch64.vm.img
for file in vmlinuz initramfs; do
echo "Downloading $file"
[ ! -f $file-$FLAVOR ] && wget -P $TMPDIR "$MIRROR"/latest-stable/releases/aarch64/netboot/$file-$FLAVOR
done
[ ! -f $DISK ] && qemu-img create -f raw $DISK 2G
install_alpine() {
echo "Booting QEMU in EFI mode"
qemu-system-aarch64 \
-kernel $TMPDIR/vmlinuz-$FLAVOR \
-initrd $TMPDIR/initramfs-$FLAVOR \
-append "modloop=$MIRROR/latest-stable/releases/aarch64/netboot/modloop-$FLAVOR alpine_repo=$MIRROR/latest-stable/main" \
-machine virt -cpu cortex-a57 -machine accel=tcg \
-smp cores=$(nproc) \
-m 2G \
-nographic \
-nic user,model=virtio \
-drive format=raw,file=$DISK \
-device virtio-rng-pci \
-bios QEMU_EFI.fd \
-rtc base=utc,clock=host
}
install_alpine
install using iso image
#!/bin/sh
# bios is taken from ovmf in edge repo
#wget http://dl-cdn.alpinelinux.org/alpine/v3.12/community/aarch64/ovmf-0.0.201908-r0.apk
#tar xf ovmf-0.0.201908-r0.apk usr/share/OVMF/QEMU_EFI.fd
#mv usr/share/OVMF/QEMU_EFI.fd .
#rm -rf usr/
TMPDIR="."
DISK=aarch64.vm.img
cdromiso="alpine-virt-3.12.1-aarch64.iso"
[ ! -f $cdromiso ] && wget -P $TMPDIR "http://dl-cdn.alpinelinux.org/alpine/v3.12/releases/aarch64/$cdromiso"
[ ! -f $DISK ] && qemu-img create -f raw $DISK 2G
install_alpine() {
echo "Booting QEMU in EFI mode"
qemu-system-aarch64 \
-machine virt -cpu cortex-a57 -machine accel=tcg \
-smp cores=$(nproc) \
-m 2G \
-nic user,model=virtio \
-drive format=raw,file=$DISK \
-device virtio-rng-pci \
-bios QEMU_EFI.fd \
-rtc base=utc,clock=host \
-nographic \
-cdrom $cdromiso -boot d
}
install_alpine
when grub menu appears press e key and remove 'quiet' and 'console=tty' from kernel command line and press Ctrl-X to see kernel boot messages.
boot take some time, about 60-120 on intel I3 (4 cores) with 4GB RAM and on SSD
qemu-system-aarch64 -machine virt -cpu cortex-a57 -machine accel=tcg -smp cores=2 -m 2G -nic user,model=virtio -drive format=raw,file=aarch64.vm.img -device virtio-rng-pci -bios QEMU_EFI.fd -rtc base=utc,clock=host -nographic