Полезная штука эта bindfs...
Т.к. про bindfs на LOR что-то мало, дарю сообществу полезный (кмк) скрипт dir2squash
:
#!/bin/bash
USAGE() {
echo "Use: $(basename $0) [-h] [-p permission] [-o outfile] sourcedir
Options:
-h - Help and exit;
-p - Permission (default: a=wrX)
e.g. og-x,og+rD,u=rwX,g+rw or 0644,a+X ;
-o - Output file."
}
#====================================================
while getopts ":hp:o:" opt_name
do
case "$opt_name" in
"h") USAGE; exit 2 ;;
"p") p="-p ${OPTARG}" ;;
"o") o="${OPTARG}" ;;
":") USAGE; exit 1 ;;
"?") echo "Unknown option: '-${OPTARG}'"; USAGE; exit 1 ;;
esac
done
shift "$((OPTIND-1))"
[ $# -eq 0 ] && echo "Error: missing sourcedir." && USAGE && exit 3
sourcedir=$1
echo "sourcedir: "${sourcedir}""
[ ! -d "${sourcedir}" ] && echo "Error: sourcedir is not a directory." && USAGE && exit 4
name=$(basename "$1")
[ -n "${p}" ] || p='-p a=wrX'
[ -n "${o}" ] || o="/tmp/${name}-$(date +%F_%H%M%S).lz4.squash"
wrk=$(mktemp -d) # дир. куда будем монтировать с помощью bindfs для подмены прав
bindfs -o ro ${p} --no-allow-other "${sourcedir}" "${wrk}"
mksquashfs "${wrk}" "${o}" -comp lz4 -b 1M -all-root -no-xattrs && echo "out: ${o}"
fusermount -u -z "${wrk}"
rm -Rf "${wrk}"