Skip to content

Instantly share code, notes, and snippets.

@MakiseKurisu
Last active March 8, 2020 00:22
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 MakiseKurisu/543d0bc3a347e00c1afdaeb5d3319d5a to your computer and use it in GitHub Desktop.
Save MakiseKurisu/543d0bc3a347e00c1afdaeb5d3319d5a to your computer and use it in GitHub Desktop.
Install Arch Linux ARM to ESPRESSObin with custom storage layout
# Please refer to https://github.com/archlinuxarm/PKGBUILDs/pull/1768 for details
# We will set up a SD card install with an EXT4 boot partition and a Btrfs root partition
# Upgrade system and install Btrfs user land utilities
sudo pacman -Syu btrfs-progs --needed --noconfirm
# Prepare necessary files
mkdir root
wget http://os.archlinuxarm.org/os/ArchLinuxARM-espressobin-latest.tar.gz
# Enter root mode
sudo su
# Set up partition table and file systems
dd if=/dev/zero of=/dev/mmcblk0 bs=1M count=8
(echo o; echo n; echo ''; echo ''; echo ''; echo '+512M'; echo n; echo ''; echo ''; echo ''; echo ''; echo w) | fdisk /dev/mmcblk0
mkfs.ext4 -O ^metadata_csum,^64bit /dev/mmcblk0p1
mkfs.btrfs -f /dev/mmcblk0p2
# Mount partitions
mount /dev/mmcblk0p2 root
mkdir root/boot
mount /dev/mmcblk0p1 root/boot
# Install ALARM
bsdtar -xpf ArchLinuxARM-espressobin-latest.tar.gz -C root
# Install updated boot script if PR #1768 is not merged
# You also need to update U-Boot from console: mmc dev 0; ext4load mmc 0:1 $loadaddr /uEnv_multi.txt; env import -t $loadaddr $filesize; saveenv; reset
# Reload /boot/uEnv.txt from USB: usb start; ext4load usb 0:1 $loadaddr /boot/uEnv.txt; env import -t $loadaddr $filesize; saveenv; reset
wget https://raw.githubusercontent.com/MakiseKurisu/PKGBUILDs/7ba37218cf9be3f441fce909540526712e7ee83b/alarm/uboot-espressobin/uEnv.txt -O root/boot/uEnv_multi.txt
sed -i "s/\/boot\//\//g" root/boot/uEnv_multi.txt
sed -i "s/uEnv.txt/uEnv_multi.txt/g" root/boot/uEnv_multi.txt
sed -i "s/mmcblk0p1/mmcblk0p2/g" root/boot/uEnv_multi.txt
# Also update USB/SATA boot in case we switch to another device
sed -i "s/sda1/sda2/g" root/boot/uEnv_multi.txt
# Set up fstab
echo "UUID=`blkid -s UUID -o value /dev/mmcblk0p2` / btrfs defaults 0 0" >> root/etc/fstab
echo "UUID=`blkid -s UUID -o value /dev/mmcblk0p1` /boot ext4 defaults 0 1" >> root/etc/fstab
# Optionally, you can chroot into this new environment to perform some system configuration
pacman -S arch-install-scripts --needed --noconfirm
# 2020-03-07 Newly installed system can't mount Btrfs root for some reason.
# I did a bunch of things in chroot (since I was already there might as well set up the system) but most likely it is an initramfs issue.
arch-chroot root pacman -S mkinitcpio --noconfirm
# Finish
umount root/boot
umount root
exit
sync
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment