ZFS Operations
Common ZFS operations.
Mounting Existing ZFS Pool
zpool import {POOL}
zpool status {POOL}
zpool scrub {POOL}
zfs mount -l -a
Note
A pool name does not need to be used to identify a ZFS container, it will be detected automatically.
zpool import -a
.Search for the pool, then mount it, use
-f
if it wasn’t exported. Scrub.
Hint
Set mountpoint to immutable without the ZFS dataset mounted. This prevents
writes when the dataset is not ready: chattr +i {MOUNTPOINT}
ZFS Filesystem Options
ZFS can be tweaked per dataset based on the data being used. ZFS only applies new settings on newly written data; changing options for pre-existing data requires export/re-import of that data to the dataset.
zfs set atime=off {POOL}/{DATASET}
zfs set compression=lz4 {POOL}/{DATASET}
zfs set compression=gzip {POOL}/{DATASET}
Setup Monthly ZFS Scrub
Scrubbing verifies all blocks can be read, and marks then bad if not. This is done while the filesystem is online, but may slightly impact performance.
#!/bin/bash
#
# Scrubs zpool monthly.
/sbin/zpool scrub {POOL}
@weekly /root/bin/scrub-zpool-monthly