Quellcode durchsuchen

Add zram functionality

pull/66/head
StuartIanNaylor vor 5 Jahren
Ursprung
Commit
34d32373c3
4 geänderte Dateien mit 43 neuen und 2 gelöschten Zeilen
  1. +0
    -0
      install.sh
  2. +26
    -1
      log2ram
  3. +17
    -1
      log2ram.conf
  4. +0
    -0
      uninstall.sh

+ 0
- 0
install.sh Datei anzeigen


+ 26
- 1
log2ram Datei anzeigen

@@ -50,21 +50,46 @@ wait_for () {
done
}

createZramLogDrive () {
# Check Zram Class created
if [ ! -d '/sys/class/zram-control' ]; then
modprobe zram
RAM_DEV='0'
else
RAM_DEV=$(cat /sys/class/zram-control/hot_add)
fi
echo ${COMP_ALG} > /sys/block/zram${RAM_DEV}/comp_algorithm
echo ${LOG_DISK_SIZE} > /sys/block/zram${RAM_DEV}/disksize
echo ${SIZE} > /sys/block/zram${RAM_DEV}/mem_limit
mke2fs -t ext4 /dev/zram${RAM_DEV}
}

case "$1" in
start)
[ -d $HDD_LOG/ ] || mkdir $HDD_LOG/
mount --bind $RAM_LOG/ $HDD_LOG/
mount --make-private $HDD_LOG/
if [ "$ZL2R" = true ]; then
createZramLogDrive
fi
wait_for $HDD_LOG
mount -t tmpfs -o nosuid,noexec,nodev,mode=0755,size="$SIZE" log2ram $RAM_LOG/
if [ "$ZL2R" = true ]; then
mount -t ext4 -o nosuid,noexec,nodev,user=log2ram /dev/zram${RAM_DEV} ${RAM_LOG}/
else
mount -t tmpfs -o nosuid,noexec,nodev,mode=0755,size=${SIZE} log2ram $RAM_LOG/
fi
wait_for $RAM_LOG
syncFromDisk
;;

stop)
syncToDisk
#ZRAM_LOG=$(awk '$2 == "/var/log" {print $1}' /proc/mounts)
#ZRAM_LOG=$(echo ${ZRAM_LOG} | grep -o -E '[0-9]+')
umount -l $RAM_LOG/
umount -l $HDD_LOG/
# Unsure as even with Root permision denied
#echo ${ZRAM_LOG} > /sys/class/zram-control/hot_remove
;;

write)


+ 17
- 1
log2ram.conf Datei anzeigen

@@ -14,4 +14,20 @@ USE_RSYNC=false

# If there are some errors with available RAM space, a system mail will be send
# Change it to false and you will have only a log if there is no place on RAM anymore.
MAIL=true
MAIL=true

# **************** Zram backing conf *************************************************

# ZL2R Zram Log 2 Ram enables a zram drive when ZL2R=true ZL2R=false is mem only tmpfs
ZL2R=false
# COMP_ALG this is any compression algorithm listed in /proc/crypto
# lz4 is fastest with lightest load but deflate (zlib) and Zstandard (zstd) give far better compression ratios
# lzo is very close to lz4 and may with some binaries have better optimisation
# COMP_ALG=lz4 for speed or Zstd for compression, lzo or zlib if optimisation or availabilty is a problem
COMP_ALG=lz4
# LOG_DISK_SIZE is the uncompressed disk size. Note zram uses about 0.1% of the size of the disk when not in use
# LOG_DISK_SIZE is expected compression ratio of alg chosen multiplied by log SIZE
# lzo/lz4=2.1:1 compression ratio zlib=2.7:1 zstandard=2.9:1
# Really a guestimate of a bit bigger than compression ratio whilst minimising 0.1% mem usage of disk size
LOG_DISK_SIZE=100M


+ 0
- 0
uninstall.sh Datei anzeigen


Laden…
Abbrechen
Speichern