- Requirements
- Flash latest EEPROM
- Change Raspberry Boot Order
- Install Arch Linux on USB device
- Final Configurations
- Resources
- Raspberry Pi 4B
- SD card with RaspbianOS
- USB device intended to use as boot device
After booting the raspberry with the sd card, update the system:
sudo apt update
sudo apt full-upgradeThen we can update the latest firmware:
sudo rpi-eeprom-update -aRestart to apply the changes.
After the first reboot run:
sudo raspi-configThen choose Advanced Options -> Boot Order -> USB Boot.
Restart to apply the changes.
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/sdXAt the fdisk prompt, delete old partitions and create a new one:
- Type
o. This will clear out any partitions on the drive. - Type
pto list partitions. There should be no partitions left. - Type
n, thenpfor primary,1for the first partition on the drive, pressENTERto accept the default first sector, then type+200Mfor the last sector. - Type
t, thencto set the first partition to typeW95 FAT32 (LBA). - Type
n, thenpfor primary,2for the second partition on the drive, and then pressENTERtwice to accept the default first and last sector. - Write the partition table and exit by typing
w.
Note: This step is not necessary for most USB devices. Use this if your device has more than 2TB of capacity and you need to have a partition with more than 2TB of space.
At the gdisk prompt, enter recovery mode to create hybrid MBR:
- Type
rto use recovery options. - Type
hto make hybrid MBR. - Type
1to select the first partition. - Type
nto not format the first partition to EFI. - Type
nto not set bootable flag. - Type
nto not protect any other partition. - Type
wto write changes. - Type
yto confirm changes and exit.
At the gdisk prompt, recreate the second partition:
- Type
dto delete a partition. - Type
2to select the second parition. - Type
nto add a new partition. - Type
ENTERto select the default partition number. - Type
ENTERto select the default first sector. - Type
ENTERto select the default last sector. - Type
ENTERto select the default partition type (Linux Filesystem). - Type
wto write changes. - Type
yto confirm changes and exit.
Create and mount the FAT filesystem:
mkfs.vfat /dev/sdX1
mkdir boot
mount /dev/sdX1 bootCreate and mount the ext4 filesystem:
mkfs.ext4 /dev/sdX2
mkdir root
mount /dev/sdX2 rootDownload 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
syncMove boot files to the first partition:
mv root/boot/* bootFirst, adjust the fstab of the new system by replacing the defined system with the USB system:
sudo vim root/etc/fstabChange the device /dev/mmcblk1p1 to your boot device /dev/sdX1.
Then we need to set the new root device to be used:
sudo vim boot/cmdline.txtSet the root parameter to your root device /dev/sdX2.
Unmount the two partitions:
umount boot rootYou can now boot from the newly created USB device without the need for the SD card
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- 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
- Setting up a SSH Server: https://www.raspberrypi.org/documentation/computers/remote-access.html#setting-up-a-ssh-server
- Running Raspbian from USB Devices : Made Easy https://www.raspberrypi.org/forums/viewtopic.php?f=29&t=196778
@dza89
I can confirm that the problem has occurred to me once. To mitigate it, I've created a backup file in case I need to recreate the file.
I've also set up
ausearchto listen for any changes in thecmdline.txtfile, but I haven't found the culprit as it only happened once to me, yet.I would advice you to use the same strategy for now.