Short Reference on ZFS Commands


These are my very short notes about using ZFS. Be sure check manpages zfs(8) and zpool(8) and consult additional documentation in case anything is unclear. Commands may need to be changed for your systems etc.


For unattended processes it is recommended to setup zfs-dkms first and only afterwards do zfsutils-linux because otherwise the utils may want to start some services while the modules are not loaded yet. All of the packages are in Debian contrib repository.

# In case it works
aptitude install zfs-dkms zfs-zed zfsutils-linux

# Safe for automation (to be verified/from memory)
apt-get install zfs-dkms
modprobe zfs
apt-get install zfsutils-linux

On live systems and other systems which are not using ZFS yet, issue

modprobe zfs

before using any of the ZFS commands.


At any time, consult the status of ZFS as follows:

zpool status      # list pools and report degraded info
zpool list        # list pools short
zpool iostat 10   # display I/O stats every 10 sec.
zfs list          # list file systems on pools

Creating ZFS Pools and Volumes

Create a Pool

# zpool create ... <pool> mirror <dev0> <dev1>
zpool create -m none -o ashift=12 masysmahdd6t mirror \
                    ata-TOSHIBA_... ata-TOSHIBA_...
-m none
Avoid creating a mountpoint for the pool as-is. It is recommended to create zfs inside the pool instead!
-o ashift=12
Recommended setting for advanced format devices (4K physical sectors, 212 = 4096). Recommended value for Intel P4510 SSDs is also 12. See and

Create a File System

# zfs create ... <pool>/<name>
zfs create -o reservation=300g -o quota=400g -o mountpoint=/data \
-o reservation=300g
Attempt to guarantee that this FS can hold 300 GiB (?) of data.
-o quota=400g
Cap the size of this FS. This is what df -h will display as “free”.
-o mountpoint=/data
Mount this ZFS. Note: /etc/fstab is not used and the mountpoint directory is created if not already existent.

ZFS for Swap?

Using a ZFS volume for swap is not directly advised against by the manpage, but may result in system lockups, see

Current idea is to use MDADM for swap which loses the ability to use whole devices rather than partitions but may otherwise be the most practical variant.

Regular Maintenance

Run zfs scrubs. Like mdadm RAID resync?

# zpool scrub <pool>
zpool scrub masysmahdd6t

Follow the progress with zpool status.

Move ZFS to Other System

Before removing disks from previous server.

# zpool export <pool>
zpool export masysmahdd6t

After inserting disks into new server.

# zpool import ... [pool]
zpool import -d /dev/disk/by-id masysmahdd6t

If pool name is left out, it will display the pools available for importing.

Replace a Failed Disk

(!) WARNING: This has not been verified yet (!) Quoted command from

# zpool replace <pool-name> <failed-disk-id> <new-disk-id>
zpool replace pool1 ata-ST31000340NS_9QJ0EQ1V ata-ST31000340NS_9QJ0DVN2

As per zpool replace manpage, one could als replace a device “by itself” after failure:

zpool replace pool1 sda sda

This may also be the command to use in case of “failure” after an intermittent drive connection issue?

Note that the ZFS term for resync in case of new/replaced disks is “resilver”.

Docker+ZFS Write Amplification

See also This may enhance lifetime of mostly-idle SSDs at the expense of higher losses in case of power failure.

# check ongoing I/O on raw devices
iostat -k 10

# Enlarge zfs_txg_timeout (beware power outrages!)
# Default is 5; other users use up to 60 seconds.
echo 20 > /sys/module/zfs/parameters/zfs_txg_timeout

Making the change persistent:

# /etc/modprobe.d/masysma-zfs.conf
# Enlarge zfs_txg_timeout from 5 to 20sec to reduce idle SSD writes
options zfs zfs_txg_timeout=20

See Also Website 5 (1.0.2) – no Flash, no JavaScript, no Webfont, no Copy Protection, no Mobile First. No bullshit. No GUI needed. Works with any browser.

Created: 2020/10/24 23:56:40 | Revised: 2024/01/12 18:17:36 | Tags: zfs, linux, kb | Version: 1.0.2 | SRC (Pandoc MD) | GPL

Copyright (c) 2020, 2024 For further info send an e-mail to

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see <>.