From 683095685ccdd4175b75293540aabe239d03a6bb Mon Sep 17 00:00:00 2001 From: Chas Williams Date: Mon, 12 Mar 2018 15:51:22 +0000 Subject: [PATCH] Add back persistance fsck option 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 | 4 +++- components/9990-misc-helpers.sh | 28 ++++++++++++++++++++++++++++ manpages/en/live-boot.7 | 10 ++++++++++ 3 files changed, 41 insertions(+), 1 deletion(-) diff --git a/components/9990-main.sh b/components/9990-main.sh index bab0bd7..4a965d5 100755 --- a/components/9990-main.sh +++ b/components/9990-main.sh @@ -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 ) } diff --git a/components/9990-misc-helpers.sh b/components/9990-misc-helpers.sh index e21fced..a565ed5 100755 --- a/components/9990-misc-helpers.sh +++ b/components/9990-misc-helpers.sh @@ -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 diff --git a/manpages/en/live-boot.7 b/manpages/en/live-boot.7 index e6bc73f..d49f578 100644 --- a/manpages/en/live-boot.7 +++ b/manpages/en/live-boot.7 @@ -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 # 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 -- 2.1.4