Skip to content

This document is a WORK IN PROGRESS.
This is just a quick personal cheat sheet: treat its contents with caution!


ZFS

ZFS is a combined file system and logical volume manager (designed by Sun Microsystems). ZFS is scalable, and includes extensive protection against data corruption, support for high storage capacities, efficient data compression, integration of the concepts of file system and volume management, snapshots and CoW clones, continuous integrity checking and automatic repair, RAID Z, native NFSv4 ACLs, and can be very precisely configured.

Reference(s)

Table of contents


Install

TODO


Config

TODO


Use

TODO

  • Show disk space utilization info:

    $ zfs list
    

  • Show all properties for or :

    $ zfs get all <POOLNAME>
    $ zfs get all <DATASET_NAME>
    

  • Check zpool status of all pools with extra verbose information:

    $ zpool status -v
    

  • Check zpool status of specific pool with extra verbose information:

    $ zpool status -v <POOLNAME>
    

  • Show verbose information about pools filesystem statistics:

    $ zpool list -v
    

  • Show verbose IO statistics for all pools:

    $ zpool iostat -v
    

  • Show verbose IO statistics for a specific pool :

    $ zpool iostat -v <POOLNAME>
    

  • Show useful and advanced information on how ZFS's ARC Cache is being used:

    $ arcstat
    
    $ arc_summary
    

sanoid

Sanoid is a policy-driven snapshot management tool for ZFS filesystems.

  • How to install (see https://repology.org/project/sanoid/versions):

    # apk add sanoid
    
    # apt install sanoid
    

    TODO

    TODO

    # nix-env -iA nixos.sanoid
    
    # nix-env -iA nixpkgs.sanoid
    

    Install with AUR:

    $ mkdir -p ~/apps/aur-apps
    $ cd ~/apps/aur-apps
    $ git https://aur.archlinux.org/sanoid.git
    $ cd sanoid
    $ makepkg -is # --syncdeps to auto-install deps, --install to install after building
    

    For Artix users

    If you are not using systemd, you might have to translate the sanoid systemd services and timer yourself

    TODO

    # xbps-install -S sanoid
    

    TODO

  • How to use / configure:

    You will also find a more detailed example in /etc/sanoid/sanoid.defaults.conf or /usr/share/sanoid/sanoid.defaults.conf, in order to consult all possible options for the template part of the configuration file.

    • Now let's list the available pool(s) for ZFS snapshots:

      $ zfs list
      
          NAME                USED  AVAIL     REFER  MOUNTPOINT
          production_data    1.11T  11.1T     1.00T  /prod
          archiving_data     3.33T  33.3T     3.00T  /arch
          test_data             1G     1T        1G  /test
          ...
      
    • Let's say you want to snapshot the production_data pool. In order to do so, you can create your own configuration file in /etc/sanoid/sanoid.conf, e.g. :

      [production_data]
          use_template = production
      
      [template_production]
          frequently = 0
          hourly = 0
          daily = 0
          weekly = 1
          monthly = 1
          yearly = 1
          autosnap = yes
          autoprune = yes
      

    This configuration will keep a weekly, a monthly and a yearly snapshot.

    You will have to wait for a 15mn (maximum) before the sanoid.timer applies your configuration and start to take snapshots.

    • You can list your snapshots like so:

      $ zfs list -t snapshot
      
  • ℹ️ Note about systemd: by default, sanoid will work with systemd, i.e. after installation, a systemd timer and two systemd services will be up and running:

    $ systemctl status sanoid.service
      ...
    
    $ systemctl status sanoid-prune.service
      ...
    
    $ systemctl status sanoid.timer
      ...
    

The sanoid.timer timer unit runs sanoid-prune.service followed by sanoid.service every 15 minutes. To edit any of the command-line options, you can edit these service files.

  • ℹ️ Note about snapshots location: by default, all snapshots are saved to the sanoid cache directory: /var/cache/sanoid

RAIDZ expansion

TODO


If this cheat sheet has been useful to you, then please consider leaving a star here.