dracut/0016-rootfs-block-mount-root.sh-warn-if-ro-mount-failed-a.patch

57 lines
2.3 KiB
Diff
Raw Normal View History

From 5113a3efff522664b85a75d67f674d218035696c Mon Sep 17 00:00:00 2001
From: Harald Hoyer <harald@redhat.com>
Date: Sat, 30 Jun 2012 12:15:42 +0200
Subject: [PATCH] rootfs-block/mount-root.sh: warn if ro mount failed and
remount
remount the root filesystem, if it was not unmounted
---
modules.d/95rootfs-block/mount-root.sh | 18 ++++++++++++++----
1 file changed, 14 insertions(+), 4 deletions(-)
diff --git a/modules.d/95rootfs-block/mount-root.sh b/modules.d/95rootfs-block/mount-root.sh
index 932571a..e61b0e8 100755
--- a/modules.d/95rootfs-block/mount-root.sh
+++ b/modules.d/95rootfs-block/mount-root.sh
@@ -29,7 +29,10 @@ mount_root() {
local _ret
# sanity - determine/fix fstype
rootfs=$(det_fs "${root#block:}" "$fstype")
- mount -t ${rootfs} -o "$rflags",ro "${root#block:}" "$NEWROOT"
+ while ! mount -t ${rootfs} -o "$rflags",ro "${root#block:}" "$NEWROOT"; do
+ warn "Failed to mount -t ${rootfs} -o $rflags,ro ${root#block:} $NEWROOT"
+ fsck_ask_err
+ done
READONLY=
fsckoptions=
@@ -106,9 +109,11 @@ mount_root() {
# printf '%s %s %s %s 1 1 \n' "$esc_root" "$NEWROOT" "$rootfs" "$rflags" >/etc/fstab
ran_fsck=0
- if [ "$rootfsck" != "0" -a -z "$fastboot" -a "$READONLY" != "yes" ] && \
+ if fsck_able "$rootfs" && \
+ [ "$rootfsck" != "0" -a -z "$fastboot" -a "$READONLY" != "yes" ] && \
! strstr "${rflags}" _netdev && \
! getargbool 0 rd.skipfsck; then
+ umount "$NEWROOT"
fsck_single "${root#block:}" "$rootfs" "$rflags" "$fsckoptions"
_ret=$?
[ $_ret -ne 255 ] && echo $_ret >/run/initramfs/root-fsck
@@ -117,8 +122,13 @@ mount_root() {
echo "${root#block:} $NEWROOT $rootfs ${rflags:-defaults} 0 $rootfsck" >> /etc/fstab
- info "Remounting ${root#block:} with -o ${rflags}"
- mount -o remount "$NEWROOT" 2>&1 | vinfo
+ if ! ismounted "$NEWROOT"; then
+ info "Mounting ${root#block:} with -o ${rflags}"
+ mount "$NEWROOT" 2>&1 | vinfo
+ else
+ info "Remounting ${root#block:} with -o ${rflags}"
+ mount -o remount "$NEWROOT" 2>&1 | vinfo
+ fi
[ -f "$NEWROOT"/forcefsck ] && rm -f "$NEWROOT"/forcefsck 2>/dev/null
[ -f "$NEWROOT"/.autofsck ] && rm -f "$NEWROOT"/.autofsck 2>/dev/null