My image: ubuntu 16.04 LTS (64-bit) Make sure the ubuntu ISO you download is for ARM 64-bit Here is the link.
qemu-img create -f qcow2 100G
sudo apt-get install qemu-system-arm qemu-efi
dd if=/dev/zero of=flash0.img bs=1M count=64
dd if=/usr/share/qemu-efi/QEMU_EFI.fd of=flash0.img conv=notrunc
dd if=/dev/zero of=flash1.img bs=1M count=64
export MYISO=<your iso>
export MYIMAGE=<your image>
qemu-system-aarch64 \
-M virt -m 1G -cpu cortex-a57 -smp 4 \
-global virtio-blk-device.scsi=off -device virtio-scsi-device,id=scsi -rtc driftfix=slew -nographic \
-drive file=$MYISO,id=cdrom,if=none,media=cdrom \
-pflash flash0.img \
-pflash flash1.img \
-drive if=none,file=$MYIMAGE,id=hd0 \
-device scsi-hd,drive=hd0 -device virtio-scsi-device \
-device scsi-cd,drive=cdrom \
-netdev user,id=net1,hostfwd=tcp::2220-:22 -device virtio-net-device,mac=52:54:00:00:02:12,netdev=net1
Basically, when I ran QEMU to install the image on disk, I was getting an error indicating that the install cannot locate the CD-ROM. turns out this was an ubuntu bug and has been fixed by installing the "debian-installer" package. BUG
After this I managed to install the image. It took really a long time for me to go through the install, so be patient.
- https://designprincipia.com/virtualize-uefi-on-arm-using-qemu/
- http://snapshots.linaro.org/components/kernel/leg-virt-tianocore-edk2-upstream/latest
Basically, remove the CD-ROM drive and device from the above command:
qemu-system-aarch64 \
-M virt -m 1G -cpu cortex-a57 -smp 4 \
-global virtio-blk-device.scsi=off -device virtio-scsi-device,id=scsi -rtc driftfix=slew -nographic \
-pflash flash0.img \
-pflash flash1.img \
-drive if=none,file=$MYIMAGE,id=hd0 \
-device scsi-hd,drive=hd0 -device virtio-scsi-device \
-netdev user,id=net1,hostfwd=tcp::2220-:22 -device virtio-net-device,mac=52:54:00:00:02:12,netdev=net1
Remember to setup your network when you first boot if you want to always keep having internet.
One solution is THIS - Also, dont forget to set permissions for that file:
sudo chmod 755 /etc/rc.local