mod for standalone, moar descriptive

This commit is contained in:
kneutron 2021-04-12 17:56:12 -05:00 committed by GitHub
parent 1c2a453be1
commit f17084e802
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,39 +1,46 @@
#!/bin/bash
# =LLC= © (C)opyright 2017 Boojum Consulting LLC / Dave Bechtel, All rights reserved.
## NOTICE: Only Boojum Consulting LLC personnel may use or redistribute this code,
## Unless given explicit permission by the author - see http://www.boojumconsultingsa.com
#
# 2014 Dave Bechtel
# cre8 a new ZFS dataset with options
echo "$0 opt1=(1)compression opt1=(1)sharesmb, 0 == OFF zpool dirname"
# cre8 a new ZFS dataset with options and loggit
echo "$0 opt1=(1)compression opt2=(1)sharesmb, 0 == OFF zpool dirname"
echo "Example: $0 11 zpoolname datasetname"
echo "== create zpoolname/datasetname as Shared Samba dataset with recordsize 1M and set owner"
# TODO -e /tmp/infile read it and process it
source ~/bin/failexit.mrg
logfile=/var/root/boojum-zfs-newds.log
logfile=~/boojum-zfs-newds.log
# TODO editme
#source ~/bin/failexit.mrg
# failexit.mrg
function failexit () {
echo '! Something failed! Code: '"$1 $2" |tee -a $logfile # code # (and optional description)
exit $1
}
# xxx TODO editme
#zp=zredpool2; myds=home/vmtmpdir/vmware-virtmachines
zp="$2"; myds="$3"
user=dave
#user=nerdz
# this is for chown later
# defaults
compr=lz4
shrwin=off
dcompr=lz4
#dcompr=zstd-2 ## for zfs 2.0.x
dshrwin=off
# opt1=compression, opt2=sharesmb
case "$1" in
"10" )
# use defaults
compr=lz4; shrwin=off
compr=$dcompr; shrwin=$dshrwin
;;
"11" )
compr=lz4; shrwin=on
compr=$dcompr; shrwin="on -o xattr=sa"
# NOTE xattr=sa may not work in older versions of freebsd
;;
"01" )
compr=off; shrwin=on
compr=off; shrwin="on -o xattr=sa"
;;
"00" )
compr=off; shrwin=off
@ -50,25 +57,18 @@ esac
# trace on
(set -x
zfs create -o \
atime=off -o compression=$compr -o sharesmb=$shrwin -o recordsize=1024k \
atime=off -o compression=$compr -o sharesmb=${shrwin} -o recordsize=1024k \
$zp/$myds || failexit 99 "! Failed to create ZFS $zp/$myds"
)
echo "`date` + $zp/$myds + compr=$compr:shr=$shrwin + owner:$user" >> $logfile
echo "$(date) + $zp/$myds + compr=$compr:shr=${shrwin} + Owner:$user" >> $logfile
# NOTE does not take into account alt.mountpoints like /home!
chown -v $user /$zp/$myds; ls -al /$zp/$myds
#df -h /$zp/$myds
df -h |head -n 1
df -h |grep $myds
df -hT |head -n 1
df -hT |grep $myds
exit;
# MAC mods
/var/root/bin/boojum/zfs-newds.sh: line 57: /root/boojum-zfs-newds.log: No such file or directory
chown: /zwdgreentera/dvnotshrcompr: No such file or directory
ls: /zwdgreentera/dvnotshrcompr: No such file or directory
Filesystem Size Used Avail Capacity iused ifree %iused Mounted on
zwdgreentera/dvnotshrcompr 449Gi 324Ki 449Gi 1% 10 942667768 0% /Volumes/zwdgreentera/dvnotshrcompr
40 root ~ # pwd
/var/root
This is not intended to be comprehensive, but should provide a good example