]> git.ipfire.org Git - thirdparty/dracut.git/commitdiff
add module for rootfs mounting via udev rules
authorHarald Hoyer <harald@redhat.com>
Tue, 24 Mar 2009 10:36:56 +0000 (11:36 +0100)
committerHarald Hoyer <harald@redhat.com>
Tue, 24 Mar 2009 10:36:56 +0000 (11:36 +0100)
modules.d/95rootfs-block-udev/genrules.sh [new file with mode: 0755]
modules.d/95rootfs-block-udev/install [new file with mode: 0755]
modules.d/95rootfs-block-udev/parse-root-opts.sh [new file with mode: 0755]

diff --git a/modules.d/95rootfs-block-udev/genrules.sh b/modules.d/95rootfs-block-udev/genrules.sh
new file mode 100755 (executable)
index 0000000..d4e226c
--- /dev/null
@@ -0,0 +1,15 @@
+
+resume=$(getarg resume=) && ! getarg noresume && [ -b "$resume" ] && {
+    # parsing the output of ls is Bad, but until there is a better way...
+    (
+       echo -e 'KERNEL=="'${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 "'
+    ) >> /etc/udev/rules.d/99-resume.rules
+}
+
+(
+ echo -e 'KERNEL=="'${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 " '
+) >> /etc/udev/rules.d/99-mount.rules
+
+
diff --git a/modules.d/95rootfs-block-udev/install b/modules.d/95rootfs-block-udev/install
new file mode 100755 (executable)
index 0000000..641e7df
--- /dev/null
@@ -0,0 +1,3 @@
+#!/bin/sh
+inst_hook pre-udev 10 "$moddir/parse-root-opts.sh"
+inst_hook pre-udev 20 "$moddir/genrules.sh"
diff --git a/modules.d/95rootfs-block-udev/parse-root-opts.sh b/modules.d/95rootfs-block-udev/parse-root-opts.sh
new file mode 100755 (executable)
index 0000000..473c34d
--- /dev/null
@@ -0,0 +1,27 @@
+#!/bin/sh
+if resume=$(getarg resume=) && ! getarg noresume; then 
+    export resume
+    echo "$resume" >/.resume
+else
+    unset resume
+fi
+
+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
+
+if rflags="$(getarg rootflags=)"; then
+    getarg rw && rflags="${rflags},rw" || rflags="${rflags},ro"
+else
+    getarg rw && rflags=rw || rflags=ro
+fi
+
+fstype="$(getarg rootfstype=)" && fstype="-t ${fstype}"
+
+export fstype rflags root