Installing Arch Linux ARM on M1 UTM (Terminal)
Prerequisites
- Have a Linux box somewhere (required for creating a rootfs image)
- Install UTM on your Mac
Prepare necessary files
Download the ARMv8 generic tar.gz
rootfs file from Arch Linux ARM to the Linux box.
Extract the archive and obtain /boot/Image
and /boot/initramfs-linux.img
files.
Create an ext4
filesystem on a file and transfer the rootfs to it:
fallocate -l 2G rootfs.img
mkfs.ext4 rootfs.img
sudo mount rootfs.img /mnt
sudo tar -xvf ArchLinuxARM-aarch64-latest.tar.gz -C /mnt
sudo umount /mnt
Then, transfer the three files to the Mac host (e.g. with scp
).
Create UTM VM
- Open UTM and create a new VM:
- Choose “Virtualize” and select “Linux”
- “Use Apple Virtualization” is optional
- Tick “Boot from kernel image”
- Select the
Image
file for “Linux kernel” - Select the
initramfs-linux.img
file for “Linux initial ramdisk” - Don’t select a Root FS image at this point, so that UTM can create the actual virtual hard disk for us
- For terminal output, type `console=hvc0” in the “Kernel arguments” field
- Set other parameters as desired
Further configuration
With the VM created, go to the settings window and click the last button on the left side labelled “New Drive”.
Select “Import” and then choose the rootfs.img
file we created earlier.
Install Arch Linux
- Start the VM: it would open two windows: the display window and the terminal window. The display window is not useful at this point, but don’t close it.
- Go to the terminal window. Booting likely already failed, and there will be a rescue shell. This is expected.
- The rootfs is likely
/dev/vdb
. Trymount /dev/vdb /new_root
If that works, enter
exit
so that the system will continue booting.
-
If that doesn’t work, list
ls /dev
and try some other block devices. It could be/dev/vda
or/dev/vdc
, etc. -
Now, we should be in the Arch Linux ARM live environment. The default passowrds are
root:root
andalarm:alarm
. - To prepare the Arch Linux ARM live environment for the installation guide, we need a few packages:
pacman-key --init pacman-key --populate archlinuxarm pacman -Sy arch-install-scripts pacman glibc
I also installed
btrfs-progs
because I wanted abtrfs
root. - Finally, follow the official Arch Linux installation guide.
In particular, I use
pacstrap -K /mnt archlinuxarm-keyring base linux linux-firmware btrfs-progs vim git sudo
linux
and linux-firmware
are actually unnecessary for the system itself,
and can be removed afterwards. It is only needed during installation for generating the initramfs for the new kernel.
Inside the chroot
- Add QEMU drivers to the initramfs by modifying
/etc/mkinitcpio.conf
:MODULES=(virtio virtio_blk virtio_pci virtio_net) BINARIES=(btrfs) # If btrfs is used
After finishing the installation guide, copy /mnt/boot/Image
and /mnt/boot/initramfs-linux.img
from the VM back to the host.
The live environment has sshd
enabled by default.
Before the first boot
It is necessary to copy or move Image
and initramfs-linux.img
to the UTM data directory at (normally) ~/Library/Containers/com.utmapp.UTM/Data/Documents/<NAME>.utm
on the host
because UTM makes a copy of the files we originally selected for the kernel and initramfs files.
Then, modify the kernel arguments:
console=hvc0 root=/dev/vda
Try starting the VM again. It should boot into the Arch Linux ARM system.
I use systemd-networkd
for networking, so I need to create /etc/systemd/network/enp0s1.network
with the following content:
[Match]
Name=enp0s1
[Network]
DHCP=yes
Then, enable the service:
systemctl enable --now systemd-networkd systemd-resolved
ln -sf /run/systemd/resolve/resolv.conf /etc/resolv.conf