98usrmount: force mounting /usr read-only option (rd.usrmount.ro)
PATCH 1/4 98usrmount: force mounting /usr read-only option (rd.usrmount.ro)
--- dracut.cmdline.7.asc | 5 +++++ modules.d/98usrmount/mount-usr.sh | 9 +++++++-- 2 files changed, 12 insertions(+), 2 deletions(-)
dracut.cmdline.7.asc +5 -0
@@ -76,6 +76,11 @@ resume=UUID=3f5ad593-4546-4a94-a374-bcfb68aa11f7 ---- +**rd.usrmount.ro**: + force mounting _/usr_ read-only. Use this option if your init system + performs remount of _/usr_ the same as it does with rootfs. + + Misc ~~~~ **rd.driver.blacklist=**_<drivername>[,<drivername>,...]_::
modules.d/98usrmount/mount-usr.sh +7 -2
@@ -68,8 +68,13 @@ mount_usr() _ret=$? echo $_ret >/run/initramfs/usr-fsck if [ $_ret -ne 255 ]; then - info "Mounting /usr" - mount "$NEWROOT/usr" 2>&1 | vinfo + if getargbool 0 rd.usrmount.ro; then + info "Mounting /usr (read-only forced)" + mount -r "$NEWROOT/usr" 2>&1 | vinfo + else + info "Mounting /usr" + mount "$NEWROOT/usr" 2>&1 | vinfo + fi fi fi }
Signature · 1 line
1.7.8.6
PATCH 2/4 99base: don't require fs-lib to detect rootfstype
In reply to a message not in the archiveIf fs-lib is not included, no rootfs autodetection is performed.
--- modules.d/99base/mount-hook.sh | 4 +++- 1 files changed, 3 insertions(+), 1 deletions(-)
modules.d/99base/mount-hook.sh +3 -1
@@ -4,7 +4,9 @@ PATH=/usr/sbin:/usr/bin:/sbin:/bin type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh -type det_fs >/dev/null 2>&1 || . /lib/fs-lib.sh +type det_fs >/dev/null 2>&1 || [ -f /lib/fs-lib.sh ] && . /lib/fs-lib.sh +# If fs-lib is not included use following det_fs replacement. +type det_fs >/dev/null 2>&1 || det_fs() { echo "${2:-auto}"; } mountpoint="$1" ismounted "$mountpoint" && exit 0
Signature · 1 line
1.7.8.6
PATCH 3/4 new option: rd.skipfsck to skip fsck for rootfs and /usr
In reply to a message not in the archive--- dracut.cmdline.7.asc | 4 ++++ modules.d/95rootfs-block/mount-root.sh | 4 +++- modules.d/98usrmount/mount-usr.sh | 15 ++++++++------- 3 files changed, 15 insertions(+), 8 deletions(-)
dracut.cmdline.7.asc +4 -0
@@ -75,6 +75,10 @@ resume=/dev/disk/by-uuid/3f5ad593-4546-4a94-a374-bcfb68aa11f7 resume=UUID=3f5ad593-4546-4a94-a374-bcfb68aa11f7 ---- +**rd.skipfsck**:: + skip fsck for rootfs and _/usr_. If you're mounting _/usr_ read-only and + the init system performs fsck before remount, you might want to use this + option to avoid duplication. **rd.usrmount.ro**: force mounting _/usr_ read-only. Use this option if your init system
modules.d/95rootfs-block/mount-root.sh +3 -1
@@ -103,7 +103,9 @@ mount_root() { # printf '%s %s %s %s 1 1 \n' "$esc_root" "$NEWROOT" "$rootfs" "$rflags" >/etc/fstab ran_fsck=0 - if [ -z "$fastboot" -a "$READONLY" != "yes" ] && ! strstr "${rflags},${rootopts}" _netdev; then + if [ -z "$fastboot" -a "$READONLY" != "yes" ] && \ + ! strstr "${rflags},${rootopts}" _netdev && \ + ! getargbool 0 rd.skipfsck; then umount "$NEWROOT" fsck_single "${root#block:}" "$rootfs" "$rflags" "$fsckoptions" _ret=$?
modules.d/98usrmount/mount-usr.sh +8 -7
@@ -60,14 +60,15 @@ mount_usr() if [ "x$_usr_found" != "x" ]; then # we have to mount /usr - if [ "0" != "${_passno:-0}" ]; then - fsck_usr "$_dev" "$_fs" "$_opts" - else - : + _fsck_ret=0 + if ! getargbool 0 rd.skipfsck; then + if [ "0" != "${_passno:-0}" ]; then + fsck_usr "$_dev" "$_fs" "$_opts" + _fsck_ret=$? + echo $_fsck_ret >/run/initramfs/usr-fsck + fi fi - _ret=$? - echo $_ret >/run/initramfs/usr-fsck - if [ $_ret -ne 255 ]; then + if [ $_fsck_ret -ne 255 ]; then if getargbool 0 rd.usrmount.ro; then info "Mounting /usr (read-only forced)" mount -r "$NEWROOT/usr" 2>&1 | vinfo
Signature · 1 line
1.7.8.6
PATCH 4/4 95rootfs-block: skip checks rel. to fsck if rd.skipfsck is supplied
In reply to a message not in the archive--- modules.d/95rootfs-block/mount-root.sh | 29 ++++++++++++++++------------- 1 files changed, 16 insertions(+), 13 deletions(-)
modules.d/95rootfs-block/mount-root.sh +16 -13
@@ -54,20 +54,23 @@ mount_root() { fsckoptions=$(cat "$NEWROOT"/fsckoptions) fi - if [ -f "$NEWROOT"/forcefsck ] || getargbool 0 forcefsck ; then - fsckoptions="-f $fsckoptions" - elif [ -f "$NEWROOT"/.autofsck ]; then - [ -f "$NEWROOT"/etc/sysconfig/autofsck ] && . "$NEWROOT"/etc/sysconfig/autofsck - if [ "$AUTOFSCK_DEF_CHECK" = "yes" ]; then - AUTOFSCK_OPT="$AUTOFSCK_OPT -f" - fi - if [ -n "$AUTOFSCK_SINGLEUSER" ]; then - warn "*** Warning -- the system did not shut down cleanly. " - warn "*** Dropping you to a shell; the system will continue" - warn "*** when you leave the shell." - emergency_shell + if ! getargbool 0 rd.skipfsck; then + if [ -f "$NEWROOT"/forcefsck ] || getargbool 0 forcefsck ; then + fsckoptions="-f $fsckoptions" + elif [ -f "$NEWROOT"/.autofsck ]; then + [ -f "$NEWROOT"/etc/sysconfig/autofsck ] && \ + . "$NEWROOT"/etc/sysconfig/autofsck + if [ "$AUTOFSCK_DEF_CHECK" = "yes" ]; then + AUTOFSCK_OPT="$AUTOFSCK_OPT -f" + fi + if [ -n "$AUTOFSCK_SINGLEUSER" ]; then + warn "*** Warning -- the system did not shut down cleanly. " + warn "*** Dropping you to a shell; the system will continue" + warn "*** when you leave the shell." + emergency_shell + fi + fsckoptions="$AUTOFSCK_OPT $fsckoptions" fi - fsckoptions="$AUTOFSCK_OPT $fsckoptions" fi rootopts=
Signature · 1 line
1.7.8.6