Instructions for Ubuntu 20.04LTS and QEMU installed from APT Based on Alpine Wiki
Install syslinux
sudo apt-get install syslinux -y
Make an empty disk image
sudo dd if=/dev/zero of=./alpine_rpi.img bs=1M count=512
Attach image as a loop device
sudo losetup -P -f ./alpine_rpi.img
Find the created loop device id
sudo fdisk -l
/dev/loopX
will have to be replaced by the proper loop device id (/dev/loop0
in my case) in the next steps
Make a primary FAT32 parition on the device
sudo fdisk -w always /dev/loopX <<EOF
o
n
p
1
2048
-0
t
0c
a
w
EOF
Format the newly created partition
sudo mkdosfs -F32 /dev/loopXp1
Copy Linux MBR to the device
sudo dd bs=440 count=1 conv=notrunc if=/usr/lib/syslinux/mbr/mbr.bin of=/dev/loopX
Install syslinux on device
sudo syslinux /dev/loopXp1
Mount the device to the host
sudo mkdir /media/alpine_rpi && sudo mount /dev/loopXp1 /media/alpine_rpi
Download Alpine archive:
wget https://dl-cdn.alpinelinux.org/alpine/v3.17/releases/aarch64/alpine-rpi-3.17.2-aarch64.tar.gz
Untar the archive into the mounted image
sudo tar -p -s --atime-preserve --same-owner --one-top-level=/media/alpine_rpi -zxvf ./alpine-rpi-3.17.2-aarch64.tar.gz
Launch the emulator
sudo qemu-system-aarch64 \
-nographic \
-machine raspi3b \
-cpu cortex-a53 \
-drive file=./alpine_rpi.img,format=raw,readonly=off \
-dtb /media/alpine_rpi/bcm2710-rpi-3-b.dtb \
-m 1G \
-smp 4 \
-device usb-net,netdev=net0 \
-netdev user,id=net0 \
-kernel /media/alpine_rpi/boot/vmlinuz-rpi \
-initrd /media/alpine_rpi/boot/initramfs-rpi \
-append "modules=loop,squashfs,sd-mod,usb-storage quiet console=ttyAMA0 modloop=/boot/modloop-rpi"
That's it !