浏览代码

Merge pull request #76 from StuartIanNaylor/no-journal

journal + mount tune
testing
azlux 5 年前
committed by GitHub
父节点
当前提交
4f3cfacf08
找不到此签名对应的密钥 GPG 密钥 ID: 4AEE18F83AFDEB23
共有 5 个文件被更改,包括 40 次插入16 次删除
  1. +1
    -1
      install.sh
  2. +21
    -12
      log2ram
  3. +1
    -1
      log2ram.conf
  4. +16
    -1
      log2ram.logrotate
  5. +1
    -1
      uninstall.sh

+ 1
- 1
install.sh 查看文件

@@ -13,7 +13,7 @@ systemctl enable log2ram

# cron
install -m 755 log2ram.hourly /etc/cron.hourly/log2ram
install -m 644 log2ram.logrotate /etc/logrotate.d/log2ram
install -m 644 log2ram.logrotate /etc/logrotate.d/00_log2ram

# Remove a previous log2ram version
rm -rf /var/log.hdd


+ 21
- 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,34 @@ 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]+')
invoke-rc.d rsyslog stop
L2G_DEV=$(df /var/log | tail -1 | awk '{ print $1 }' | tr -dc '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
echo "$L2G_DEV" > /sys/class/zram-control/hot_remove
rmod zram
else
echo "$L2G_DEV" > /sys/class/zram-control/hot_remove
fi
fi
invoke-rc.d rsyslog restart
journalctl --flush
;;

write)
syncToDisk


+ 1
- 1
log2ram.conf 查看文件

@@ -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


+ 16
- 1
log2ram.logrotate 查看文件

@@ -1,3 +1,19 @@
# These settings will save the rotated logfiles to a seperate location.
# This file needs to be located in /etc/logrotate.d.
# The "00" prefix in the file name is required to ensure this file is
# loaded before any program specific logrotate settings are loaded as
# contents of /etc/logrotate.d are read in alphabetical order.

# The path & name for rotated logfiles folder.
olddir /var/log.old

# Create the path if it doesn't exist
createolddir 755 root root

# To allow the files to be "moved" (ie copied and original deleted)
# to another device/partition (eg out of RAM)
renamecopy

/var/log/log2ram.log
{
rotate 7
@@ -7,4 +23,3 @@
delaycompress
compress
}


+ 1
- 1
uninstall.sh 查看文件

@@ -8,7 +8,7 @@ then
rm /usr/local/bin/log2ram
rm /etc/log2ram.conf
rm /etc/cron.hourly/log2ram
rm /etc/logrotate.d/log2ram
rm /etc/logrotate.d/00_log2ram

if [ -d /var/hdd.log ]; then
rm -r /var/hdd.log


正在加载...
取消
保存