Created
February 24, 2022 19:22
-
-
Save AlexRogalskiy/4ac3809e33c048d27aff1c2fea0ddd10 to your computer and use it in GitHub Desktop.
shortcut for creating zfs volumes
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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