-   Terms of Use and Privacy
Apps | GNU/Linux | IT Prepper | Meta
  -   Terms of Use and Privacy
Apps | GNU/Linux | IT Prepper | Meta

<<   <   >   >>

2021-08-14 | GNU/Linux | Bring up an Aarch64 VM in QEMU on Apple Silicon

Would you like to boot a minimal GNU/Linux OS with QEMU on your Mac M1 system? Well, this is how. Grab a copy of pilfs-base-aarch64-r10.1-76.img.xz. Verify the MD5 hash is fcf784a090b8c9d2d8899b7e18516a2e.

Mount the image on a GNU/Linux system:

root [ /home/divine/art ]# ls
root [ /home/divine/art ]# losetup -f
root [ /home/divine/art ]# losetup -P /dev/loop0 pilfs-base-aarch64-r10.1-76.img
root [ /home/divine/art ]# ls /dev/loop*
/dev/loop0    /dev/loop1  /dev/loop4  /dev/loop7
/dev/loop0p1  /dev/loop2  /dev/loop5  /dev/loop-control
/dev/loop0p2  /dev/loop3  /dev/loop6
root [ /home/divine/art ]# mount /dev/loop0p2 /mnt
root [ /home/divine/art ]# cd /mnt
root [ /mnt ]# ls
bin   dev  home  lost+found  mnt  proc  run   srv  tmp  var
boot  etc  lib   media       opt  root  sbin  sys  usr
root [ /mnt ]# cd etc

Edit fstab and unmount the image:

root [ /mnt/etc ]# vi fstab
root [ ~ ]# losetup -d /dev/loop0

Fstab should look like this:

# Begin /etc/fstab

# file system  mount-point  type     options                     dump  fsck
#                                                                      order

/dev/vda2  /            ext4     defaults,noatime,nodiratime 0     2
#/swapfile     swap         swap     pri=1                       0     0
proc           /proc        proc     nosuid,noexec,nodev         0     0
sysfs          /sys         sysfs    nosuid,noexec,nodev         0     0
devpts         /dev/pts     devpts   gid=5,mode=620              0     0
tmpfs          /run         tmpfs    defaults                    0     0
devtmpfs       /dev         devtmpfs mode=0755,nosuid            0     0

# End /etc/fstab

Start the vm with something like this:

/usr/local/bin/qemu-system-aarch64 \
  -kernel vmlinuz \
  -device e1000e,netdev=netwk \
  -netdev user,id=netwk,hostfwd=tcp::5252-:22 \
  -M virt,highmem=off \
  -accel hvf \
  -cpu cortex-a72 \
  -append "root=/dev/vda2" \
  -smp 4 \
  -m 4096 \
  -device virtio-gpu-pci \
  -device qemu-xhci \
  -device usb-kbd \
  -device usb-tablet \
  -device intel-hda \
  -device hda-duplex \
  -serial stdio \
  -drive file=pilfs-base-aarch64-r10.1-76.img

Create vmlinuz from above with this .config file. If you are unfamiliar, you'll need to download the 5.13.10 linux kernel from, extract it, put the .config in the root of the extracted tree, run make oldconfig, then make. You can this copy Image.gz to vmlinuz and boot with the above command. Here is what the booted systems looks like:

To get the network to work, you need to edit ifconfig.eth0 as in the above screenshot.

qemu lfs arm64 aarch64 m1

Articles tagged with qemu on L1G3R Information Systems:


Articles tagged with qemu on O.R.N.G.:

2009-06-28: An Innocent Computer Move - Sunday