]> git.ipfire.org Git - thirdparty/dracut.git/commitdiff
rootfs-block/mount-root: remount root with /etc/fstab filesystem options
authorHarald Hoyer <harald@redhat.com>
Thu, 26 Nov 2009 10:15:59 +0000 (11:15 +0100)
committerHarald Hoyer <harald@redhat.com>
Thu, 26 Nov 2009 18:12:10 +0000 (19:12 +0100)
dracut.8
modules.d/95rootfs-block/mount-root.sh
modules.d/99base/init

index cb9bedd9b77a9881feb3e8de24a56144c6c57ead..851a5ced997ee51141733e0425a2db18734450fa 100644 (file)
--- a/dracut.8
+++ b/dracut.8
@@ -111,7 +111,14 @@ specify e.g. \fI/dev/sda1\fR or
 "auto" if not specified, e.g. \fIrootfstype=ext3\fR
 .TP
 .B rootflags=<mount options>
-specify additional mount options for the root filesystem
+specify additional mount options for the root filesystem. If not set, /etc/fstab
+of the real root will be parsed for special mount options and mounted 
+accordingly.
+.TP
+.B rd_NO_FSTAB
+do not honor special mount options for the root filesystem found in 
+/etc/fstab of the real root.
+
 .SH I18N
 e.g. LANG=en_US.UTF-8 SYSFONT=latarcyrheb-sun16 KEYTABLE=de-latin1-nodeadkeys
 .TP
index 10b93117e724549e72d825adfee0ff85fb3af3ba..8c3b5867772c761ce63149083a0c5fc00047367d 100755 (executable)
@@ -1,5 +1,33 @@
 #!/bin/sh
 
+. /lib/dracut-lib.sh
+
 if [ -n "$root" -a -z "${root%%block:*}" ]; then
-    mount -t ${fstype:-auto} -o "$rflags" "${root#block:}" "$NEWROOT" && ROOTFS_MOUNTED=yes
+    mount -t ${fstype:-auto} -o "$rflags" "${root#block:}" "$NEWROOT" \
+        && ROOTFS_MOUNTED=yes
+
+    if ! getarg rd_NO_FSTAB \
+      && ! getarg rootflags \
+      && [ -f "$NEWROOT/etc/fstab" ] \
+      && ! [ -L "$NEWROOT/etc/fstab" ]; then
+        # if $NEWROOT/etc/fstab contains special mount options for 
+        # the root filesystem,
+        # remount it with the proper options
+       rootfs="auto"
+       rootopts="defaults"
+       while read dev mp fs opts rest; do 
+            if [ "$mp" = "/" ]; then
+               rootfs=$fs
+               rootopts=$opts
+               break
+            fi
+       done < "$NEWROOT/etc/fstab"
+
+       if [ "$rootopts" != "defaults" ]; then
+            umount $NEWROOT
+            info "Remounting ${root#block:} with -o $rflags,$rootopts"
+            mount -t "$rootfs" -o "$rflags","$rootopts" \
+                "${root#block:}" "$NEWROOT" 2>&1 | vinfo
+       fi
+    fi
 fi
index d5f78320b35f55f16695ad2a85881929a4b4f0f2..9d85f69b20dcf4210edd4c6b104de90ec10ff76b 100755 (executable)
@@ -282,3 +282,5 @@ exec switch_root "$NEWROOT" "$INIT" $initargs || {
     echo "file a bug against dracut."
     emergency_shell
 }
+# vim:ts=8:sw=4:sts=4:et
+