Table of Contents
ZFS install
Ubuntu
On ubuntu based systems after 16.04 it's enough to run
apt install zfsutils-linux
for zfs support to be installed.
Mint
The same as Ubuntu.
Centos7
https://github.com/zfsonlinux/zfs/wiki/RHEL-and-CentOS
Add module to autoload by creating file /etc/modules-load.d/zfs.conf with content
zfs
ZFS pools
Create a striped pool
zpool create -o ashift=12 -m <mountpoint> <pool-name> <device1> <device2>
Create a mirror pool
zpool create -o ashift=12 -m <mountpoint> <pool-name> mirror <device1> <device2>
Create a raidz pool
- raidz/raidz1 - one drive can fail (requires 3+ drives)
- raidz2 - two drives can fail (requires 3+ drives)
- raidz3 - three drives can fail (requires 4+ drives)
zpool create -o ashift=12 -m <mountpoint> <pool-name> raidz <device1> <device2> <device3>
Add device to pool
Please note you should match current pool type for accurate redundancy.
zpool add <pool-name> mirror|raidz(2,3)|none <device(s)>
Get status on pool
zpool status <pool-name>
Delete pool
zpool destroy <pool-name>
List pools
zpool list
Rename pool
This is a two step process. First the pool must be exported, then imported to a new name.
zpool export <pool-name> zpool import <pool-name> <new-pool-name>
Import pool
Typically after re-installing the OS the datadrive (zfs) needs to be imported. Again this is a two step process.
zpool import
will list the zfs pools that it can find. Then it's just a matter of running
zpool import -f <pool-name>
to import the pool and mount the datasets.
Make sure to use by-id or similar for import as device naming (sd*) can change.
zpool import -f -d /dev/disk/by-id <pool-name>
ZFS datasets
or filesystems, as some call them
Create dataset
zfs create -o mountpoint=<mountpoint> <pool-name>/<dataset>
Delete dataset
zfs destroy <pool-name>/<dataset>
Set Quota
zfs set quota=xxG <pool-name>/<dataset>
ZFS snapshots
Create a snapshot
zfs snapshot -r <pool-name>/<dataset>@<snapshot-name>
List snapshots
zfs list -t snapshot
Rollback to snapshot
zfs rollback <pool-name>/<dataset>@<snapshot-name>
Delete snapshot
zfs destroy <pool-name>/<dataset>@<snapshot-name>
Delete all snapshots
for snapshot in `zfs list -H -t snapshot -r <pool>|cut -f 1`; do zfs destroy $snapshot; done
Troubleshooting
Cannot load zfs module
ZFS installation problems on KDE Neon (16.04).
$ zpool status The ZFS modules are not loaded. Try running '/sbin/modprobe zfs' as root to load them.
$ /sbin/modprobe zfs modprobe: ERROR: could not insert 'zfs': Unknown symbol in module, or unknown parameter (see dmesg)
It seems there is a problem on a fresh install of KDE Neon (16.04) where the kernel installed is not the same as the kernel headers. My only solution was to remove all zfs and kernel related packages and reinstall the following packages
linux-headers-generic linux-image-generic zfsutils-linux