Package: initscripts
Version: 3.14-4

Dear maintainer,

checkroot.sh returns error and does not even attempt to save logs if logfile does not exist - for example, when /var/log is on a different partition, which is not yet mounted.


[root@debian13 ~]# ls -l /var/log/fsck
ls: cannot access '/var/log/fsck': No such file or directory

[root@debian13 ~]# /etc/init.d/checkroot.sh start
Will now check root file system:Cannot persist the following output on disc ... 
failed!
[/sbin/fsck.ext4 (1) -- /] fsck.ext4 -a -C0 /dev/sda1
/dev/sda1: clean, 28655/524288 files, 374797/2096896 blocks


The culprit is the logsave_best_effort function in mount-functions.sh, which only runs logsave if the logfile exists, defeating the very purpose of logsave.

I suggest the following patch:


--- old/mount-functions.sh
+++ new/mount-functions.sh
@@ -727,7 +727,7 @@
 # This function does not actually belong here; it is duct-tape solution
 # for #901289.
 logsave_best_effort() {
-       if [ -x /sbin/logsave ] && [ -e "${FSCK_LOGFILE}" ]; then
+       if [ -x /sbin/logsave ]; then
                logsave -s "${FSCK_LOGFILE}" "$@"
        else
                log_failure_msg "Cannot persist the following output on disc"


And maybe we should change the log severity to warning - the important part is actually running the command (in our case: fsck), not saving the log; and perhaps changing "disc" to "disk" in the error message (AFAIK "disc" refers to optical media).


--- old/mount-functions.sh
+++ new/mount-functions.sh
@@ -730,7 +730,7 @@
        if [ -x /sbin/logsave ]; then
                logsave -s "${FSCK_LOGFILE}" "$@"
        else
-               log_failure_msg "Cannot persist the following output on disc"
+               log_warning_msg "Cannot persist the following output on disk"
                "$@"
        fi
 }


With my patch(es):


[root@debian13 ~]# ls -l /var/log/fsck
ls: cannot access '/var/log/fsck': No such file or directory

[root@debian13 ~]# /etc/init.d/checkroot.sh start
Will now check root file system:[/sbin/fsck.ext4 (1) -- /] fsck.ext4 -a -C0 
/dev/sda1
/dev/sda1: clean, 28657/524288 files, 374807/2096896 blocks
.

[root@debian13 ~]# pidof logsave
2309

[root@debian13 ~]# mount /var/log

[root@debian13 ~]# pidof logsave

[root@debian13 ~]# ls -l /var/log/fsck/checkroot
-rw-r--r-- 1 root root 227 May 30 09:34 /var/log/fsck/checkroot


--
Best regards,
Zsolt Bartos-Elekes

Reply via email to