8

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?

ewwhite
  • 197,159
  • 92
  • 443
  • 809
  • 1
    Now you have me wondering just what the `"..."` means in [the documentation](http://docs.oracle.com/cd/E19253-01/816-5166/zfs-1m/index.html) that shows `zfs set property=value filesystem|volume|snapshot ...` – Andrew Henle Oct 09 '16 at 15:29
  • The man page says no... – Michael Hampton Oct 09 '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.) – user Nov 04 '16 at 22:00

2 Answers2

8

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. :)

drookie
  • 8,625
  • 1
  • 19
  • 29
  • Interesting. Doing something similar on the current ZFS Linux release results in error. – ewwhite Oct 09 '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 09 '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 09 '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 09 '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 07:30
  • Oracle is guilty of many things, but choosing the license of ZFS is not one of them. That was Sun Microsystems. – Jim Salter Oct 12 '16 at 09:20
3

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!

Samuel Harmer
  • 294
  • 3
  • 9