Skip to content

Instantly share code, notes, and snippets.

@Sam0230
Last active June 8, 2024 06:46
Show Gist options
  • Save Sam0230/57673468b3b9f5050c7f051227f0920a to your computer and use it in GitHub Desktop.
Save Sam0230/57673468b3b9f5050c7f051227f0920a to your computer and use it in GitHub Desktop.
Installing Arch Linux ARM in a UTM virtual machine

Installing Arch Linux ARM in a UTM virtual machine

Steps:

  1. Create a new virtual machine.
  2. Go to System tab, change architecture to `ARM64 (aarch64)' and increase memory as needed.
  3. Download Alpine Linux LiveCD:
mirror=https://dl-cdn.alpinelinux.org/alpine
curl -o alpine-virt-latest-aarch64.iso "$mirror/latest-stable/releases/aarch64/$(curl "$mirror/latest-stable/releases/aarch64/latest-releases.yaml" | /usr/bin/grep -E 'file: alpine-virt-[0-9\.]+-aarch64\.iso' | head -n 1 | sed 's/ //g' | sed 's/\t//g' | sed 's/^file://')"
  1. Go to Drives tab, New Drive, set size to 20GiB or larger, then Inport Drive, choose the file you just downloaded.
  2. Go to Display tab, change Type to Console Only to enable pasting.
  3. Save the settings.
  4. Start the VM.
  5. Login as root.
  6. setup-alpine

Leave all fileds empty (including password) until selecting a mirror. You might want to use a mirror, and then select `none' for ssh server and everything left.

  1. Paste these commands:
alpineMirror=ALPIN_MIRROR
archlinuxARMMirror=ARCH_ARM_MIRROR
hostname=YOUR_HOSTNAME
username=YOUR_USER_NAME

echo "$alpineMirror"'/edge/main
'"$alpineMirror"'/edge/community' >/etc/apk/repositories
apk add arch-install-scripts pacman-makepkg gptfdisk btrfs-progs
mkdir /etc/pacman.d
cat >/etc/pacman.conf <<END
[options]
HoldPkg = pacman glibc
SigLevel = Required DatabaseOptional
Architecture = aarch64
Color
CheckSpace
ParallelDownloads = 8
LocalFileSigLevel = Optional
[core]
Include = /etc/pacman.d/mirrorlist
[extra]
Include = /etc/pacman.d/mirrorlist
[community]
Include = /etc/pacman.d/mirrorlist
[alarm]
Include = /etc/pacman.d/mirrorlist
[aur]
Include = /etc/pacman.d/mirrorlist
END
echo 'Server = '"$archlinuxARMMirror"'/$arch/$repo' >/etc/pacman.d/mirrorlist
mkdir /tmp/pacmaninit
cd /tmp/pacmaninit
pacman -Sydd pacman-mirrorlist archlinuxarm-keyring --noconfirm
rm /var/cache/pacman/pkg/*.sig
tar -xf /var/cache/pacman/pkg/pacman-mirrorlist-*.pkg.tar.*
tar -xf /var/cache/pacman/pkg/archlinuxarm-keyring-*.pkg.tar.*
cat etc/pacman.d/mirrorlist >>/etc/pacman.d/mirrorlist
mkdir /usr/share/pacman/keyrings
cp usr/share/pacman/keyrings/archlinuxarm.gpg /usr/share/pacman/keyrings/
echo '02922214DE8981D14DC2ACABBC704E86B823CD25:4:' >>/usr/share/pacman/keyrings/archlinuxarm-trusted
echo '9D22B7BB678DC056B1F7723CB55C5315DCD9EE1A:4:' >>/usr/share/pacman/keyrings/archlinuxarm-trusted
echo '69DD6C8FD314223E14362848BF7EEF7A9C6B5765:4:' >>/usr/share/pacman/keyrings/archlinuxarm-trusted
touch /usr/share/pacman/keyrings/archlinuxarm-revoked
pacman-key --init
pacman-key --populate archlinuxarm
pacman -Sdd archlinuxarm-keyring --noconfirm --overwrite '*'
pacman-key --init
pacman-key --populate archlinuxarm
echo -e 'n\n\n\n+1G\nef00\np\nn\n\n\n\n8300\nw\ny\n' | gdisk /dev/vda
mkfs.vfat /dev/vda1
mkfs.btrfs /dev/vda2
mount -t btrfs /dev/vda2 /mnt
mkdir -p /mnt/boot/efi
mount -t vfat /dev/vda1 /mnt/boot/efi
pacstrap /mnt base linux linux-firmware grub btrfs-progs sudo dhcpcd busybox
if [ ! -e /mnt/boot/Image ]; then
	ln -s Image /mnt/boot/vmlinuz-linux
fi
genfstab -U /mnt >> /mnt/etc/fstab
cat >/mnt/.__init <<END
grub-install --removable
grub-mkconfig -o /boot/grub/grub.cfg
echo "\$hostname" >> /etc/hostname
echo -e "127.0.0.1\tlocalhost" >> /etc/hosts
echo -e "::1\t\t\tlocalhost" >> /etc/hosts
echo -e "127.0.0.1\t\$hostname" >> /etc/hosts
chmod +w /etc/sudoers
echo 'Defaults env_reset' >>/etc/sudoers
sed -i 's|# Defaults secure_path="|Defaults secure_path="/usr/local/sbin:/usr/local/bin:/usr/bin"\n# Defaults secure_path="|' /etc/sudoers
sed -i 's/# \%sudo\tALL/\%sudo\tALL/' /etc/sudoers
chmod -w /etc/sudoers
sed -i 's/proc:x:26:/proc:x:26:\nsudo:x:27:'"\$username"'/' /etc/group
useradd "\$username" -m -U
passwd -d "\$username"
systemctl enable dhcpcd
systemctl set-default multi-user.target
END
export username hostname
arch-chroot /mnt bash /.__init
rm /mnt/.__init
  1. chroot /mnt /bin/passwd "$username" to change your passwd.
  2. poweroff
  3. Open VM settings panel, switch to Display tab, change display type back to full graphics and chang scaling algorithm to nearst neighbor.
  4. Go to Drivers and remove Alpine Linux LiveCD.
  5. Save config, power on and install a graphic user interface.
@adocampo
Copy link

I've used archboot, and it installs pretty straight forward. But when I'm in plasma, I couldn't see the fonts properly. To fix it, I had to change the M1 resolution to 1800x1169 and inside plasma, change it as well to 1920x1080.

@peggy-48
Copy link

peggy-48 commented Jun 8, 2024

👎 Really a bad option. Guys if you want Arch Linux on ARM go install the true ALARM from the website. This is a fake Arch (a disguised Alpine actually.).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment