Shinyspace

Edit

Convenience script for arch setup

2026-10-02

Arch isn't as hard to install as the memes might make it seem, but it still contains a bunch of steps that aren't just clicking obvious buttons. I don't install arch as often as i used to, so i also forget how exactly i did set it up. For this reason i'm making a personal script to help me set up my archlinux.

STATUS: script exists

this is now an actual script: arch-init-scripts (archiso-install.sh). notes below are the manual version of the same flow.

Starting point

Minimal requirement is a running Archiso live system conntected to the internet. Since i use my personal, customized archiso image (insert link to blog post here) i might rely on certain files being present from there.

Data gathering

Partitioning

Not sure if the script should do this, but if it should:

in my first attempt, the disk may be partitioned already. might update later if neeeded.

LUKS setup (encrypted root partition)

cryptsetup -v luksFormat /dev/"$ROOTPARTITION" cryptsetup open /dev/"$ROOTPARTITION" cryptroot

Note: this is the point where we should likely add a keyfile on any system that should be able to boot unattended (link other blogpost here)

Keyfile on USB stick

wipefs -a /dev/sdX fdisk /dev/sdX g n w mkfs.ext4 /dev/sdX1 mkdir tmpmount && mount /dev/sdX1 tmpmount tr -dc '[:alnum:]' </dev/urandom | head -c64 > tmpmount/keyfile chmod 600 tmpmount/keyfile

add it to the partition "keyslots": cryptsetup luksAddKey "$ROOTPARTITION" tmpmount/keyfile

then configure mkinitcpio so the initramfs uses it (follow archwiki at https://wiki.archlinux.org/title/Dm-crypt/Device_encryption#With_a_keyfile_stored_on_an_external_media)

TODO

Filesystems

Mounting

Note: we don't use /boot on our efi partition. using UKI for booting, we want ONLY the finished UKI image on the efi partition, anything in /boot is "trusted" input we use to build that UKI. /boot SHOULD be on our encrypted root partition in this case.

Pacstrap

pacstrap -K /mnt base linux linux-firmware "$CPU_UCODE" vim neovim openssh

Note: networking will be done by systemd-networkd and systemd-resolved, which should ship with systemd package. remember to enable the services.

[Match]
Name=en* eth*

[Network]
DHCP=yes

Fstab

genfstab -U /mnt >> /mnt/etc/fstab

Copy useful files - only if from proper archiso

cp /etc/locale.gen /mnt/etc/locale.gen cp /etc/locale.conf /mnt/etc/locale.conf cp /etc/vconsole.conf /mnt/etc/vconsole.conf

cp /etc/ssh/sshd_config /mnt/etc/ssh/sshd_config mkdir /mnt/root/.ssh chmod 700 /mnt/root/.ssh cp /root/.ssh/authorized_keys /mnt/root/.ssh

Chroot

arch-chroot /mnt

Swap file

mkswap -U clear --size 4G --file /swapfile echo "/swapfile none swap defaults 0 0" >> /etc/fstab

more setup

ln -sf /usr/share/zoneinfo/Europe/Zurich /etc/localtime hwclock --systohc locale-gen echo "$HOSTNAME" > /etc/hostname

enable services

systemctl enable systemd-timesyncd systemctl enable systemd-networkd systemctl enable systemd-resolved systemctl enable sshd

UKI

(specify in /etc/kernel/cmdline, mkinitcpio SHOULD automatically use that) rd.luks.name=UUID-of-LUKS-part=cryptroot rd.luks.key=UUID-of-LUKS-part=/keyfile:UUID=UUID-of-USB-stick-part root=/dev/mapper/cryptroot rw