2023-05-09 20:02:34 +00:00
|
|
|
function mo {
|
|
|
|
local directory="${1}"
|
|
|
|
local file
|
|
|
|
if [ "${directory}" ] ; then
|
|
|
|
directory="$(realpath "${directory}")"
|
|
|
|
file="${directory}/filesystem.squashfs"
|
|
|
|
if mkdir 'overlay' ; then
|
|
|
|
cd 'overlay'
|
|
|
|
mkdir {lower,upper,work,mount}
|
|
|
|
if mount "${file}" 'lower' ; then
|
|
|
|
mount -t 'overlay' 'overlay' 'mount' \
|
|
|
|
-o lowerdir='lower',upperdir='upper',workdir='work'
|
|
|
|
fi
|
|
|
|
cd ..
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
echo 'KO: directory?'
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
function uo {
|
|
|
|
cd 'overlay'
|
|
|
|
if umount 'mount' ; then
|
|
|
|
rmdir 'mount'
|
|
|
|
rm --recursive 'upper' 'work'
|
|
|
|
if umount 'lower' ; then
|
|
|
|
rmdir 'lower'
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
cd ..
|
|
|
|
rmdir 'overlay'
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function mr {
|
|
|
|
for f in 'dev' 'dev/pts' 'proc' 'sys' ; do
|
|
|
|
mount --bind "/${f}" "overlay/mount/${f}"
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
2023-05-14 21:12:22 +00:00
|
|
|
alias cr="\
|
|
|
|
chroot \
|
|
|
|
\"overlay/mount\" \
|
|
|
|
"
|
|
|
|
|
|
|
|
alias cru="\
|
|
|
|
chroot \
|
|
|
|
--userspec \"1000:1000\" \
|
|
|
|
\"overlay/mount\" \
|
|
|
|
"
|
2023-05-09 20:02:34 +00:00
|
|
|
|
|
|
|
function ur {
|
2023-05-14 21:12:22 +00:00
|
|
|
for f in 'sys' 'proc' 'dev/pts' 'dev' ; do
|
2023-05-09 20:02:34 +00:00
|
|
|
umount --lazy "overlay/mount/${f}"
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function mm {
|
2023-05-16 16:26:21 +00:00
|
|
|
mount --make-rslave --rbind '/deb' 'overlay/mount/deb'
|
2023-05-09 20:02:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function um {
|
2023-05-16 16:26:21 +00:00
|
|
|
umount --recursive 'overlay/mount/deb'
|
2023-05-09 20:02:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function ms {
|
|
|
|
local directory="${1}"
|
|
|
|
local level="${2}"
|
|
|
|
if [ "${directory}" ] ; then
|
|
|
|
if mkdir "${directory}" ; then
|
|
|
|
[ "${level}" ] || level='18'
|
|
|
|
cp overlay/mount/{vmlinuz,initrd.img} "${directory}"
|
|
|
|
mksquashfs \
|
|
|
|
'overlay/mount' "${directory}/filesystem.squashfs" \
|
|
|
|
-b '1M' \
|
|
|
|
-comp 'zstd' -Xcompression-level "${level}"
|
|
|
|
chown --recursive 1000:1000 "${directory}"
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
}
|