Skip to content

Instantly share code, notes, and snippets.

@kbruner
Created November 3, 2020 06:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kbruner/852949efb55b34c26b895132f4781b6b to your computer and use it in GitHub Desktop.
Save kbruner/852949efb55b34c26b895132f4781b6b to your computer and use it in GitHub Desktop.
manual ZFS-on-root disk partitioning
# Remember to replace nvd0 with your disk's device name
# Legacy boot partition
gpart add -t freebsd-boot -s 256k -l boot nvd0
# UEFI
gpart add -t efi -s 2m -l efi nvd0
newfs_msdos /dev/gpt/efi
# Swap. Adjust size (-s) as desired.
gpart add -t freebsd-swap -l swap -a 1m -s 8G nvd0
# ZFS. Adjust size as needed or omit -s flag and arg to use remaining disk
gpart add -t freebsd-zfs -l zroot -a 1m -s 200G nvd0
# ZFS pool
zpool create -R /mnt -o cachefile=/tmp/zpool.cache -O mountpoint=/ \
-O atime=off -O canmount=off -O compression=on \
zroot nvd0
zfs create -o canmount=off -o mountpoint=none zroot/ROOT
zfs create -o mountpoint=/ zroot/ROOT/default
zpool set bootfs=zroot/ROOT/default zroot
zfs create zroot/home
zfs create -o canmount=off zroot/usr
zfs create zroot/usr/local
zfs create zroot/usr/obj
zfs create zroot/usr/src
zfs create zroot/usr/ports
zfs create zroot/usr/ports/distfiles
zfs create -o canmount=off zroot/var
zfs create zroot/var/jail
zfs create zroot/var/log
zfs create zroot/var/tmp
zfs create zroot/tmp
# Copy the zpool cache file to /boot
mkdir -p /mnt/boot/zfs
cp /tmp/zpool.cache /mnt/boot/zfs
exit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment