瀏覽代碼

journal + mount tune

pull/76/head
StuartIanNaylor 5 年之前
父節點
當前提交
26396f5b8c
共有 2 個文件被更改,包括 20 次插入15 次删除
  1. +17
    -12
      log2ram
  2. +3
    -3
      log2ram.conf

+ 17
- 12
log2ram 查看文件

@@ -52,8 +52,7 @@ wait_for () {

createZramLogDrive () {
# Check Zram Class created
if [ ! -d "/sys/class/zram-control" ]; then
modprobe zram
if modprobe --first-time --verbose zram; then
RAM_DEV='0'
else
RAM_DEV=$(cat /sys/class/zram-control/hot_add)
@@ -61,7 +60,8 @@ createZramLogDrive () {
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}
mke2fs -v -t ext4 -O ^has_journal -s 1024 -L log2ram$RAM_DEV /dev/zram${RAM_DEV}
tune2fs -o journal_data_writeback /dev/zram${RAM_DEV}
}

case "$1" in
@@ -70,25 +70,30 @@ case "$1" in
mount --bind $RAM_LOG/ $HDD_LOG/
mount --make-private $HDD_LOG/
wait_for $HDD_LOG
if [ "$ZL2R" = true ]; then
if [ "$ZL2R" = true ]; then
createZramLogDrive
mount -t ext4 -o nosuid,noexec,nodev,user=log2ram /dev/zram${RAM_DEV} ${RAM_LOG}/
else
mount -t ext4 -o nosuid,noexec,nodev,discard,user=log2ram /dev/zram${RAM_DEV} ${RAM_LOG}/
else
mount -t tmpfs -o nosuid,noexec,nodev,mode=0755,size=${SIZE} log2ram $RAM_LOG/
fi
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
;;
if [ "$ZL2R" = true ]; then
RAM_DEV=$(cat /sys/class/zram-control/hot_add)
if [ "$RAM_DEV" -eq "1" ];then
rmod zram
else
RAM_DEV=$(df /var/log | tail -1 | awk '{ print $1 }' | tr -dc '0-9')
echo "$RAM_DEV" > /sys/class/zram-control/hot_remove
fi
fi
;;

write)
syncToDisk


+ 3
- 3
log2ram.conf 查看文件

@@ -5,7 +5,7 @@
# If it's not enough, log2ram will not be able to use ram. Check you /var/log size folder.
# The default is 40M and is basically enough for a lot of applications.
# You will need to increase it if you have a server and a lot of log for example.
SIZE=40M
SIZE=20M

# This variable can be set to true if you prefer "rsync" rather than "cp".
# I use the command cp -u and rsync -X, so I don't copy the all folder every time for optimization.
@@ -19,7 +19,7 @@ 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
ZL2R=true
# 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
@@ -29,5 +29,5 @@ COMP_ALG=lz4
# 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
LOG_DISK_SIZE=60M


Loading…
取消
儲存