Skip to content

Instantly share code, notes, and snippets.

@mdellavo
Last active December 16, 2021 01:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mdellavo/1f872c42eb9d325c4f2efbb0382e7923 to your computer and use it in GitHub Desktop.
Save mdellavo/1f872c42eb9d325c4f2efbb0382e7923 to your computer and use it in GitHub Desktop.
Prepare an ArchLinux Image for a Raspberry Pi

Overview

An alternative approach for installing Arch Linux on a raspberry pi:

See https://archlinuxarm.org/platforms/armv6/raspberry-pi

The approach is to prepare the image in the Linux VM. This image can later be written to the SD card.

# Prepare an empty image
dd if=/dev/zero of=arch-raspi-aarch64.img bs=1M count=8192

# Follow instructions above to partition image
fdisk arch-raspi-aarch64.img 

# Prepare loopback devices to the partitions of the image
kpartx -a -v arch-raspi-aarch64.img 

# Example Output
add map loop0p1 (252:0): 0 409600 linear 7:0 2048
add map loop0p2 (252:1): 0 16365568 linear 7:0 411648

# Make filesystems 
mkfs.vfat /dev/mapper/loop0p1 
mkfs.ext4 /dev/mapper/loop0p2 

# Mount filesystems
mkdir -p mnt/root mnt/boot
mount /dev/mapper/loop0p1 mnt/boot/
mount /dev/mapper/loop0p2 mnt/root/

# Download and unpack
wget http://os.archlinuxarm.org/os/ArchLinuxARM-rpi-aarch64-latest.tar.gz 
cd mnt/root
tar zxvf ../../ArchLinuxARM-rpi-aarch64-latest.tar.gz 
cd ../..
mv mnt/root/boot/* mnt/boot
umount mnt/boot mnt/root

The image can now be copied from arch-raspi-arm64.img to the host and written to an SD card

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