Last active
October 25, 2025 02:36
-
-
Save johnramsden/2128a1a8a9b100537f17b4cbb26070cb to your computer and use it in GitHub Desktop.
Install scripts for installing Arch Linux on ZFS. Not runnable, just listed commands.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # Check before running, may need intervention | |
| # Replace the following: | |
| BOOT_PARTITION="/dev/sdg1" | |
| DISK_1="ata-SanDisk_SDSSDXPS480G_152271401093" | |
| DISK_2="ata-SanDisk_SDSSDXPS480G_154501401266" | |
| # Replace with poolname. I use 'vault' here | |
| POOL="vault" | |
| # Check for zfs | |
| modprobe zfs | |
| # Create pool | |
| zpool create -f -o ashift=12 ${POOL} mirror ${DISK_1} ${DISK_2} | |
| ## Properties | |
| # Compression | |
| zfs set compression=on ${POOL} | |
| # Access time | |
| zfs set atime=on ${POOL} | |
| zfs set relatime=on ${POOL} | |
| # Create key datasets | |
| zfs create -o mountpoint=none "${POOL}/ROOT" | |
| zfs create -o mountpoint=legacy "${POOL}/ROOT/default" | |
| zfs create -o mountpoint=/home "${POOL}/home" | |
| ## Optional datasets ## | |
| # tmp | |
| zfs create "${POOL}/tmp" \ | |
| -o setuid=off \ | |
| -o devices=off \ | |
| -o sync=disabled \ | |
| -o mountpoint=/tmp | |
| # Mask systemd’s automatic tmpfs-backed tmp | |
| systemctl mask tmp.mount | |
| # var | |
| zfs create "${POOL}/var" \ | |
| -o xattr=sa \ | |
| -o mountpoint=legacy | |
| # usr | |
| zfs create "${POOL}/usr" -o mountpoint=legacy | |
| ## End Optional | |
| # Unmount pool | |
| zfs umount -a | |
| # Put them in /etc/fstab | |
| nano /etc/fstab | |
| # <pass><file system> <dir> <type> <options> <dump> | |
| # vault/ROOT/default / zfs rw,relatime,xattr,noacl 0 0 | |
| # vault/var /var zfs rw,relatime,xattr,noacl 0 0 | |
| # vault/usr /usr zfs rw,relatime,xattr,noacl 0 0 | |
| # set boot property | |
| zpool set bootfs="${POOL}/ROOT/default" ${POOL} | |
| ## Setup Installation ## | |
| # Export the pool | |
| zpool export ${POOL} | |
| # re-import the pool, | |
| zpool import -d /dev/disk/by-id -R /mnt ${POOL} | |
| # bring the zpool.cache file into your new system | |
| mkdir -p /mnt/etc/zfs | |
| cp /etc/zfs/zpool.cache /mnt/etc/zfs/zpool.cache | |
| # OR, if you do not have /etc/zfs/zpool.cache, create it: | |
| # zpool set cachefile=/etc/zfs/zpool.cache zroot | |
| # Mount legacy zfs | |
| mkdir /mnt/{home,var,usr,tmp,boot} | |
| mount -t zfs "${POOL}/home" "/mnt/home" | |
| mount -t zfs "${POOL}/var" "/mnt/var" | |
| mount -t zfs "${POOL}/usr" "/mnt/usr" | |
| mount -t zfs "${POOL}/tmp" "/mnt/tmp" | |
| # Boot | |
| mkdir -p /boot | |
| mount "/dev/${BOOT_PARTITION}" /boot | |
| # Generate the fstab | |
| genfstab -U -p /mnt >> /mnt/etc/fstab | |
| # Comment out all non-legacy datasets apart from the root dataset, | |
| # the swap file and the boot/EFI partition | |
| nano /mnt/etc/fstab | |
| # Edit mirrorlist | |
| nano /etc/pacman.d/mirrorlist | |
| # Install the base system | |
| pacstrap -i /mnt base base-devel | |
| # Edit ramdisk hooks | |
| # If you are using a separate dataset for /usr, have the usr hook enabled after zfs | |
| # If using a separate dataset for /var, add shutdowm hook | |
| # HOOKS="base udev autodetect modconf block keyboard zfs usr filesystems shutdown" | |
| nano /mnt/etc/mkinitcpio.conf | |
| # Enter Chroot |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment