From 07fa1c40345f2766e6f08a2a9ed9e322e9e29fa2 Mon Sep 17 00:00:00 2001 From: HoTschir <148773120+HoTschir@users.noreply.github.com> Date: Wed, 25 Sep 2024 13:07:21 +0200 Subject: [PATCH 1/4] log2ram improvement repeated start) (without stop) does not cause additional "mount --bind" anymore --- log2ram | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/log2ram b/log2ram index cd4e5b6..d856d37 100755 --- a/log2ram +++ b/log2ram @@ -1,5 +1,7 @@ #!/usr/bin/env bash +# HTs 2024-09-25: - repeated start) (without stop) does not cause additional "mount --bind" anymore + . /etc/log2ram.conf if [ -z "$PATH_DISK" ]; then @@ -127,20 +129,25 @@ start) HDD_LOG="${PATH_FIRST_PART}/hdd.${PATH_LAST_PART}" LOG2RAM_LOG="${RAM_LOG}/${LOG_NAME}" - [ -d "$HDD_LOG" ] || mkdir "$HDD_LOG" - - mount --bind "$RAM_LOG"/ "$HDD_LOG"/ - mount --make-private "$HDD_LOG"/ - wait_for "$HDD_LOG" - - if [ "$ZL2R" = true ]; then - create_zram_log_drive - mount -t ext4 -o nosuid,noexec,noatime,nodev,user=log2ram "/dev/zram${RAM_DEV}" "$RAM_LOG"/ - else - mount -t tmpfs -o "nosuid,noexec,noatime,nodev,mode=0755,size=${SIZE}" log2ram "$RAM_LOG"/ + # ++HTs 2024-09-25: if HDD_LOG is already mounted, log2ram was started. mounting a second time is counterproductive + mount | grep "$HDD_LOG" 2>&1 > /dev/null + if [ $? != 0 ]; then + # not found, it seems log2ram (for this path) is not started yet + [ -d "$HDD_LOG" ] || mkdir "$HDD_LOG" + + mount --bind "$RAM_LOG"/ "$HDD_LOG"/ + mount --make-private "$HDD_LOG"/ + wait_for "$HDD_LOG" + + if [ "$ZL2R" = true ]; then + create_zram_log_drive + mount -t ext4 -o nosuid,noexec,noatime,nodev,user=log2ram "/dev/zram${RAM_DEV}" "$RAM_LOG"/ + else + mount -t tmpfs -o "nosuid,noexec,noatime,nodev,mode=0755,size=${SIZE}" log2ram "$RAM_LOG"/ + fi + wait_for "$RAM_LOG" + sync_from_disk fi - wait_for "$RAM_LOG" - sync_from_disk done exit 0 ;; From fba1e56993de401166469fe3cd83b69dad095bba Mon Sep 17 00:00:00 2001 From: HoTschir <148773120+HoTschir@users.noreply.github.com> Date: Wed, 25 Sep 2024 13:11:57 +0200 Subject: [PATCH 2/4] log2ram bugfix LOG2RAM_LOG, extended by sync_to_disk, needs to be rescued separately --- log2ram | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/log2ram b/log2ram index d856d37..5753a8e 100755 --- a/log2ram +++ b/log2ram @@ -1,6 +1,7 @@ #!/usr/bin/env bash # HTs 2024-09-25: - repeated start) (without stop) does not cause additional "mount --bind" anymore +# - LOG2RAM_LOG, extended by sync_to_disk, is rescued, when sync_to_disk . /etc/log2ram.conf @@ -53,6 +54,10 @@ sync_to_disk() { else cp -rfup --sparse=always "$RAM_LOG"/ -T "$HDD_LOG"/ 2>&1 | tee -a "$LOG2RAM_LOG" fi + + # ++HTs 2024-09-25: LOG2RAM_LOG, extended by sync_to_disk, needs to be rescued separately + cp "$LOG2RAM_LOG" "$HDD_LOG"/ + } ## @fn sync_from_disk() From 186ca4d9cbbbdfcbe7144bd5507c30475a6bf011 Mon Sep 17 00:00:00 2001 From: HoTschir <148773120+HoTschir@users.noreply.github.com> Date: Wed, 25 Sep 2024 13:14:27 +0200 Subject: [PATCH 3/4] log2ram bugfix cleanup at stop) --- log2ram | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/log2ram b/log2ram index 5753a8e..c4069a4 100755 --- a/log2ram +++ b/log2ram @@ -2,6 +2,7 @@ # HTs 2024-09-25: - repeated start) (without stop) does not cause additional "mount --bind" anymore # - LOG2RAM_LOG, extended by sync_to_disk, is rescued, when sync_to_disk +# - cleanup at stop) . /etc/log2ram.conf @@ -173,6 +174,10 @@ stop) umount -l "$HDD_LOG"/ # Unsure as even with Root permision denied #echo ${ZRAM_LOG} > /sys/class/zram-control/hot_remove + + # ++HTs 2024-09-25: cleanup + rm -rf "$HDD_LOG" + done exit 0 ;; From 4d471c2682a55ad4286fd088a39eb1032e92977d Mon Sep 17 00:00:00 2001 From: HoTschir <148773120+HoTschir@users.noreply.github.com> Date: Wed, 25 Sep 2024 13:30:30 +0200 Subject: [PATCH 4/4] clarify comment LOG2RAM_LOG, extended by sync_to_disk, is rescued to hdd.path --- log2ram | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/log2ram b/log2ram index 5753a8e..842d0dd 100755 --- a/log2ram +++ b/log2ram @@ -1,7 +1,7 @@ #!/usr/bin/env bash # HTs 2024-09-25: - repeated start) (without stop) does not cause additional "mount --bind" anymore -# - LOG2RAM_LOG, extended by sync_to_disk, is rescued, when sync_to_disk +# - LOG2RAM_LOG, extended by sync_to_disk, is rescued to hdd.path . /etc/log2ram.conf