Last active
May 27, 2024 23:52
-
-
Save Matthewacon/82c2c9cf797ff49528576bef36e0ae28 to your computer and use it in GitHub Desktop.
Arch install with ZFS root on LUKS and EFISTUB
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
# Create your partition layout (using GPT) | |
# 1 - ESP (FAT32, 128M) | |
# 2 - Linux (luks, any size) | |
# Format your partitions | |
mkfs.fat -F32 /dev/sdx1 | |
cryptsetup luksFormat --key-size 512 --cipher aes-xts-plain64 /dev/sdx2 | |
# Open your luks partition | |
cryptsetup open /dev/sdx2 luks_root | |
# Make sure ZFS is loaded before continuing | |
modprobe zfs | |
# Create your ZFS pool | |
# Note: | |
# - For drives with a block size of 512b, use ashift=9 | |
# - For drives with a blocks size of 4KiB, use ahift=12 | |
zpool create \ | |
-o ashift=12\ | |
-O xattr=sa\ | |
-O redundant_metadata=most\ | |
-O normalization=formD\ | |
-O acltype=posixacl\ | |
-O compression=lz4\ | |
-O dedup=on\ | |
-O dnodesize=legacy\ | |
-O relatime=on\ | |
-O mountpoint=none\ | |
-O canmount=off\ | |
-O devices=off\ | |
-m none\ | |
zroot\ | |
/dev/mapper/luks_root | |
# Export your new zpool and reimport it with an alternate root to avoid mounting conflicts | |
zpool export zroot | |
zpool import -R /mnt zroot | |
# Create all of your datasets | |
# 1 - zroot/root (/) | |
# 2 - zroot/home (/home) | |
# 3 - zroot/home/root (/root) | |
# 4 - zroot/home/your_user_here (/home/your_user_here) | |
# 5 - zroot/var (/var) | |
zfs create -o mountpoint=/ -o canmount=noauto zroot/root | |
zfs create -o mountpoint=/home -o canmount=noauto zroot/home | |
zfs create -o mountpoint=/home/your_user_here -o canmount=noauto zroot/home/your_user_here | |
zfs create -o mountpoint=/root -o canmount=noauto zroot/home/root | |
zfs create -o mountpoint=/var -o canmount=noauto zroot/var | |
# Mount your ESP | |
mkdir -p /mnt/boot | |
mount /dev/sdx1 /mnt/boot | |
# Export your mount configuration to /mnt/etc/fstab | |
# Note: You must comment out all of the exported ZFS dataset mounts, otheriwse you will experience issues booting | |
genfstab -pU /mnt > /mnt/etc/fstab | |
# Add a tmpfs for /tmp to /mnt/etc/fstab | |
# tmpfs /tmp tmpfs defaults,noatime,mode=1777 0 0 | |
# Install Arch Linux | |
pacstrap /mnt \ | |
base\ | |
base-devel\ | |
zsh\ | |
vim\ | |
git\ | |
efibootmgr\ | |
dialog\ | |
openssh\ | |
dhcpcd\ | |
dosfstools\ | |
linux\ | |
linux-headers\ | |
linux-firmware\ | |
mkinitcpio\ | |
intel-ucode\ | |
reflector | |
# Chroot into your new installation | |
arch-chroot /mnt | |
# Set your locales | |
echo "LANG=en_US.UTF-8\nLC_ALL=C\nLANGUAGE=en_US" > /etc/locale.conf | |
echo "en_US.UTF-8 UTF-8" > /etc/locale.gen | |
locale-gen | |
# Set your hostname | |
echo "your_hostname" > /etc/hostname | |
# Enable NTP and set your timezone | |
timedatectl set-ntp true | |
timedatectl set-timezone your_timezone | |
# Enable DHCPCD on boot | |
systemctl enable dhcpcd | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
oh ok