Add back persistance fsck option
authorChas Williams <chas3@att.com>
Mon, 12 Mar 2018 15:51:22 +0000 (15:51 +0000)
committerLuca Boccassi <luca.boccassi@gmail.com>
Mon, 12 Mar 2018 22:36:58 +0000 (22:36 +0000)
Commit bc79205b554396acd1a20538df2e189eb304ec9e removed the fsck
option due to lack of usage. But it can be useful and we have had
customer escalations due to corrupted persistent filesystem, which
are solved by being able to configure this option.

Mailing list thread:
 https://lists.debian.org/debian-live/2015/08/msg00107.html

components/9990-main.sh
components/9990-misc-helpers.sh
manpages/en/live-boot.7

index bab0bd7..4a965d5 100755 (executable)
@@ -182,5 +182,7 @@ Live ()
        exec 1>&6 6>&-
        exec 2>&7 7>&-
        kill ${tailpid}
-       [ -w "${rootmnt}/var/log/" ] && mkdir -p "${rootmnt}/var/log/live" && cp boot.log "${rootmnt}/var/log/live" 2>/dev/null
+       [ -w "${rootmnt}/var/log/" ] && mkdir -p "${rootmnt}/var/log/live" && ( \
+                               cp boot.log "${rootmnt}/var/log/live" 2>/dev/null; \
+                               cp fsck.log "${rootmnt}/var/log/live" 2>/dev/null )
 }
index e21fced..a565ed5 100755 (executable)
@@ -95,6 +95,7 @@ is_nice_device ()
 
 check_dev ()
 {
+       local force fix
        sysdev="${1}"
        devname="${2}"
        skip_uuid_check="${3}"
@@ -195,6 +196,33 @@ check_dev ()
        then
                devuid=$(blkid -o value -s UUID "$devname")
                [ -n "$devuid" ] && grep -qs "\<$devuid\>" /var/lib/live/boot/devices-already-tried-to-mount && continue
+
+               for _PARAMETER in ${LIVE_BOOT_CMDLINE}
+               do
+                       case "${_PARAMETER}" in
+                               forcefsck)
+                                       FORCEFSCK="true"
+                                       ;;
+                       esac
+               done
+
+               if [ "${PERSISTENCE_FSCK}" = "true" ] ||  [ "${PERSISTENCE_FSCK}" = "yes" ] || [ "${FORCEFSCK}" = "true" ]
+               then
+                       force=""
+                       if [ "$FORCEFSCK" = "true" ]
+                       then
+                               force="-f"
+                       fi
+
+                       fix="-a"
+                       if [ "$FSCKFIX" = "true" ] || [ "$FSCKFIX" = "yes" ]
+                       then
+                               fix="-y"
+                       fi
+
+                       fsck $fix $force ${devname} >> fsck.log 2>&1
+               fi
+
                mount -t ${fstype} -o ro,noatime "${devname}" ${mountpoint} || continue
                [ -n "$devuid" ] && echo "$devuid" >> /var/lib/live/boot/devices-already-tried-to-mount
 
index e6bc73f..d49f578 100644 (file)
@@ -50,6 +50,14 @@ Disable support for booting from USB devices.  If set to '\fIy\fR' mkinitramfs w
 \fBMINIMAL\fR=[\fIy\fR|\fIn\fR]
 Build a minimal initramfs.  If set to '\fIy\fR' mkinitramfs will build an initramfs without some udev scripts and without rsync.
 
+.TP
+\fBPERSISTENCE_FSCK\fR=[\fItrue\fR|\fIfalse\fR]
+Run fsck on persistance filesystem on boot. Will attempt to repair errors. The execution log will be saved in /var/log/live/fsck.log.
+
+.TP
+\fBFSCKFIX\fR=[\fItrue\fR|\fIfalse\fR]
+If PERSISTENCE_FSCK or forcefsck are set, will pass -y to fsck to stop it from asking questions interactively and assume yes to all queries.
+
 .SH OPTIONS
 \fBlive\-boot\fR currently features the following parameters.
 .\" FIXME
@@ -93,6 +101,8 @@ Target <target-name>
   # Wthreads or MaxConnections
 .IP "\fBfindiso\fR=\fI/PATH/TO/IMAGE\fI" 4
 Look for the specified ISO file on all disks where it usually looks for the .squashfs file (so you don't have to know the device name as in fromiso=....).
+.IP "\fBforcefsck\fR" 4
+Run fsck on persistance filesystem on boot. Will attempt to repair errors. The execution log will be saved in /var/log/live/fsck.log.
 .IP "\fBfromiso\fR=\fI/PATH/TO/IMAGE\fI" 4
 Use a filesystem from within an ISO image that's available on live-media.
 .IP "\fBignore_uuid\fR" 4