I'm running Ubuntu 19.10 on ZFS and all works good. I know that Ubuntu has fstrim scheduled on a weekly basis by default but ZFS also supports trim through '/sbin/zpool trim [pool]'. What's the difference between them and should I schedule both to trim my SSD?
1 Answers
To put it short, fstrim is a command to run trim on filesystems that support this by the kernel, such as ext4, btrfs, f2fs etc.
Since ZFS is more than just a filesystem (it's also a disk volume manager), it has it's own trim utility to trim a Zpool (the top component of a ZFS storage system), which is run by the zpool trim command.
This is needed because a mount point on a ZFS system is not necessarily equivalent to a disk (a mount point can be a pool, a subfilesystem, a snapshot etc.). And since the fstrim command does not know the ZFS data structure, it can't do anything on ZFS.
This is completely evident if you actually try to run fstrim on a ZFS mount point, which I tried below:
$ sudo fstrim -v /mnt/zfs/public
fstrim: /mnt/zfs/public: the discard operation is not supported
So this will not work. Instead, for ZFS you should set up regular trim with the zpool trim command, or set the ZFS property autotrim=on on your Zpool.
Also see this Q&A for advice on how to configure trim on your ZFS pool.
- 31,035