Add ZRAM ramdisk support

This commit is contained in:
j1nx 2021-03-02 17:01:39 +01:00
parent 364d8be816
commit ad5b3114db
4 changed files with 39 additions and 4 deletions

View File

@ -9,4 +9,3 @@ tmpfs /run tmpfs mode=0755,nosuid,nodev 0 0
sysfs /sys sysfs defaults 0 0
#tmpfs /var/log tmpfs defaults 0 0
tmpfs /var/tmp tmpfs defaults 0 0
tmpfs /ramdisk tmpfs rw,nodev,nosuid,size=20M 0 0

View File

@ -0,0 +1,16 @@
[Unit]
Description=OVOS ZRAM ramdisk
DefaultDependencies=no
Requires=zram-ramdisk.service
After=zram-ramdisk.service
Before=umount.target
Conflicts=umount.target
[Mount]
What=/dev/zram1
Where=/ramdisk
Type=ext4
Options=nobarrier,strictatime,nosuid,nodev
[Install]
WantedBy=local-fs.target

View File

@ -0,0 +1,15 @@
[Unit]
Description=OVOS ZRAM ramdisk
DefaultDependencies=no
Before=ramdisk.mount
RefuseManualStart=true
RefuseManualStop=true
[Service]
Type=oneshot
ExecStart=/usr/libexec/ovos-zram -t fs -m ramdisk -s 20M
RemainAfterExit=true
StandardOutput=null
[Install]
WantedBy=ovos-zram.target

View File

@ -35,7 +35,7 @@ while [ "$1" != "" ]; do
done
# Valide Type
if [ "$TYPE" != "swap" ]; then
if [ "$TYPE" != "swap" ] && [ "$TYPE" != "fs" ]; then
echo "[Error] Type unknown!"
exit 1
fi
@ -43,8 +43,8 @@ fi
# Lookup device
if [ "$TYPE" = "swap" ]; then
DEVICE="/dev/zram0"
#elif [ "$MOUNT" = "var" ]; then
# DEVICE="/dev/zram1"
elif [ "$MOUNT" = "ramdisk" ]; then
DEVICE="/dev/zram1"
#elif [ "$MOUNT" = "tmp" ]; then
# DEVICE="/dev/zram2"
else
@ -64,3 +64,8 @@ zramctl "$DEVICE" -s "$SIZE" -a lz4
if [ "$TYPE" = "swap" ]; then
mkswap -L "ovos-zramswap" "$DEVICE"
fi
# FileSystem
if [ "$TYPE" = "fs" ]; then
mkfs.ext4 -L "ovos-$MOUNT" -O ^has_journal "$DEVICE"
fi