From 64bcf1adce3d3ebb5980df5832ef95a8f45dbfbe Mon Sep 17 00:00:00 2001 From: Justin Cormack Date: Tue, 31 Jan 2017 12:42:37 +0000 Subject: [PATCH] Try to fsck harder This will potentially leave stuff in lost+found but may be able to recover from more filesystem corruption. See #736 Signed-off-by: Justin Cormack --- alpine/packages/automount/etc/init.d/automount | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/alpine/packages/automount/etc/init.d/automount b/alpine/packages/automount/etc/init.d/automount index 30f875ef4..78f2b4fed 100755 --- a/alpine/packages/automount/etc/init.d/automount +++ b/alpine/packages/automount/etc/init.d/automount @@ -7,6 +7,7 @@ depend() do_fsck() { + # preen /sbin/e2fsck -p $* EXIT_CODE=$? # exit code 1 is errors corrected @@ -14,7 +15,17 @@ do_fsck() # exit code 2 or 3 means need to reboot [ "${EXIT_CODE}" -eq 2 -o "${EXIT_CODE}" -eq 3 ] && /sbin/reboot # exit code 4 or over is fatal + [ "${EXIT_CODE}" -lt 4 ] && return "${EXIT_CODE}" + + # try harder + /sbin/e2fsck -y $* + # exit code 1 is errors corrected + [ "${EXIT_CODE}" -eq 1 ] && EXIT_CODE=0 + # exit code 2 or 3 means need to reboot + [ "${EXIT_CODE}" -eq 2 -o "${EXIT_CODE}" -eq 3 ] && /sbin/reboot + # exit code 4 or over is fatal [ "${EXIT_CODE}" -ge 4 ] && printf "Filesystem unrecoverably corrupted, will reformat\n" + return "${EXIT_CODE}" }