Skip to content

Instantly share code, notes, and snippets.

@loukamb
Last active January 24, 2025 19:04
Show Gist options
  • Save loukamb/4f0f482fe0553786d506ce544cbf4d64 to your computer and use it in GitHub Desktop.
Save loukamb/4f0f482fe0553786d506ce544cbf4d64 to your computer and use it in GitHub Desktop.
Void Linux w/ ZFS on Root

Void Linux w/ ZFS on Root

This is a personal cheat sheet for myself that I use to install Void Linux. Assumes you're running a x64 CPU, using a NVMe disk at /dev/nvme0n1 and UEFI. If you're attempting this, use hrmpf to install Void Linux, not the live image they provide since it lacks ZFS support. Don't blindly copy/paste shit, you will have to adjust certain commands.

Pre-chroot

source /etc/os-release
export ID
export ARCH=x86_64
export MIRROR="https://repo-fastly.voidlinux.org/current"
export BOOT_DEVICE="/dev/nvme0n1p1"
export POOL_DEVICE="/dev/nvme0n1p2"
export BOOT_DISK="/dev/nvme0n1"
export POOL_DISK="/dev/nvme0n1"
zgenhostid -f 0x00bab10c
zpool labelclear -f "$POOL_DISK"
wipefs -a "$POOL_DISK"
sgdisk --zap-all "$POOL_DISK"
cfdisk /dev/nvme0n1
# In cfdisk, setup two partitions: 1 GB with type "EFI System",
# remainder of space with type "Linux filesystem".
echo 'Disk Password Here' > /etc/zfs/zroot.key
chmod 000 /etc/zfs/zroot.key
zpool create -f -o ashift=12 \
 -O compression=lz4 \
 -O acltype=posixacl \
 -O xattr=sa \
 -O relatime=on \
 -O encryption=aes-256-gcm \
 -O keylocation=file:///etc/zfs/zroot.key \
 -O keyformat=passphrase \
 -o autotrim=on \
 -m none zroot "$POOL_DEVICE"
zfs create -o mountpoint=none zroot/ROOT
zfs create -o mountpoint=/ -o canmount=noauto zroot/ROOT/${ID}
zfs create -o mountpoint=/home zroot/home
zpool set bootfs=zroot/ROOT/${ID} zroot
zpool export zroot
zpool import -N -R /mnt zroot
zfs load-key -L prompt zroot
zfs mount zroot/ROOT/${ID}
zfs mount zroot/home
udevadm trigger
XBPS_ARCH=$ARCH xbps-install -S -R "${MIRROR}" -r /mnt base-system
cp /etc/hostid /mnt/etc
mkdir /mnt/etc/zfs
cp /etc/zfs/zroot.key /mnt/etc/zfs
xchroot /mnt

Chroot

xbps-install -R "${MIRROR}" neovim xtools xmirror zsh void-repo-nonfree
xmirror
xbps-install -S # may be redundant after xmirror call
echo 'desktop' > /etc/hostname
ln -sf /usr/share/zoneinfo/America/Toronto /etc/localtime
cat << EOF >> /etc/default/libc-locales
en_US.UTF-8 UTF-8
en_US ISO-8859-1
EOF
xbps-reconfigure -f glibc-locales
passwd
cat << EOF > /etc/dracut.conf.d/zol.conf
nofsck="yes"
add_dracutmodules+=" zfs "
omit_dracutmodules+=" btrfs "
install_items+=" /etc/zfs/zroot.key "
EOF
echo 'add_drivers+=" nvidia nvidia_modeset nvidia_drm "' > /etc/dracut.conf.d/nvidia.conf
xbps-install zfs nvidia
zfs set org.zfsbootmenu:commandline="quiet nvidia-drm.modeset=1 nvidia-drm.fbdev=1" zroot/ROOT
zfs set org.zfsbootmenu:keysource="zroot/ROOT/${ID}" zroot
mkfs.vfat -F32 "$BOOT_DEVICE"
cat << EOF >> /etc/fstab
$( blkid | grep "$BOOT_DEVICE" | cut -d ' ' -f 2 ) /boot/efi vfat defaults 0 0
EOF
mkdir -p /boot/efi
mount /boot/efi
xbps-install zfsbootmenu gummiboot-efistub
nvim /etc/zfsbootmenu/config.yaml
# change Global.ManageImages to true, Components.Enabled to false, save and quit
generate-zbm
xbps-install refind
refind-install
rm /boot/refind_linux.conf
cat << EOF > /boot/efi/EFI/ZBM/refind_linux.conf
"Boot default"  "quiet loglevel=0 zbm.skip"
"Boot to menu"  "quiet loglevel=0 zbm.show"
EOF
exit
umount -n -R /mnt
zpool export zroot
reboot

Rebooted

# login into root
ln -s /etc/sv/dhcpcd /var/service
# wait until internet comes on. ping 1.1.1.1 to check internet status.
visudo
# grant sudo perms to wheel user by uncommenting line
useradd -m -G wheel,audio,video,plugdev,lp louka
passwd louka
exit
# login as louka
sudo chsh
/usr/bin/zsh
exit
# login as louka again
sudo xbps-install flatpak flatpak-builder xorg kde-plasma konsole gwenview spectacle pinentry-qt kwrite git fastfetch pipewire firefox
sudo mkdir -p /etc/pipewire/pipewire.conf.d
sudo ln -s /usr/share/examples/wireplumber/10-wireplumber.conf /etc/pipewire/pipewire.conf.d/
sudo ln -s /usr/share/examples/pipewire/20-pipewire-pulse.conf /etc/pipewire/pipewire.conf.d/
sudo ln -s /usr/share/applications/pipewire.desktop /etc/xdg/autostart
sudo ln -s /usr/share/fontconfig/conf.avail/70-no-bitmaps.conf /etc/fonts/conf.d/
sudo xbps-reconfigure -f fontconfig
sudo ln -s /etc/sv/dbus /var/service
sudo ln -s /etc/sv/sddm /var/service
sudo reboot
# installation complete lol

After all this, I generally clone my fork of void-packages with some xbps packages for MEGAsync, import my GPG key, install vscode and whatever else I need.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment