My normal ZFS filesystem build process may look something like:

zpool create vol1 -o autoexpand=on -o autoreplace=on mirror nvme0n1 nvme1n1 -f
zfs set compression=lz4 vol1
zfs set atime=off vol1
zfs set xattr=sa vol1
zfs set acltype=posixacl vol1
zfs create vol1/data -o mountpoint=/data

ZFS seems to allow setting options at filesystems and pool creation using the -o flag. However, in many cases, I need to set filesystem parameters at the top level (for inheritance by new filesystems) rather than define locally.

Is there any way to streamline the multiple zfs set parameter=value lines into a single command line?

  • 1
    Now you have me wondering just what the "..." means in the documentation that shows zfs set property=value filesystem|volume|snapshot ... – Andrew Henle Oct 9 '16 at 15:29
  • The man page says no... – Michael Hampton Oct 9 '16 at 16:54
  • @AndrewHenle It repeats the filesystem|volume|snapshot part an arbitrary non-zero number of times. Try it: something like truncate -s 1G /root/zfstest then zpool create tank /root/zfstest then zfs create tank/fs1 then zfs create tank/fs2 then zfs create tank/fs3 then zfs set compression=gzip-9 tank/fs1 tank/fs2 then zfs get compression tank -r all as root. (At least, that's how ZFS on Linux does it.) – a CVn Nov 4 '16 at 22:00

Depends on the implementation.

On FreeBSD (10.3-STABLE) you can:

# zfs create zfsroot/test
# zfs set compression=lzjb sync=disabled zfsroot/test

And on Solaris (11.2) you can't:

# zfs create rpool/test
# zfs set compression=on sync=disabled rpool/test
cannot open 'sync=disabled': invalid dataset name

Since I don't have a Linux with zfs, this one is for you to discover. :)

  • Interesting. Doing something similar on the current ZFS Linux release results in error. – ewwhite Oct 9 '16 at 18:37
  • Although Linux has a huge number of the features that FreeBSD lacks (and, unfortunately, will be lacking), in my opinion - ZFS is suprisingly (for some mysterious reason, probably licensing schemes clashing) more mature in FreeBSD (of course, among OpenZFS derivatives - it's regrettable, but it looks like that OpenZFS will never provide the ability to swap on zvol (I mean properly) or dump kernel cores): lack of NFSv4 ACLs in Linux, or unreliable root pool support - these two just came in mind, but there's more. – drookie Oct 9 '16 at 18:44
  • The license is the primary reason for ZFS on Linux not providing certain things that it does on other distributions. Oracle even chose that license specifically to attempt to deny ZFS to Linux. – Michael Hampton Oct 9 '16 at 19:30
  • Yet, I find ZFS on Linux wins on hardware compatibility, performance and mindshare. So there are still advantages to working within the Linux ecosystem. – ewwhite Oct 9 '16 at 20:51
  • OmniOS/illumos is the same as FreeBSD, so I assume the same goes for SmartOS and OpenIndiana. – user121391 Oct 10 '16 at 7:30

I realise this might be a bit late, but that's what the -O (uppercase letter) is for: the pool's root dataset. Lowercase letter -o is for pool properties. I used this in Ubuntu/ZoL but FreeBSD seems to have it too. Oh would you look at that, seems Solaris does too!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.