From 743d4c0b3e7b7836bb5487a84f10a0df1e623c62 Mon Sep 17 00:00:00 2001 From: Rowan Wookey Date: Tue, 13 Oct 2020 11:55:26 +0100 Subject: [PATCH 1/2] Automatically fsck data paritition on boot By default this runs e2fsck on the data partition on boot before mounting. A forced fsck can be enabled by adding `fsck.mode=force` to /boot/cmdline.txt Moved from https://github.com/ccrisan/motioneyeos/pull/2464 --- board/common/overlay/etc/init.d/S00datapart | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/board/common/overlay/etc/init.d/S00datapart b/board/common/overlay/etc/init.d/S00datapart index 4bdc300bc0..35b073d5a4 100755 --- a/board/common/overlay/etc/init.d/S00datapart +++ b/board/common/overlay/etc/init.d/S00datapart @@ -41,7 +41,16 @@ case "$1" in msg_done "${disk_dev}" - test -b ${data_dev} && exit 0 + if [ -b ${data_dev} ] + then + if grep -q 'fsck.mode=force' /proc/cmdline + then + /sbin/e2fsck -fy ${data_dev} + else + /sbin/e2fsck -y ${data_dev} + fi + exit 0 + fi msg_begin "Creating data partition" data_start=$((DATA_OFFS * 2048)) From 2bd433b1540a2ba3ba43ce14b455f74d4e433897 Mon Sep 17 00:00:00 2001 From: Calin Crisan Date: Sun, 25 Oct 2020 11:07:50 +0200 Subject: [PATCH 2/2] /etc/init.d/S00datapart: show fsck log only on errors --- board/common/overlay/etc/init.d/S00datapart | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/board/common/overlay/etc/init.d/S00datapart b/board/common/overlay/etc/init.d/S00datapart index 35b073d5a4..e3e2725c72 100755 --- a/board/common/overlay/etc/init.d/S00datapart +++ b/board/common/overlay/etc/init.d/S00datapart @@ -41,13 +41,18 @@ case "$1" in msg_done "${disk_dev}" - if [ -b ${data_dev} ] - then - if grep -q 'fsck.mode=force' /proc/cmdline - then - /sbin/e2fsck -fy ${data_dev} + if [[ -b ${data_dev} ]]; then + msg_begin "Checking data filesystem" + if grep -q 'fsck.mode=force' /proc/cmdline; then + /sbin/e2fsck -fy ${data_dev} &> /tmp/fsck.log + elif ! grep -q 'fsck.mode=skip' /proc/cmdline; then + /sbin/e2fsck -y ${data_dev} &> /tmp/fsck.log + fi + if [[ $? == 0 ]]; then + msg_done else - /sbin/e2fsck -y ${data_dev} + msg_fail + cat /tmp/fsck.log fi exit 0 fi