Blame 0005-new-option-rd.skipfsck-to-skip-fsck-for-rootfs-and-u.patch

Harald Hoyer c4a5a0
From 9fb01d49d6fa9772caed7eaa184072ff365b7d80 Mon Sep 17 00:00:00 2001
Harald Hoyer c4a5a0
From: =?UTF-8?q?Amadeusz=20=C5=BBo=C5=82nowski?= <aidecoe@aidecoe.name>
Harald Hoyer c4a5a0
Date: Fri, 29 Jun 2012 13:58:20 +0200
Harald Hoyer c4a5a0
Subject: [PATCH] new option: rd.skipfsck to skip fsck for rootfs and /usr
Harald Hoyer c4a5a0
Harald Hoyer c4a5a0
---
Harald Hoyer c4a5a0
 dracut.cmdline.7.asc                   |    4 ++++
Harald Hoyer c4a5a0
 modules.d/95rootfs-block/mount-root.sh |    4 +++-
Harald Hoyer c4a5a0
 modules.d/98usrmount/mount-usr.sh      |   15 ++++++++-------
Harald Hoyer c4a5a0
 3 files changed, 15 insertions(+), 8 deletions(-)
Harald Hoyer c4a5a0
Harald Hoyer c4a5a0
diff --git a/dracut.cmdline.7.asc b/dracut.cmdline.7.asc
Harald Hoyer c4a5a0
index 5669700..3bfb53a 100644
Harald Hoyer c4a5a0
--- a/dracut.cmdline.7.asc
Harald Hoyer c4a5a0
+++ b/dracut.cmdline.7.asc
Harald Hoyer c4a5a0
@@ -75,6 +75,10 @@ resume=/dev/disk/by-uuid/3f5ad593-4546-4a94-a374-bcfb68aa11f7
Harald Hoyer c4a5a0
 resume=UUID=3f5ad593-4546-4a94-a374-bcfb68aa11f7
Harald Hoyer c4a5a0
 ----
Harald Hoyer c4a5a0
 
Harald Hoyer c4a5a0
+**rd.skipfsck**::
Harald Hoyer c4a5a0
+    skip fsck for rootfs and _/usr_.  If you're mounting _/usr_ read-only and
Harald Hoyer c4a5a0
+    the init system performs fsck before remount, you might want to use this
Harald Hoyer c4a5a0
+    option to avoid duplication.
Harald Hoyer c4a5a0
 
Harald Hoyer c4a5a0
 **rd.usrmount.ro**:
Harald Hoyer c4a5a0
     force mounting _/usr_ read-only.  Use this option if your init system
Harald Hoyer c4a5a0
diff --git a/modules.d/95rootfs-block/mount-root.sh b/modules.d/95rootfs-block/mount-root.sh
Harald Hoyer c4a5a0
index 2cae526..9109638 100755
Harald Hoyer c4a5a0
--- a/modules.d/95rootfs-block/mount-root.sh
Harald Hoyer c4a5a0
+++ b/modules.d/95rootfs-block/mount-root.sh
Harald Hoyer c4a5a0
@@ -103,7 +103,9 @@ mount_root() {
Harald Hoyer c4a5a0
     # printf '%s %s %s %s 1 1 \n' "$esc_root" "$NEWROOT" "$rootfs" "$rflags" >/etc/fstab
Harald Hoyer c4a5a0
 
Harald Hoyer c4a5a0
     ran_fsck=0
Harald Hoyer c4a5a0
-    if [ -z "$fastboot" -a "$READONLY" != "yes" ] && ! strstr "${rflags},${rootopts}" _netdev; then
Harald Hoyer c4a5a0
+    if [ -z "$fastboot" -a "$READONLY" != "yes" ] && \
Harald Hoyer c4a5a0
+            ! strstr "${rflags},${rootopts}" _netdev && \
Harald Hoyer c4a5a0
+            ! getargbool 0 rd.skipfsck; then
Harald Hoyer c4a5a0
         umount "$NEWROOT"
Harald Hoyer c4a5a0
         fsck_single "${root#block:}" "$rootfs" "$rflags" "$fsckoptions"
Harald Hoyer c4a5a0
         _ret=$?
Harald Hoyer c4a5a0
diff --git a/modules.d/98usrmount/mount-usr.sh b/modules.d/98usrmount/mount-usr.sh
Harald Hoyer c4a5a0
index 748ac01..5798777 100755
Harald Hoyer c4a5a0
--- a/modules.d/98usrmount/mount-usr.sh
Harald Hoyer c4a5a0
+++ b/modules.d/98usrmount/mount-usr.sh
Harald Hoyer c4a5a0
@@ -60,14 +60,15 @@ mount_usr()
Harald Hoyer c4a5a0
 
Harald Hoyer c4a5a0
     if [ "x$_usr_found" != "x" ]; then
Harald Hoyer c4a5a0
         # we have to mount /usr
Harald Hoyer c4a5a0
-        if [ "0" != "${_passno:-0}" ]; then
Harald Hoyer c4a5a0
-            fsck_usr "$_dev" "$_fs" "$_opts"
Harald Hoyer c4a5a0
-        else
Harald Hoyer c4a5a0
-            :
Harald Hoyer c4a5a0
+        _fsck_ret=0
Harald Hoyer c4a5a0
+        if ! getargbool 0 rd.skipfsck; then
Harald Hoyer c4a5a0
+            if [ "0" != "${_passno:-0}" ]; then
Harald Hoyer c4a5a0
+                fsck_usr "$_dev" "$_fs" "$_opts"
Harald Hoyer c4a5a0
+                _fsck_ret=$?
Harald Hoyer c4a5a0
+                echo $_fsck_ret >/run/initramfs/usr-fsck
Harald Hoyer c4a5a0
+            fi
Harald Hoyer c4a5a0
         fi
Harald Hoyer c4a5a0
-        _ret=$?
Harald Hoyer c4a5a0
-        echo $_ret >/run/initramfs/usr-fsck
Harald Hoyer c4a5a0
-        if [ $_ret -ne 255 ]; then
Harald Hoyer c4a5a0
+        if [ $_fsck_ret -ne 255 ]; then
Harald Hoyer c4a5a0
             if getargbool 0 rd.usrmount.ro; then
Harald Hoyer c4a5a0
                 info "Mounting /usr (read-only forced)"
Harald Hoyer c4a5a0
                 mount -r "$NEWROOT/usr" 2>&1 | vinfo