rootfs-block/module-setup.sh: add support for xfs / reiserfs separate journal device
authorHarald Hoyer <harald@redhat.com>
Thu, 26 Jul 2012 15:00:47 +0000 (17:00 +0200)
committerHarald Hoyer <harald@redhat.com>
Thu, 26 Jul 2012 15:00:47 +0000 (17:00 +0200)
xfs and reiserfs (among other) supports storing journal data to a
separate device. Unfortunately, XFS requires this information to boot
properly (reiserfs can embed the information in its metadata but you
might want to override it).

Frederic Crozat <fcrozat@suse.com>

modules.d/95rootfs-block/module-setup.sh

index 243a174..4d87fab 100755 (executable)
@@ -2,6 +2,47 @@
 # -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
 # ex: ts=8 sw=4 sts=4 et filetype=sh
 
+search_option() {
+    rootopts=$1
+    option=$2
+    local OLDIFS="$IFS"
+    IFS=,
+    set -- $rootopts
+    IFS="$OLDIFS"
+    while [ $# -gt 0 ]; do
+        case $1 in
+            $option=*)
+                echo ${1#${option}=}
+                break
+        esac
+        shift
+    done
+}
+
+check() {
+        rootopts="defaults"
+        while read dev mp fs opts dump fsck; do
+            # skip comments
+            [ "${dev%%#*}" != "$dev" ] && continue
+
+            if [ "$mp" = "/" ]; then
+                # sanity - determine/fix fstype
+                rootfs=$(find_mp_fstype /)
+                rootfs=${rootfs:-$fs}
+                rootopts=$opts
+                break
+            fi
+        done < "$NEWROOT/etc/fstab"
+
+        [ "$rootfs" = "reiserfs" ] && journaldev=$(search_option $rootopts "jdev")
+        [ "$rootfs" = "xfs" ] && journaldev=$(search_option $rootopts "logdev")
+        if [ -n "$journaldev" ]; then
+            echo "root.journaldev=$journaldev" >> "${initdir}/etc/cmdline.d/95root-jurnaldev.conf"
+        fi
+    return 0
+
+}
+
 depends() {
     echo fs-lib
 }