HON’s Wiki # ZFS

Home / Linux Servers

Contents

Using ZFS on Linux (ZoL).

Info

Setup (Debian)

Installation (Debian 11)

  1. Install: apt install zfsutils-linux

Installation (Debian 10)

The backports repo is used to get the newest version of ZoL.

  1. Enable the Buster backports repo: See Backports (Debian Wiki)
    • Add the following lines to /etc/apt/sources.list
        deb http://deb.debian.org/debian buster-backports main contrib non-free
        deb-src http://deb.debian.org/debian buster-backports main contrib non-free
      
  2. Install: apt install -t buster-backports zfsutils-linux

Configuration (Debian)

  1. (Typically not needed) Check that the cron scrub script exists:
    • Typical location: /etc/cron.d/zfsutils-linux
    • If it doesn’t exist, add one which runs /usr/lib/zfs-linux/scrub e.g. monthly. It’ll scrub all disks.
  2. (Typically not needed) Check that ZED is working:
    • ZEDLET: /etc/zfs/zed.d/history_event-zfs-list-cacher.sh should point to /usr/lib/zfs-linux/zed.d/history_event-zfs-list-cacher.sh.
    • Email sending: In /etc/zfs/zed.d/zed.rc, make sure ZED_EMAIL_ADDR="root" is uncommented.,
    • Service: zfs-zed.service should be enabled.
  3. (Optional) Set the max ARC size:
    • Command: echo "options zfs zfs_arc_max=$((<gigabytes>*1024*1024*1024))" >> /etc/modprobe.d/zfs.conf
    • It should typically be around 15-25% of the physical RAM size on general nodes. It defaults to 50%.
    • This is generally not required, ZFS should happily yield RAM to other processes that need it.
  4. (Optional) Automatically load key (if encrypted) and mount pool/dataset on boot: See encryption section.
  5. (Optional) Fix pool cache causing pool loading problems at boot:
    1. (Note) Do this if systemctl status zfs-import-cache.service shows that no pools were found. I had significant problems with this multiple times with Proxmox VE on an older server.
    2. Make sure the pools are not set to use a cache file: zpool get cachefile and zpool set cachefile=none <pool>
    3. Copy /lib/systemd/system/zfs-import-scan.service to /etc/systemd/system/.
    4. In zfs-mount.service, comment the ConditionFileNotEmpty=!/etc/zfs/zpool.cache line (the file tends to find a way back to existance).
    5. Update systemd files: systemctl daemon-reload
    6. Disable the caching import service: systemctl disable zfs-import-cache.service
    7. Enable the scanning import service: systemctl enable zfs-import-scan.service
    8. Delete the existing cache file: rm /etc/zfs/zpool.cache
    9. In /etc/default/zfs, set:
      • ZPOOL_CACHE='' (no cache file)
      • ZFS_INITRD_PRE_MOUNTROOT_SLEEP='5' (or higher)
      • ZFS_INITRD_POST_MODPROBE_SLEEP='5' (or higher)
    10. Update initramfs: update-initramfs -u -k all
    11. Reboot.
    12. Check if the pools are loaded correctly at boot (see systemctl status zfs-import-cache.service).

Usage

General

Pools

L2ARC

SLOG

Special Device

Datasets

Snapshots

Transfers

Encryption

Error Handling and Replacement

Events

Miscellanea

Best Practices and Suggestions

Extra Notes

Troubleshooting

“cannot create ‘pool’: URI scheme is not supported”:

Reboot.

zfs-auto-snapshot

See zfsonlinux/zfs-auto-snapshot (GitHub).


hon.one | HON95/wiki | Edit page