lxc-ramdisk/bin/ramdisk.sh
2023-04-10 20:33:27 +02:00

45 lines
808 B
Bash
Executable File

#! /usr/bin/env bash
start() {
[ -d /ramdisk/sys ] && rm -rf /ramdisk/sys
[ -d /ramdisk/tmp ] && rm -rf /ramdisk/tmp
mkdir -p /ramdisk/sys
mkdir -p /ramdisk/tmp
echo "Bienvenue dans le ramdisk"
mount -t tmpfs -o size=32G tmpfs /ramdisk/sys
mount -t tmpfs -o size=32G tmpfs /ramdisk/tmp
echo "ramdisk monté!"
if [ -d /ramdisk/persist ]; then
cp -a /ramdisk/persist/* /ramdisk/sys/
echo "Données persistentes copiées!"
fi
mount -o remount,ro /ramdisk/sys
}
stop() {
umount /ramdisk/sys
rm -rf /ramdisk/sys
umount /ramdisk/tmp
rm -rf /ramdisk/tmp
echo "ramdisk démonté!"
}
help() {
echo "ramdisk.sh start|stop"
echo " Mount a readonly ramdisk to /ramdisk/sys and a read-write one to /ramdisk/tmp"
}
case "$1" in
"start")
start
;;
"stop")
stop
;;
*)
help
;;
esac