Blob Blame History Raw
From 3cc4c8ba9b43ff646701d4236c1a70860c16d02c Mon Sep 17 00:00:00 2001
From: Harald Hoyer <harald@redhat.com>
Date: Thu, 26 Jul 2012 17:00:47 +0200
Subject: [PATCH] rootfs-block/module-setup.sh: add support for xfs / reiserfs
 separate journal device

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 | 41 ++++++++++++++++++++++++++++++++
 1 file changed, 41 insertions(+)

diff --git a/modules.d/95rootfs-block/module-setup.sh b/modules.d/95rootfs-block/module-setup.sh
index 243a174..4d87fab 100755
--- a/modules.d/95rootfs-block/module-setup.sh
+++ b/modules.d/95rootfs-block/module-setup.sh
@@ -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
 }