]> git.ipfire.org Git - thirdparty/dracut.git/commitdiff
trigger root mount via udev rules
authorHarald Hoyer <harald@redhat.com>
Mon, 9 Mar 2009 11:55:02 +0000 (12:55 +0100)
committerHarald Hoyer <harald@redhat.com>
Mon, 9 Mar 2009 12:08:12 +0000 (13:08 +0100)
modules.d/90dmsetup/check [new file with mode: 0644]
modules.d/90dmsetup/install [new file with mode: 0755]
modules.d/99base/init

diff --git a/modules.d/90dmsetup/check b/modules.d/90dmsetup/check
new file mode 100644 (file)
index 0000000..fadb6d7
--- /dev/null
@@ -0,0 +1,7 @@
+#!/bin/sh
+
+[[ $dracutfunctions ]] && . $dracutfunctions
+
+[[ -x /lib/udev/devkit-disks-dm-export ]] || exit 1
+
+exit 0
diff --git a/modules.d/90dmsetup/install b/modules.d/90dmsetup/install
new file mode 100755 (executable)
index 0000000..1a64faf
--- /dev/null
@@ -0,0 +1,8 @@
+#!/bin/bash
+# FIXME: would be nice if we didn't have to know which rules to grab....
+# ultimately, /lib/initramfs/rules.d or somesuch which includes links/copies
+# of the rules we want so that we just copy those in would be best
+dracut_install /lib/udev/devkit-disks-dm-export /lib/udev/devkit-disks-part-id
+
+inst_rules 95-devkit-disks.rules
+    
index 12ca3711a0f675b6a158acfeba0b3344144b4228..8f0ece16aa5a959841de18ad06c880bda9822f79 100755 (executable)
@@ -31,6 +31,8 @@ source_all() {
 echo "Starting initrd..."
 export PATH=/sbin:/bin:/usr/sbin:/usr/bin
 export TERM=linux
+NEWROOT="/sysroot"
+
 trap "emergency_shell" 0
 
 mknod /dev/null c 1 3
@@ -52,26 +54,66 @@ mount -t devpts -o gid=5,mode=620 /dev/pts /dev/pts >/dev/null 2>&1
 getarg 'break=pre-udev' && emergency_shell
 source_all pre-udev
 
+
+[ "$root" ] || {
+    root=$(getarg root=)
+    case $root in
+       LABEL=*) root=${root#LABEL=}
+            root="$(echo $root |sed 's,/,\\x2f,g')"
+            root="/dev/disk/by-label/${root}" ;;
+        UUID=*) root="/dev/disk/by-uuid/${root#UUID=}" ;;
+        '') echo "Warning: no root specified"
+            root="/dev/sda1" ;;
+    esac
+}
+
+[ "$rflags" ] || {
+    if rflags="$(getarg rootflags=)"; then
+       getarg rw && rflags="${rflags},rw" || rflags="${rflags},ro"
+    else
+       getarg rw && rflags=rw || rflags=ro
+    fi
+}
+
+[ "$fstype" ] || {
+    fstype="$(getarg rootfstype=)" && fstype="-t ${fstype}"
+}
+
+resume=$(getarg resume=) && ! getarg noresume && [ -b "$resume" ] && {
+    # parsing the output of ls is Bad, but until there is a better way...
+    (
+       echo -e 'NAME=="'${resume#/dev/}'", RUN+="/bin/sh -c \047 echo %M:%m > /sys/power/resume \047 "'
+       echo -e 'SYMLINK=="'${resume#/dev/}'", RUN+="/bin/sh -c \047 echo %M:%m > /sys/power/resume \047 "'
+    ) >> /lib/udev/rules.d/99-resume.rules
+}
+
+(
+ echo -e ' NAME=="'${root#/dev/}'", RUN+="/bin/sh -c \047 mount '$fstype' -o '$rflags' '$root' '$NEWROOT' \047 " '
+ echo -e ' SYMLINK=="'${root#/dev/}'", RUN+="/bin/sh -c \047 mount '$fstype' -o '$rflags' '$root' '$NEWROOT' \047 " '
+) >> /lib/udev/rules.d/99-mount.rules
+
 # start up udev and trigger cold plugs
 udevd --daemon
 udevadm trigger >/dev/null 2>&1
 udevadm settle --timeout=30 >/dev/null 2>&1
 
-NEWROOT="/sysroot"
 # pre-mount happens before we try to mount the root filesystem,
 # and happens once.
 getarg 'break=pre-mount' && emergency_shell
 source_all pre-mount
 getarg 'break=mount' && emergency_shell
+
 # mount scripts actually try to mount the root filesystem, and may
 # be sourced any number of times. As soon as one suceeds, no more are sourced.
 i=0
 while :; do
+    grep -q '/sysroot' /proc/mounts && break;
+
     for f in /mount/*.sh; do
-       [ -x "$f" ] && . "$f";
-       [ "$ROOTFS_MOUNTED" ] && break;
+       [ -x "$f" ] && . "$f";
+       [ "$ROOTFS_MOUNTED" ] && break;
     done
-    [ "$ROOTFS_MOUNTED" ] && break;
+
     sleep 1
     i=$(($i+1))
     (