Skip to content

Instantly share code, notes, and snippets.

@flyingluscas
Forked from yogaxpto/alarm-usb-config.md
Created September 10, 2021 10:40
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 flyingluscas/dd2c881a9b86f0108612c8f7a53424e9 to your computer and use it in GitHub Desktop.
Save flyingluscas/dd2c881a9b86f0108612c8f7a53424e9 to your computer and use it in GitHub Desktop.
Arch Linux ARM USB Boot on Raspberry Pi 4

Arch Linux ARM USB Boot on Raspberry Pi 4B

Index

  1. Requirements
  2. Flash latest EEPROM
  3. Change Raspberry Boot Order
  4. Install Arch Linux on USB device
  5. Update USB Boot Partitions
  6. Final Configurations
  7. Resources

Requirements

  • Raspberry Pi 4B
  • SD card with RaspbianOS
  • USB device intended to use as boot device

Flash latest EEPROM

After booting the raspberry with the sd card, update the system:

sudo apt update
sudo apt full-upgrade

Then we can update the latest firmware:

sudo rpi-eeprom-update -a

Restart to apply the changes.

Change Raspberry Boot Order

After the first reboot run:

sudo raspi-config

Then choose Advanced Options -> Boot Order -> USB Boot.

Restart to apply the changes.

Install Arch Linux on USB device

After the second reboot, follow the following instructions to install Arch Linux according to the Arch Linux Documentation:
https://archlinuxarm.org/platforms/armv8/broadcom/raspberry-pi-4

Replace sdX in the following instructions with the device name for the USB device as it appears on your computer.

Start fdisk to partition the SD card:

fdisk /dev/sdX

At the fdisk prompt, delete old partitions and create a new one:

  1. Type o. This will clear out any partitions on the drive.
  2. Type p to list partitions. There should be no partitions left.
  3. Type n, then p for primary, 1 for the first partition on the drive, press ENTER to accept the default first sector, then type +200M for the last sector.
  4. Type t, then c to set the first partition to type W95 FAT32 (LBA).
  5. Type n, then p for primary, 2 for the second partition on the drive, and then press ENTER twice to accept the default first and last sector.
  6. Write the partition table and exit by typing w.

Create and mount the FAT filesystem:

mkfs.vfat /dev/sdX1
mkdir boot
mount /dev/sdX1 boot

Create and mount the ext4 filesystem:

mkfs.ext4 /dev/sdX2
mkdir root
mount /dev/sdX2 root

Download and extract the root filesystem (as root, not via sudo):

wget http://os.archlinuxarm.org/os/ArchLinuxARM-rpi-4-latest.tar.gz
bsdtar -xpf ArchLinuxARM-rpi-4-latest.tar.gz -C root
sync

Move boot files to the first partition:

mv root/boot/* boot

Update USB Boot Partitions

fstab

First, adjust the fstab of the new system by replacing the defined system with the USB system:

sudo vim root/etc/fstab

Change the device /dev/mmcblk1p1 to your boot device /dev/sdX1.

cmdline.txt

Then we need to set the new root device to be used:

sudo vim boot/cmdline.txt

Set the root parameter to your root device /dev/sdX2.

Unmount the two partitions:

umount boot root

You can now boot from the newly created USB device without the need for the SD card

Final Configurations

Connect the USB device into the Raspberry Pi, connect ethernet, and apply 5V power. Use the serial console or SSH to the IP address given to the board by your router. Login as the default user alarm with the password alarm. The default root password is root.

Initialize the pacman keyring and populate the Arch Linux ARM package signing keys:

pacman-key --init
pacman-key --populate archlinuxarm

Resources

  1. How To Set Up a Raspberry Pi 4 with Archlinux 64-bit (AArch64) and Full Disk Encryption (+SSH unlock), USB Boot (No SD-Card) and btrfs: https://gist.github.com/XSystem252/d274cd0af836a72ff42d590d59647928
  2. Setting up a SSH Server: https://www.raspberrypi.org/documentation/computers/remote-access.html#setting-up-a-ssh-server
@phiresky
Copy link

phiresky commented Feb 3, 2023

cmdline.txt doesn't have to be edited, it by default takes the root partition from the same device the boot partition is on. The only thing I had to change from the original instructions from https://archlinuxarm.org/platforms/armv8/broadcom/raspberry-pi-4 was rootfs/etc/fstab, which I set to

UUID=XXXX-XXXX  /boot   vfat    defaults        0       0

(the uuid from lsblk -f) in order to make it still work if i plug another HDD in.

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