I've tried
Code: Select all
args0="-K '-c options=/usr/share/xfsprogs/mkfs/lts_6.6.conf'"I know this is some eval shenanigans but no idea how to solve it.
Code: Select all
args0="-K '-c options=/usr/share/xfsprogs/mkfs/lts_6.6.conf'"What happen if you take out the single quote (') in from of "-c" and after "...conf"?grknight wrote:I need zram-init to pass an option to mkfs.xfs but it is not working properly.
I've triedWhen used mkfs.xfs says "Unknown option: -c options=/usr/share/xfsprogs/mkfs/lts_6.6.conf", but if I run it from the command-line, e.g. mkfs.xfs -c options=/usr/share/xfsprogs/mkfs/lts_6.6.conf /dev/zram0 it works perfectly.Code: Select all
args0="-K '-c options=/usr/share/xfsprogs/mkfs/lts_6.6.conf'"
I know this is some eval shenanigans but no idea how to solve it.
pingtoo wrote:What happen if you take out the single quote (') in from of "-c" and after "...conf"?
Code: Select all
zram-init | * Loading zram module... [ ok ]
zram-init | * Mount zram0 /var/tmp/portage
zram-init |Usage: zram-init [options] SIZE|write [DIR]
zram-init |Prepare a zRAM device and use it as swap (resp. mount it under DIR).
zram-init |SIZE is the maximal size in megabytes.
zram-init |For umounting/freeing the zRAM device, use SIZE=0.
zram-init |When using "write" (or anything else starting with "w") an idle writeback
zram-init |is forced (only makes sense if previously initialized with "-w" or "-W LIMIT").
zram-init |If DIR is - then only a filesystem is created in /dev/zram$DEV (or the device
zram-init |is removed if SIZE is 0) but it is not mounted
zram-init |(options "-o", "-c", "-m", and "-T" take no effect in this case, of course).
zram-init |The latter can be useful e.g. for Btrfs if multiple devices should be mounted
zram-init |jointly afterwards.
zram-init |The following options are available.
zram-init |An empty argument means the same as if the option is not specified.
zram-init |-d DEV Use zRAM device DEV. If not specified, DEV=0 is assumed.
zram-init | Make sure to use the matching value for umounting (SIZE=0)!
zram-init |-D NUM If modprobe needs to be used, require NUM devices. This is not
zram-init | recommended. Rely instead on /etc/modprobe.d/zram.conf with the line
zram-init | "options zram num_devices=NUM"
zram-init |-s NUM Use up to NUM parallel compression streams for the device
zram-init |-S MAX Use maximally MAX megabytes of uncompressed memory for the device
zram-init |-b DEV Use DEV as backing device
zram-init |-I If combined with "-b DEV", store incompressible pages to
zram-init | backing device
zram-init |-w If combined with "-b DEV", enable idle writeback to backing device
zram-init |-W LIMIT As "-w" but additionally set writeback_limit to LIMIT * 4kB.
zram-init |-a ALGO Set compression algorithm to ALGO (e.g. zstd, lz4, or lzo)
zram-init |-A PARAM Set algorithm parameters to PARAM (e.g. "algo=zstd level=22")
zram-init |-c OWNER If specified, chown to OWNER (resp. OWNER:GROUP) after mounting.
zram-init | If not specified, the default owner (root:root) is not changed.
zram-init |-m MODE If specified, chmod DIR to MODE after mounting.
zram-init |-o OPTS If specified, mount DIR with "-o OPTS".
zram-init |-p PRIO Use priority PRIO for the swap device.
zram-init | If not specified, PRIO=16383 is assumed.
zram-init | Use PRIO=- if you want to keep the default priority (-1).
zram-init |-t TYPE Use a filesystem of type TYPE if DIR is specified.
zram-init | TYPE can be either ext2, ext4, btrfs or xfs
zram-init | If not specified, TYPE=ext4 is assumed.
zram-init |-B BSIZE Override default blocksize (ext2, ext4) (BSIZE=1024|2048|4096)
zram-init |-i IRATIO If specified override default bytes/inodes in fs (ext2, ext4)
zram-init |-N INODES If specified override inode count (ext2, ext4)
zram-init |-L LABEL Specify the label LABEL for the new filesystem
zram-init |-U UUID Specify the uuid UUID for the new filesystem
zram-init |-T If specified, do not use the discard (TRIM) feature of ext4/swap.
zram-init | Use this option with linux-3.14 or earlier or when you want a slight
zram-init | speed increase at the cost of possibly wasting a lot of memory
zram-init |-l Do not use zramctl even if available
zram-init |-k Do no attempt to umount/free a previously used zRAM under this
zram-init | device
zram-init |
zram-init |If you have push.sh in $PATH, you can also use accumulatively:
zram-init |-K ARG Pass ARG to the respective mkswap or mkfs.* call
zram-init |-M ARG Pass ARG to the respective swapon/mount call
zram-init |-2 ARG Pass ARG to the tune2fs call (ignored unless for ext2 or ext4)
zram-init |-Z ARG Pass ARG to the zramctl call
zram-init |
zram-init |Call with LANG=C to disable translations [ !! ]Code: Select all
zram-init | * Loading zram module... [ ok ]
zram-init | * Mount zram0 /var/tmp/portage
zram-init |unknown option -c options=/usr/share/xfsprogs/mkfs/lts_6.6.conf
zram-init |Usage: mkfs.xfs
zram-init |/* blocksize */ [-b size=num]
zram-init |/* config file */ [-c options=xxx]
zram-init |/* metadata */ [-m crc=0|1,finobt=0|1,uuid=xxx,rmapbt=0|1,reflink=0|1,
zram-init | inobtcount=0|1,bigtime=0|1,autofsck=xxx,
zram-init | metadir=0|1]
zram-init |/* quota */ [-m uquota|uqnoenforce,gquota|gqnoenforce,
zram-init | pquota|pqnoenforce]
zram-init |/* data subvol */ [-d agcount=n,agsize=n,file,name=xxx,size=num,
zram-init | (sunit=value,swidth=value|su=num,sw=num|noalign),
zram-init | sectsize=num,concurrency=num]
zram-init |/* force overwrite */ [-f]
zram-init |/* inode size */ [-i perblock=n|size=num,maxpct=n,attr=0|1|2,
zram-init | projid32bit=0|1,sparse=0|1,nrext64=0|1,
zram-init | exchange=0|1,max_atomic_write=n]
zram-init |/* no discard */ [-K]
zram-init |/* log subvol */ [-l agnum=n,internal,size=num,logdev=xxx,version=n
zram-init | sunit=value|su=num,sectsize=num,lazy-count=0|1,
zram-init | concurrency=num]
zram-init |/* label */ [-L label (maximum 12 characters)]
zram-init |/* naming */ [-n size=num,version=2|ci,ftype=0|1,parent=0|1]]
zram-init |/* no-op info only */ [-N]
zram-init |/* prototype file */ [-p fname]
zram-init |/* populate from directory */ [-p dirname,atime=0|1]
zram-init |/* quiet */ [-q]
zram-init |/* realtime subvol */ [-r extsize=num,size=num,rtdev=xxx,rgcount=n,rgsize=n,
zram-init | concurrency=num,zoned=0|1,start=n,reserved=n]
zram-init |/* sectorsize */ [-s size=num]
zram-init |/* version */ [-V]
zram-init | devicename
zram-init |<devicename> is required unless -d name=xxx is given.
zram-init |<num> is xxx (bytes), xxxs (sectors), xxxb (fs blocks), xxxk (xxx KiB),
zram-init | xxxm (xxx MiB), xxxg (xxx GiB), xxxt (xxx TiB) or xxxp (xxx PiB).
zram-init |<value> is xxx (512 byte blocks).
zram-init |zram-init:
zram-init |mkfs.xfs /dev/zram0 failed [ !! ]Code: Select all
args0="-K -c -K options=/usr/share/xfsprogs/mkfs/lts_6.6.conf"Notice it say you need "push.sh" in your PATH, do you have that?grknight wrote:pingtoo wrote:What happen if you take out the single quote (') in from of "-c" and after "...conf"?Code: Select all
zram-init | * Loading zram module... [ ok ] ... zram-init | zram-init |If you have push.sh in $PATH, you can also use accumulatively: zram-init |-K ARG Pass ARG to the respective mkswap or mkfs.* call zram-init |-M ARG Pass ARG to the respective swapon/mount call zram-init |-2 ARG Pass ARG to the tune2fs call (ignored unless for ext2 or ext4) zram-init |-Z ARG Pass ARG to the zramctl call zram-init | zram-init |Call with LANG=C to disable translations [ !! ]
Sorry, Not very good at shell substitution, can only suggest try out.grknight wrote:Yes, it is installed and in the PATH (added with env.d file)pingtoo wrote:Notice it say you need "push.sh" in your PATH, do you have that?
I found it on Github:vaeth/push
Code: Select all
args0='-K -c options=/usr/share/xfsprogs/mkfs/lts_6.6.conf'Code: Select all
K) Push mkfs_opt "$OPTARG";;Same error as your first suggestion.pingtoo wrote:So what if in steads double quote the args0, change it to single quite? like thisCode: Select all
args0='-K -c options=/usr/share/xfsprogs/mkfs/lts_6.6.conf'
Code: Select all
getopts K: opt
case $opt in
K) echo OPTARG="$OPTARG"
esac
source /home/me/Downloads/push.sh
Push mkfs_opt "$OPTARG"
eval "set -- a $mkfs_opt"
shift
echo \>Using ${1+"$@"}\<
echo \$1=$1
echo \$2=$2
echo \$3=$3
mkfs.xfs ${1+"$@"} -- /dev/zram0Code: Select all
bash -x ./gg "-K-coptions=/usr/share/xfsprogs/mkfs/lts_6.6.conf"Code: Select all
+ getopts K: opt
+ case $opt in
+ echo OPTARG=-coptions=/usr/share/xfsprogs/mkfs/lts_6.6.conf
OPTARG=-coptions=/usr/share/xfsprogs/mkfs/lts_6.6.conf
+ source /home/me/Downloads/push.sh
+ Push mkfs_opt -coptions=/usr/share/xfsprogs/mkfs/lts_6.6.conf
+ case $1 in
+ eval 'PushA_=$mkfs_opt'
++ PushA_=
+ PushB_=mkfs_opt
+ shift
+ for PushE_ in "$@"
+ '[' -z '' ']'
+ unset PushF_
+ case ${PushE_:-=} in
+ PushC_=-coptions=/usr/share/xfsprogs/mkfs/lts_6.6.conf
+ PushD_=-coptions=/usr/share/xfsprogs/mkfs/lts_6.6.conf
+ :
+ case $PushD_ in
+ PushA_=-coptions=/usr/share/xfsprogs/mkfs/lts_6.6.conf
+ '[' x-coptions=/usr/share/xfsprogs/mkfs/lts_6.6.conf = x-coptions=/usr/share/xfsprogs/mkfs/lts_6.6.conf ']'
+ break
+ eval 'mkfs_opt=$PushA_
unset PushA_ PushB_ PushC_ PushD_ PushE_
[ -n "${mkfs_opt:++}" ]'
++ mkfs_opt=-coptions=/usr/share/xfsprogs/mkfs/lts_6.6.conf
++ unset PushA_ PushB_ PushC_ PushD_ PushE_
++ '[' -n + ']'
+ eval 'set -- a -coptions=/usr/share/xfsprogs/mkfs/lts_6.6.conf'
++ set -- a -coptions=/usr/share/xfsprogs/mkfs/lts_6.6.conf
+ shift
+ echo '>Using' '-coptions=/usr/share/xfsprogs/mkfs/lts_6.6.conf<'
>Using -coptions=/usr/share/xfsprogs/mkfs/lts_6.6.conf<
+ echo '$1=-coptions=/usr/share/xfsprogs/mkfs/lts_6.6.conf'
$1=-coptions=/usr/share/xfsprogs/mkfs/lts_6.6.conf
+ echo '$2='
$2=
+ echo '$3='
$3=
+ mkfs.xfs -coptions=/usr/share/xfsprogs/mkfs/lts_6.6.conf -- /dev/zram0
Parameters parsed from config file /usr/share/xfsprogs/mkfs/lts_6.6.conf successfully
specified blocksize 4096 is less than device physical sector size 16384
switching to logical sector size 4096
can't get size of data subvolume
Usage: mkfs.xfs
/* blocksize */ [-b size=num]
/* config file */ [-c options=xxx]
/* metadata */ [-m crc=0|1,finobt=0|1,uuid=xxx,rmapbt=0|1,reflink=0|1,
inobtcount=0|1,bigtime=0|1]
/* data subvol */ [-d agcount=n,agsize=n,file,name=xxx,size=num,
(sunit=value,swidth=value|su=num,sw=num|noalign),
sectsize=num
/* force overwrite */ [-f]
/* inode size */ [-i perblock=n|size=num,maxpct=n,attr=0|1|2,
projid32bit=0|1,sparse=0|1,nrext64=0|1]
/* no discard */ [-K]
/* log subvol */ [-l agnum=n,internal,size=num,logdev=xxx,version=n
sunit=value|su=num,sectsize=num,lazy-count=0|1]
/* label */ [-L label (maximum 12 characters)]
/* naming */ [-n size=num,version=2|ci,ftype=0|1]
/* no-op info only */ [-N]
/* prototype file */ [-p fname]
/* quiet */ [-q]
/* realtime subvol */ [-r extsize=num,size=num,rtdev=xxx]
/* sectorsize */ [-s size=num]
/* version */ [-V]
devicename
<devicename> is required unless -d name=xxx is given.
<num> is xxx (bytes), xxxs (sectors), xxxb (fs blocks), xxxk (xxx KiB),
xxxm (xxx MiB), xxxg (xxx GiB), xxxt (xxx TiB) or xxxp (xxx PiB).
<value> is xxx (512 byte blocks).Code: Select all
args0='-K-coptions=/usr/share/xfsprogs/mkfs/lts_6.6.conf'This seems like it works as well. I guess the -K option isn't apparent and limited.Hu wrote:You found a syntax where mkfs.xfs allowed everything to be in one parameter, so -K keeping everything together worked. I'm still curious whether my suggestion would work.
Code: Select all
args0='-K -c -K options=/usr/share/xfsprogs/mkfs/lts_6.6.conf'My mental state apperently pretty weak todayHu wrote:My approach has the benefit that it passes -c and options=... as separate parameters, so if the called tool required that -c be its own option, then my approach would work, whereas -K-coptions=... would not. If the tool accepts both, then use whichever seems most convenient.
Code: Select all
source /home/me/Downloads/push.sh
while getopts K: opt; do
case $opt in
K) Push mkfs_opt "$OPTARG"
esac
done
eval "set -- a $mkfs_opt"
shift
echo \>Using ${1+"$@"}\<
echo \$1=$1
echo \$2=$2
echo \$3=$3
mkfs.xfs ${1+"$@"} -- /dev/zram0Code: Select all
bash -x ./gg -K -c -K options=/usr/share/xfsprogs/mkfs/lts_6.6.confCode: Select all
+ source /home/me/Downloads/push.sh
+ getopts K: opt
+ case $opt in
+ Push mkfs_opt -c
+ case $1 in
+ eval 'PushA_=$mkfs_opt'
++ PushA_=
+ PushB_=mkfs_opt
+ shift
+ for PushE_ in "$@"
+ '[' -z '' ']'
+ unset PushF_
+ case ${PushE_:-=} in
+ PushC_=-c
+ PushD_=-c
+ :
+ case $PushD_ in
+ PushA_=-c
+ '[' x-c = x-c ']'
+ break
+ eval 'mkfs_opt=$PushA_
unset PushA_ PushB_ PushC_ PushD_ PushE_
[ -n "${mkfs_opt:++}" ]'
++ mkfs_opt=-c
++ unset PushA_ PushB_ PushC_ PushD_ PushE_
++ '[' -n + ']'
+ getopts K: opt
+ case $opt in
+ Push mkfs_opt options=/usr/share/xfsprogs/mkfs/lts_6.6.conf
+ case $1 in
+ eval 'PushA_=$mkfs_opt'
++ PushA_=-c
+ PushB_=mkfs_opt
+ shift
+ for PushE_ in "$@"
+ '[' -z + ']'
+ PushA_='-c '
+ unset PushF_
+ case ${PushE_:-=} in
+ PushC_=options=/usr/share/xfsprogs/mkfs/lts_6.6.conf
+ PushD_=options=/usr/share/xfsprogs/mkfs/lts_6.6.conf
+ :
+ case $PushD_ in
+ PushA_='-c options=/usr/share/xfsprogs/mkfs/lts_6.6.conf'
+ '[' xoptions=/usr/share/xfsprogs/mkfs/lts_6.6.conf = xoptions=/usr/share/xfsprogs/mkfs/lts_6.6.conf ']'
+ break
+ eval 'mkfs_opt=$PushA_
unset PushA_ PushB_ PushC_ PushD_ PushE_
[ -n "${mkfs_opt:++}" ]'
++ mkfs_opt='-c options=/usr/share/xfsprogs/mkfs/lts_6.6.conf'
++ unset PushA_ PushB_ PushC_ PushD_ PushE_
++ '[' -n + ']'
+ getopts K: opt
+ eval 'set -- a -c options=/usr/share/xfsprogs/mkfs/lts_6.6.conf'
++ set -- a -c options=/usr/share/xfsprogs/mkfs/lts_6.6.conf
+ shift
+ echo '>Using' -c 'options=/usr/share/xfsprogs/mkfs/lts_6.6.conf<'
>Using -c options=/usr/share/xfsprogs/mkfs/lts_6.6.conf<
+ echo '$1=-c'
$1=-c
+ echo '$2=options=/usr/share/xfsprogs/mkfs/lts_6.6.conf'
$2=options=/usr/share/xfsprogs/mkfs/lts_6.6.conf
+ echo '$3='
$3=
+ mkfs.xfs -c options=/usr/share/xfsprogs/mkfs/lts_6.6.conf -- /dev/zram0
Parameters parsed from config file /usr/share/xfsprogs/mkfs/lts_6.6.conf successfully
specified blocksize 4096 is less than device physical sector size 16384
switching to logical sector size 4096
can't get size of data subvolume
Usage: mkfs.xfs
/* blocksize */ [-b size=num]
/* config file */ [-c options=xxx]
/* metadata */ [-m crc=0|1,finobt=0|1,uuid=xxx,rmapbt=0|1,reflink=0|1,
inobtcount=0|1,bigtime=0|1]
/* data subvol */ [-d agcount=n,agsize=n,file,name=xxx,size=num,
(sunit=value,swidth=value|su=num,sw=num|noalign),
sectsize=num
/* force overwrite */ [-f]
/* inode size */ [-i perblock=n|size=num,maxpct=n,attr=0|1|2,
projid32bit=0|1,sparse=0|1,nrext64=0|1]
/* no discard */ [-K]
/* log subvol */ [-l agnum=n,internal,size=num,logdev=xxx,version=n
sunit=value|su=num,sectsize=num,lazy-count=0|1]
/* label */ [-L label (maximum 12 characters)]
/* naming */ [-n size=num,version=2|ci,ftype=0|1]
/* no-op info only */ [-N]
/* prototype file */ [-p fname]
/* quiet */ [-q]
/* realtime subvol */ [-r extsize=num,size=num,rtdev=xxx]
/* sectorsize */ [-s size=num]
/* version */ [-V]
devicename
<devicename> is required unless -d name=xxx is given.
<num> is xxx (bytes), xxxs (sectors), xxxb (fs blocks), xxxk (xxx KiB),
xxxm (xxx MiB), xxxg (xxx GiB), xxxt (xxx TiB) or xxxp (xxx PiB).
<value> is xxx (512 byte blocks).Code: Select all
bash -x ./gg '-K -c -K options=/usr/share/xfsprogs/mkfs/lts_6.6.conf'Code: Select all
' -c -K options=/usr/share/xfsprogs/mkfs/lts_6.6.conf'Code: Select all
mkfs.xfs ' -c -K options=/usr/share/xfsprogs/mkfs/lts_6.6.conf' -- /dev/zram0