Skip to content

Instantly share code, notes, and snippets.

@AlexRogalskiy
Created February 24, 2022 19:22
Show Gist options
  • Save AlexRogalskiy/4ac3809e33c048d27aff1c2fea0ddd10 to your computer and use it in GitHub Desktop.
Save AlexRogalskiy/4ac3809e33c048d27aff1c2fea0ddd10 to your computer and use it in GitHub Desktop.
shortcut for creating zfs volumes
# zfs create na nd nx ns blah
zfs_create() {
options=""
while [ $# -gt 0 ]
do
case $1
na) option="atime=off" ;;
a) option="atime=on" ;;
nm) option="mountpoint=none" ;;
m) option="mountpoint=$2" ; shift ;;
nx) option="exec=off" ;;
x) option="exec=on" ;;
ns) option="setuid=off" ;;
s) option="setuid=on" ;;
nd) option="devices=off" ;;
d) option="devices=on" ;;
c) option="primarycache=all" ;;
nc) option="primarycache=none" ;;
mc) option="primarycache=metadata" ;;
nq) option="quota=none" ;;
q) option="quota=$2" ; shift ;;
6|9) option="compression=gzip$1" ;;
lj) option="compression=lzjb" ;;
ncomp) option="compression=off" ;;
comp) option="compression=on" ;;
f4) option="checksum=fletcher4" ;;
f2) option="checksum=fletcher2" ;;
s) option="checksum=sha256" ;;
off|on) option="checksum=$1" ;;
1|2|3) option="copies=$1" ;;
l) option="logbias=latency" ;;
t) option="logbias=throughput" ;;
ro) option="readonly=on" ;;
rw) option="readonly=off" ;;
*) echo zfs create $options "$@"
zfs create $options "$@"
break
esac
options="$options -o $option"
shift
done
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment