User Tools

Install arch linux with zfs root

  1. Obtain latest ISO from archlinux.org and burn it to an ISO
  2. Boot up and change / size \
    1. mount a swap partition
    2. mount -o remount,size=16G /run/archiso/cowspace
  3. Add zfs support
    1. curl -s https://archzfs.leibelt.de/media/setup/init | bash
    2. zgenhostid -f 0x00bab10c
  4. Partition Disk(s)
    1. Create EFI partition
      sgdisk -n "1:1m:+512m" -t "1:ef00" /dev/sda
    2. I suggest a swap partition large enough to hold RAM (my system has 16g) contents if you intend to use hibernate
      sgdisk -n "2:0:+16g" -t "2:8200" /dev/sda
    3. Allocate the remainder to the ZFS pool
      sgdisk -n "3:0:-10m" -t "3:bf00" /dev/sda
  5. Create the ZFS pool
    1. I suggest using the partition UUID for the device name.
      root@archiso ~ # ls -l /dev/disk/by-partuuid|grep sda3 
      lrwxrwxrwx 1 root root 10 Sep  2 10:21 1aea6cc8-8333-4d5c-a9e6-e0a51296391d -> ../../sda3
    2. We will be using zfsbootmenu which is currently using OpenZFS 2.3
      zpool create -f -o ashift=12 \
       -O compression=lz4 \
       -O acltype=posixacl \
       -O xattr=sa \
       -O relatime=on \
       -o autotrim=on \
       -o compatibility=openzfs-2.3-linux \
       -m none zroot /dev/disk/by-partuuid/1aea6cc8-8333-4d5c-a9e6-e0a51296391d
  6. Export / Import the ZFS pool
    zpool export zroot && zpool import -NR /mnt zroot
  7. Create the ZFS file systems including the home directory for the normal user account.
    zfs create -o mountpoint=none zroot/ROOT
    zfs create -o mountpoint=/ -o canmount=noauto zroot/ROOT/arch
    zfs mount zroot/ROOT/arch
    
    zfs mount
    zroot/ROOT/arch                 /mnt
  8. Set up EFI and swap partitions
    mkfs.vfat -F32 /dev/sda1
    mkswap /dev/sda2
  9. Install the system
    pacstrap /mnt linux linux-headers linux-firmware base vim amd-ucode networkmanager sudo openssh rsync
  10. Populate the fstab
    echo "$(blkid /dev/sda1|cut -d\  -f2) /boot/efi vfat defaults 0 2" >> /mnt/etc/fstab
    echo "$(blkid /dev/sda2|cut -d\  -f2) none swap defaults 0 0" >> /mnt/etc/fstab
  11. Move into the install
    1. arch-chroot /mnt
  12. Set up arch system
    1. Time
      ln -sf /usr/share/zoneinfo/America/New_York /etc/localtime
      hwclock --systohc
    2. locale
      sed -i 's/#\(en_US\.UTF-8\)/\1/' /etc/locale.gen
      locale-gen
      echo "LANG=en_US.UTF-8" > /etc/locale.conf
    3. vconsole
      echo -e "KEYMAP=us\n#FONT=latarcyrheb-sun32" > /etc/vconsole.conf
    4. hostname/hosts
      echo tas > /etc/hostname
    5. set root password
      passwd root
  13. Create a normal user and add to sudoers/wheel group
    useradd -G wheel some_user
    passwd some_user
    mkdir -p ~some_user && chown some_user ~some_user
    1. edit sudoers with visudo to uncomment one of the wheel stanzas
      EDITOR=vim visudo
    2. create home for some_user
      mkdir -p ~some_user && chown some_user ~some_user
    3. su - some_user
  14. Install paru
    sudo pacman -S --needed base-devel git
    git clone https://aur.archlinux.org/paru.git
    cd paru
    makepkg -si
  15. Install zfs support
    paru -S zfs-utils
    paru -S zfs-dkms
  16. exit to root
    exit
  17. finish setup
    1. zgenhostid -f 0x00bab10c
    2. edit /etc/mkinitcpio.conf and modify the HOOKS line adding resume and zfs
      vim /etc/mkinitcpio.conf
      grep ^HOOKS /etc/mkinitcpio.conf
      HOOKS=(base udev autodetect microcode modconf kms keyboard keymap zfs consolefont block filesystems resume)
      mkinitcpio -P
    3. fix up user home directories
      rm -rf ~some_user; mv /root /_root
    4. set up services
      systemctl disable zfs-import-cache.service
      systemctl mask zfs-import-cache.service
      systemctl enable zfs-import-scan.service zfs-mount.service zfs.target zfs-volumes.target zfs-import.target zfs-zed.service NetworkManager
  18. Set up the EFI and install zfsbootmenu
    zfs set org.zfsbootmenu:commandline="rw quiet" zroot/ROOT
    mkdir /boot/efi
    mount /boot/efi
    mkdir -p /boot/efi/EFI/ZBM
    curl -o /boot/efi/EFI/ZBM/VMLINUZ.EFI -L https://get.zfsbootmenu.org/efi
    cp /boot/efi/EFI/ZBM/VMLINUZ.EFI /boot/efi/EFI/ZBM/VMLINUZ-BACKUP.EFI
    pacman -S refind
    refind-install
    rm /boot/refind_linux.conf
    cat << EOF >> /boot/efi/EFI/refind/refind_linux.conf
    
    menuentry "zbm boot" {
        loader /EFI/ZBM/VMLINUZ.EFI
        options "quiet loglevel=0 zbm.skip"
    }
    menuentry "zbm menu" {
        loader /EFI/ZBM/VMLINUZ.EFI
        options "quiet loglevel=0 zbm.show"
    }
    menuentry "zbm backup menu" {
        loader /EFI/ZBM/VMLINUZ-BACKUP.EFI
        options "quiet loglevel=0 zbm.show"
    }
    EOF
  19. Exit and reboot
    exit
    umount -n -R /mnt
    zpool export zroot
    reboot
  20. Finish up
    1. Log in as root
      zfs create -o mountpoint=none zroot/homes
      zfs create -o mountpoint=/root zroot/homes/root
      zfs create -o mountpoint=/home/USER zroot/homes/USER
      cp -r /etc/skel/. ~
      cp -r /etc/skel/. ~some_user
      chown -R some_user:some_user ~some_user
      chmod 750 ~some_user
      zfs snapshot zroot/ROOT/arch@initial
      exit

This website uses cookies. By using the website, you agree with storing cookies on your computer. Also, you acknowledge that you have read and understand our Privacy Policy. If you do not agree, please leave the website.

More information