ZFS Filesystem Management Guide
ZFS Overview
ZFS (Zettabyte File System) is a next-generation filesystem that combines volume management and filesystem capabilities. It provides advanced features like snapshots, compression, deduplication, and built-in RAID functionality.
Prerequisites
- Root or sudo access required for most ZFS operations
- ZFS kernel modules must be installed
- Understanding of storage concepts recommended
Installation & Setup¶
On Debian, you need to build the kernel module via DKMS:
Alternative: Zabbly ZFS builds
The Incus team maintains optimized ZFS builds at github.com/zabbly/zfs with pre-compiled modules for Debian.
Distribution Support
ZFS packages are available for most major Linux distributions. Check your package manager for zfs-utils or similar packages.
Pool Management¶
Create and List Pools¶
- Creates a new ZFS pool named "local" using device
/dev/xxx - Lists all ZFS pools with their status and capacity
Device Selection
Replace /dev/xxx with your actual device path. This will destroy all data on the device!
Import Existing Pools¶
- Imports a previously created pool (useful after boot or cryptsetup unlock)
Auto-Import
Use this command after system boot or when encrypted drives become available via cryptsetup.
Dataset Management¶
Create and List Datasets¶
zfs create local/home #(1)!
zfs list #(2)!
zfs set mountpoint=/home local/home #(3)!
- Creates a new dataset called "home" in the "local" pool
- Lists all ZFS datasets with their properties
- Sets the mount point for the dataset to
/home
Compression & Optimization¶
NFS Sharing¶
Setup NFS Server¶
apt install nfs-kernel-server nfs-common #(1)!
systemctl enable --now rpc-statd.service nfs-server.service #(2)!
- Installs NFS kernel server and common utilities
- Enables and starts NFS services
Configure ZFS NFS Shares¶
zfs set sharenfs="rw=@10.0.1.0/24" local/home #(1)!
zfs share local/home #(2)!
zfs get sharenfs #(3)!
- Sets NFS share permissions for 10.0.1.0/24 network
- Activates the NFS share
- Displays current NFS share settings
Snapshots & Backups¶
Snapshot Management¶
zfs snapshot local/containers/archive@backup #(1)!
zfs list -t snapshot #(2)!
zfs destroy local/containers/archive@backup #(3)!
- Creates a snapshot named "backup" of the archive dataset
- Lists all available snapshots
- Removes the specified snapshot
Remote Backup¶
zfs send local/containers/archive@backup | ssh zfs@10.0.1.1 sudo zfs recv local/lxd00/containers/archive #(1)!
- Sends snapshot over SSH to remote ZFS system for backup
Backup Strategy
- Create regular snapshots for point-in-time recovery
- Use
zfs send/recvfor efficient remote backups - Consider automated snapshot management tools
Clone Operations¶
- Creates a writable clone from a snapshot
Clones vs Snapshots
- Snapshots: Read-only point-in-time copies
- Clones: Writable copies that can be modified independently
Additional Resources¶
Best Practices
- Monitor pool health with
zpool status - Regular snapshots before major changes
- Use compression for most datasets
- Be cautious with deduplication on systems with limited RAM
Common Commands Quick Reference