Installing Arch ARM in a VM

Installing Arch ARM in a VM

yesterday at 11:40 PM

With the sunsetting of Windows 10 coming up soon and my desktop PC being unable to run it (due to the TPM requirements), I've decided I'm going to put Linux on it. But which one and which desktop environment?

The past few weeks I've gone on a bit of a deep dive downloading various Linux ISOs (yes, actual Linux ISOs not the ones the BitTorrent users call "Linux ISOs"), installing and testing them in a VM on my MacBook Pro and running various things to see what I'd settle on for my desktop (which is currently in storage for a couple of personal reasons).

Because I'm a tinkerer (and big nerd), I've settled on Arch (and not just because I'll be able to say BTW I use Arch), but testing out desktop environments started to get a little tricky due to the way that VM's don't really emulate GPU's very well. However, with the transition to the ARM architecture that Apple has done, they have provided a lot of abilities to make this quite a bit better.

My go to VM is UTM. It supports using both QEMU and Apple Virtualisation. In the past I've done plenty with QEMU but not much outside of that. My needs usually are pretty basic, no desktop environment, just a terminal which this is ideal for. But on this deep dive, I needed something more.

There are pros and cons of each, and I'm sure it goes a lot deeper than this, but it boils down to QEMU has better disk images (that only take up the amount of space that is used, not for the whole virtual drive), and a stable base. Apple Virtualisation is still marked as Experimental, however it has MUCH better GPU support and performance.

Setting up Arch on ARM was a little tricky as natively it only supports x86_64. However there is the Arch Linux Arm project which I'm sure has close ties to the Manjaro distribution (unfortunately Manjaro wouldn't work for me as much like Debian, their packages are quite old by design).

So pulling various bit of info from various wikis, along with different experiences throughout the years (I ran Gentoo for a while on a laptop back in the early 2000's), I've created a bit of a tutorial to get everything up and running.

  • For starters, if you don't already have it, you'll need to download and install UTM.
  • Create a new VM, Virtualize, Linux, tick Use Apple Virtualization
  • Use Fedora/Debian/Alpine for the image - anything with a Live CD rather than an install (I'll have a tutorial for Fedora - KDE Plasma here)
  • Memory - Whatever, I use 8Gb
  • Hard Disk at least 20Gb, I used 64Gb (remember, this takes up this amount of hard drive space on your computer)
  • Open VM Settings checkbox
  • Rename the VM, set Icon (gotta have that Arch icon so people know how awesome you are), etc
  • Move the base hard disk up to the top (this just makes sure that the drive you end up installing to stays at /dev/vda)
  • Start the VM
  • If using a desktop env, adjust your scaling as needed (I use 200% on a 16" MacBook and 175% on a 14" MacBook) - Right Click, display settings
    • Open a terminal (konsole)
  • Not usually recommended to run as the super user, but this makes the next stuff a whole lot easier rather than prefixing everything with sudo
    • sudo su
  • Partition your drive
    • fdisk /dev/vda
    • n for new partition
      • Primary (default)
      • Partition 1 (default)
      • Start 2048 (default)
      • Size +2G
    • t to change type
      • set to uefi
    • n for new partition
      • Primary (default)
      • Partition 2 (default)
      • Start 4196352 (default)
      • Size +8G
    • t to change type
      • Partition 2 (default)
      • set to swap
    • n for new partition
      • Go with defaults for all
    • w to write the partition table and exit
  • Format the partitions
    • Format the UEFI partition as Fat32 as that's what it needs
      • mkfs.fat -F 32 /dev/vda1
    • Set up the swap partition
      • mkswap /dev/vda2
    • Format the main partition as ext4 (this is standard on Linux - but feel free to use something else like btrfs)
      • mkfs.ext4 /dev/vda3
  • Mount the filesystems
    • The main system partition
      • mount /dev/vda3 /mnt
    • We mount our UEFI partition into /boot on our system when it's set up, so we do it here as it makes the file extraction below a lot easier)
      • mount --mkdir /dev/vda1 /mnt/boot
    • Enable the swap partition
      • swapon /dev/vda2
  • Install the arch install scripts (I've found most distros have these available)
    • yum install arch-install-scripts
    • Answer yes to both the questions
  • Download and install Arch Linux Arm
    • curl -OL http://os.archlinuxarm.org/os/ArchLinuxARM-aarch64-latest.tar.gz
  • Extract - we use bsdtar (which comes with the arch-install-scripts) as it does a better job maintaining file attributes and permissions
    • bsdtar -xpf ArchLinuxARM-aarch64-latest.tar.gz -C /mnt
  • Create your fstab file (this is what gets mounted automatically on boot)
    • genfstab -U /mnt >> /mnt/etc/fstab
    • Edit this file (with your editor of choice, vim/nano/etc) and remove the zram0 line (if you forget this, your system will hang for 90 seconds on startup, so if you're happy to wait, it can be done after our first reboot)
  • Chroot into your new system (you're almost running Arch at this point)
    • arch-chroot /mnt
  • Set up your time zone
    • ln -sf /usr/share/zoneinfo/_Region_/_City_ /etc/localtime
      • eg. ln -sf /usr/share/zoneinfo/Autralia/Melbourne /etc/localtime
    • hwclock --systohc
  • Set up localisation
    • locale-gen
    • edit (using vi or nano) /etc/locale.conf and set to LANG=en_US.UTF-8
  • Set up the hostname (optional - will be called alarm if you don't set it, which I believe stands for Arch Linux Arm)
    • edit /etc/hostname and set to whatever you like
  • Set the root password passwd
  • Set up the package manager keys
    • pacman-key --init
    • pacman-key --populate archlinuxarm
  • Update the package manager library with
    • pacman -Syu (this will take a while)
  • Install grub for your boot loader (I'm sure you can use something like systemd-boot but grub is what I'm comfortable with)
    • pacman -S grub efibootmgr
    • grub-install --target=arm64-efi --efi-directory=/boot --bootloader-id=GRUB
  • Set up your grub config file - if you forget this, you'll have to drop in to the grub command line and work out a tonne of stuff to boot it - doable, but annoying (ask me how I know!)
    • grub-mkconfig -o /boot/grub/grub.cfg
  • Create a user for yourself (or you could potentially just set the password on the alarm user if you prefer)
    • useradd -m _username_
    • passwd _username_
  • Add sudo
    • pacman -S sudo
  • Add the user to the wheel group which gives sudo access
    • usermod -aG _username_ wheel
    • visudo uncomment either of the wheel lines (near the bottom of the file) depending on if you want to have the security of typing your password when using sudo or not
  • Install the desktop environment (could be done after reboot, but your font would be tiny) usually a good idea to install something that just works without configuration as a fallback
    • pacman -S plasma sddm konsole (go with the defaults for everything)
    • if you run in to issues downloading, just run the command again
  • Enable sddm
    • systemctl enable sddm.service
  • Exit out of your chroot environment exit
  • Unmount your drives umount /mnt/boot && umount /mnt
  • Eject the Fedora drive (I just used the icon next to the network icon in the system tray)
  • Reboot
  • Additional tools you may wish to install
    • Yay to access the Arch User Repository
    sudo pacman -S --needed git base-devel
    git clone https://aur.archlinux.org/yay.git
    cd yay
    makepkg -si
    yay -Syu
    • Firefox yay -S firefox

And at this point, you have a working Arch install! Give yourself a pat on the back and flex your muscles in /r/linux. From here, you can go wild. Install my favourite terminal emulator (ghostty).

I was trying out Hyprland (which I think I'll run when I install on my proper machine), however on my M1 pro, it's quite laggy, even moving around in neovim was slow. My work M3 pro is better (running glxgears was about twice as fast on the M3 vs the M1), but still slow.