sh/bash/mount.sh

83 lines
1.4 KiB
Bash
Raw Normal View History

2024-11-12 08:43:56 +00:00
mo() {
2023-05-09 20:02:34 +00:00
local directory="${1}"
local file
if [ "${directory}" ] ; then
directory="$(realpath "${directory}")"
file="${directory}/filesystem.squashfs"
2024-11-12 08:46:29 +00:00
if mkdir "overlay" ; then
cd "overlay"
2023-05-09 20:02:34 +00:00
mkdir {lower,upper,work,mount}
2024-11-12 08:46:29 +00:00
if mount "${file}" "lower" ; then
mount -t "overlay" "overlay" "mount" \
-o lowerdir="lower",upperdir="upper",workdir="work"
2023-05-09 20:02:34 +00:00
fi
cd ..
fi
else
2024-11-12 08:46:29 +00:00
echo "KO: directory?"
2023-05-09 20:02:34 +00:00
fi
}
2024-11-12 08:43:56 +00:00
uo() {
2024-11-12 08:46:29 +00:00
cd "overlay"
if umount "mount" ; then
rmdir "mount"
rm --recursive "upper" "work"
if umount "lower" ; then
rmdir "lower"
2023-05-09 20:02:34 +00:00
fi
fi
cd ..
2024-11-12 08:46:29 +00:00
rmdir "overlay"
2023-05-09 20:02:34 +00:00
}
2024-11-12 08:43:56 +00:00
mr() {
2024-11-12 08:46:29 +00:00
for f in "dev" "dev/pts" "proc" "sys" ; do
2023-05-09 20:02:34 +00:00
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
2024-11-12 08:43:56 +00:00
ur() {
2024-11-12 08:46:29 +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
}
2024-11-12 08:43:56 +00:00
mm() {
2024-11-12 08:46:29 +00:00
mount --make-rslave --rbind "/deb" "overlay/mount/deb"
2023-05-09 20:02:34 +00:00
}
2024-11-12 08:43:56 +00:00
um() {
2024-11-12 08:46:29 +00:00
umount --recursive "overlay/mount/deb"
2023-05-09 20:02:34 +00:00
}
2024-11-12 08:43:56 +00:00
ms() {
2023-05-09 20:02:34 +00:00
local directory="${1}"
local level="${2}"
if [ "${directory}" ] ; then
if mkdir "${directory}" ; then
2024-11-12 08:46:29 +00:00
[ "${level}" ] || level="18"
2023-05-09 20:02:34 +00:00
cp overlay/mount/{vmlinuz,initrd.img} "${directory}"
mksquashfs \
2024-11-12 08:46:29 +00:00
"overlay/mount" "${directory}/filesystem.squashfs" \
2024-01-05 15:22:23 +00:00
-noappend \
2024-11-12 08:46:29 +00:00
-comp "zstd" -Xcompression-level "${level}"
2023-05-09 20:02:34 +00:00
chown --recursive 1000:1000 "${directory}"
fi
fi
}