* [PATCH 1/2] [99fs-lib] Create generic mount framework
@ 2013-04-11 15:39 Dennis Schridde
[not found] ` <1365694762-7806-1-git-send-email-devurandom-hi6Y0CQ0nG0@public.gmane.org>
0 siblings, 1 reply; 9+ messages in thread
From: Dennis Schridde @ 2013-04-11 15:39 UTC (permalink / raw)
To: initramfs-u79uwXL29TY76Z2rM5mHXA; +Cc: Dennis Schridde
* Utilises fstab.{early,late} files in /etc
* Provides fs_add_mount function to mount in pre-mount (early) and pre-pivot (late) phases
* Code to mount a fstab file is moved over from 95fstab-sys
---
modules.d/95fstab-sys/mount-sys.sh | 22 ---------------------
modules.d/99fs-lib/fs-lib.sh | 39 ++++++++++++++++++++++++++++++++++++++
modules.d/99fs-lib/module-setup.sh | 3 +++
modules.d/99fs-lib/mount-early.sh | 8 ++++++++
modules.d/99fs-lib/mount-late.sh | 8 ++++++++
5 files changed, 58 insertions(+), 22 deletions(-)
create mode 100755 modules.d/99fs-lib/mount-early.sh
create mode 100755 modules.d/99fs-lib/mount-late.sh
diff --git a/modules.d/95fstab-sys/mount-sys.sh b/modules.d/95fstab-sys/mount-sys.sh
index 12711a0..d2ed7cc 100755
--- a/modules.d/95fstab-sys/mount-sys.sh
+++ b/modules.d/95fstab-sys/mount-sys.sh
@@ -5,28 +5,6 @@
type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh
type det_fs >/dev/null 2>&1 || . /lib/fs-lib.sh
-fstab_mount() {
- local _dev _mp _fs _opts _dump _pass _rest
- test -e "$1" || return 1
- info "Mounting from $1"
- while read _dev _mp _fs _opts _dump _pass _rest; do
- [ -z "${_dev%%#*}" ] && continue # Skip comment lines
- ismounted $_mp && continue # Skip mounted filesystem
- if [ "$_pass" -gt 0 ] && ! strstr "$_opts" _netdev; then
- fsck_single "$_dev" "$_fs" "$_opts"
- fi
- _fs=$(det_fs "$_dev" "$_fs")
- info "Mounting $_dev"
- if [ -d "$NEWROOT/$_mp" ]; then
- mount -v -t $_fs -o $_opts $_dev "$NEWROOT/$_mp" 2>&1 | vinfo
- else
- [ -d "$_mp" ] || mkdir -p "$_mp"
- mount -v -t $_fs -o $_opts $_dev $_mp 2>&1 | vinfo
- fi
- done < $1
- return 0
-}
-
[ -f /etc/fstab ] && fstab_mount /etc/fstab
# prefer $NEWROOT/etc/fstab.sys over local /etc/fstab.sys
diff --git a/modules.d/99fs-lib/fs-lib.sh b/modules.d/99fs-lib/fs-lib.sh
index e1f3074..9e6abf6 100755
--- a/modules.d/99fs-lib/fs-lib.sh
+++ b/modules.d/99fs-lib/fs-lib.sh
@@ -248,3 +248,42 @@ write_fs_tab() {
systemctl --no-block start initrd-root-fs.target
fi
}
+
+# fstab_mount FSTAB
+# go through FSTAB and mount each line
+# cannot be used to mount rootfs for 40network, because it will not create /dev/root
+fstab_mount() {
+ local _dev _mp _fs _opts _dump _pass _rest
+ test -e "$1" || return 1
+ info "Mounting from $1"
+ while read _dev _mp _fs _opts _dump _pass _rest; do
+ [ -z "${_dev%%#*}" ] && continue # Skip comment lines
+ ismounted $_mp && continue # Skip mounted filesystem
+ if [ "$_pass" -gt 0 ] && ! strstr "$_opts" _netdev; then
+ fsck_single "$_dev" "$_fs" "$_opts"
+ fi
+ _fs=$(det_fs "$_dev" "$_fs")
+ info "Mounting $_dev"
+ if [ -d "$NEWROOT/$_mp" ]; then
+ mount -v -t $_fs -o $_opts $_dev "$NEWROOT/$_mp" 2>&1 | vinfo
+ else
+ [ -d "$_mp" ] || mkdir -p "$_mp"
+ mount -v -t $_fs -o $_opts $_dev $_mp 2>&1 | vinfo
+ fi
+ done < $1
+ return 0
+}
+
+# fs_add_mount PHASE FS MOUNTPOINT FSTYPE OPTIONS DUMP PASS
+# add line to fstab used by pre-mount (PHASE=early) or pre-pivot (PHASE=late) hook
+# FS is anything that could be found in the first column of fstab
+fs_add_mount() {
+ local phase="$1" fs="$2" mountpoint="$3" fstype="$4" options="$5" dump="$6" pass="$7"
+ [ "${fs}" ] || die "FS passed to $0 is empty"
+ [ "${mountpoint}" ] || die "Mountpoint passed to $0 is empty"
+ [ "${fstype}" ] || fstype=auto
+ [ "${options}" ] || options=defaults
+ [ "${dump}" ] || dump=0
+ [ "${pass}" ] || pass=0
+ echo "${fs} ${mountpoint} ${fstype} ${options} ${dump} ${pass}" >> /etc/fstab."${phase}"
+}
diff --git a/modules.d/99fs-lib/module-setup.sh b/modules.d/99fs-lib/module-setup.sh
index 637737e..1f8d528 100755
--- a/modules.d/99fs-lib/module-setup.sh
+++ b/modules.d/99fs-lib/module-setup.sh
@@ -60,6 +60,9 @@ install() {
inst "$moddir/fs-lib.sh" "/lib/fs-lib.sh"
> ${initdir}/etc/fstab.empty
+ inst_hook pre-mount 99 "$moddir/mount-early.sh"
+ inst_hook pre-pivot 99 "$moddir/mount-late.sh"
+
[[ "$nofscks" = "yes" ]] && return
if [[ "$fscks" = "${fscks#*[^ ]*}" ]]; then
diff --git a/modules.d/99fs-lib/mount-early.sh b/modules.d/99fs-lib/mount-early.sh
new file mode 100755
index 0000000..e11774a
--- /dev/null
+++ b/modules.d/99fs-lib/mount-early.sh
@@ -0,0 +1,8 @@
+#!/bin/sh
+# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
+# ex: ts=8 sw=4 sts=4 et filetype=sh
+
+type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh
+type det_fs >/dev/null 2>&1 || . /lib/fs-lib.sh
+
+[ -f /etc/fstab.early ] && fstab_mount /etc/fstab.early
diff --git a/modules.d/99fs-lib/mount-late.sh b/modules.d/99fs-lib/mount-late.sh
new file mode 100755
index 0000000..669fcd2
--- /dev/null
+++ b/modules.d/99fs-lib/mount-late.sh
@@ -0,0 +1,8 @@
+#!/bin/sh
+# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
+# ex: ts=8 sw=4 sts=4 et filetype=sh
+
+type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh
+type det_fs >/dev/null 2>&1 || . /lib/fs-lib.sh
+
+[ -f /etc/fstab.late ] && fstab_mount /etc/fstab.late
--
1.8.1.5
^ permalink raw reply related [flat|nested] 9+ messages in thread[parent not found: <1365694762-7806-1-git-send-email-devurandom-hi6Y0CQ0nG0@public.gmane.org>]
* [PATCH 2/2] [99fs-lib] Provide fs_mount_to_var utility function to parse /path:type:/dev,options style mountspecs [not found] ` <1365694762-7806-1-git-send-email-devurandom-hi6Y0CQ0nG0@public.gmane.org> @ 2013-04-11 15:39 ` Dennis Schridde [not found] ` <1365694762-7806-2-git-send-email-devurandom-hi6Y0CQ0nG0@public.gmane.org> 2013-04-11 15:48 ` [PATCH 1/2] [99fs-lib] Create generic mount framework Harald Hoyer 2013-05-17 16:17 ` [PATCH 1/2] [40network] Add variable parsing framework for network related variables Dennis Schridde 2 siblings, 1 reply; 9+ messages in thread From: Dennis Schridde @ 2013-04-11 15:39 UTC (permalink / raw) To: initramfs-u79uwXL29TY76Z2rM5mHXA; +Cc: Dennis Schridde --- modules.d/99fs-lib/fs-lib.sh | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/modules.d/99fs-lib/fs-lib.sh b/modules.d/99fs-lib/fs-lib.sh index 9e6abf6..15e2b91 100755 --- a/modules.d/99fs-lib/fs-lib.sh +++ b/modules.d/99fs-lib/fs-lib.sh @@ -287,3 +287,29 @@ fs_add_mount() { [ "${pass}" ] || pass=0 echo "${fs} ${mountpoint} ${fstype} ${options} ${dump} ${pass}" >> /etc/fstab."${phase}" } + +# fs_mount_to_var MOUNTSPEC +# use MOUNTSPEC to set $mountpoint, $fstype, $fs and $options. +# MOUNTSPEC is something like: [<mountpoint>]:<fstype>:<fs>[,<options>] +fs_mount_to_var() { + local arg="$1" + + options="${arg#*,}" + [ "${options}" = "${arg}" ] && unset options + arg="${arg%%,${options}}" + + mountpoint="${arg%%:*}" + [ "${mountpoint}" = "${arg}" ] && die "Unable to parse mountpoint out of $1" + arg="${arg##${mountpoint}:}" + + if [ "${mountpoint}" = "${mountpoint#/}" ] ; then + fstype="${mountpoint}" + mountpoint=/ + else + fstype="${arg%%:*}" + [ "${fstype}" = "${arg}" ] && die "Unable to parse fstype out of $1" + arg="${arg##${fstype}:}" + fi + + fs="${arg}" +} -- 1.8.1.5 ^ permalink raw reply related [flat|nested] 9+ messages in thread
[parent not found: <1365694762-7806-2-git-send-email-devurandom-hi6Y0CQ0nG0@public.gmane.org>]
* Re: [PATCH 2/2] [99fs-lib] Provide fs_mount_to_var utility function to parse /path:type:/dev,options style mountspecs [not found] ` <1365694762-7806-2-git-send-email-devurandom-hi6Y0CQ0nG0@public.gmane.org> @ 2013-04-11 15:48 ` Dennis Schridde 0 siblings, 0 replies; 9+ messages in thread From: Dennis Schridde @ 2013-04-11 15:48 UTC (permalink / raw) To: initramfs-u79uwXL29TY76Z2rM5mHXA [-- Attachment #1: Type: text/plain, Size: 232 bytes --] Hello! I will submit further patches that require these, once these are in a state where they will be accepted. Please note that you can also have a look at these patches on github: https://github.com/devurandom/dracut --Dennis [-- Attachment #2: This is a digitally signed message part. --] [-- Type: application/pgp-signature, Size: 198 bytes --] ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 1/2] [99fs-lib] Create generic mount framework [not found] ` <1365694762-7806-1-git-send-email-devurandom-hi6Y0CQ0nG0@public.gmane.org> 2013-04-11 15:39 ` [PATCH 2/2] [99fs-lib] Provide fs_mount_to_var utility function to parse /path:type:/dev,options style mountspecs Dennis Schridde @ 2013-04-11 15:48 ` Harald Hoyer [not found] ` <5166DB40.7040108-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> 2013-05-17 16:17 ` [PATCH 1/2] [40network] Add variable parsing framework for network related variables Dennis Schridde 2 siblings, 1 reply; 9+ messages in thread From: Harald Hoyer @ 2013-04-11 15:48 UTC (permalink / raw) To: Dennis Schridde; +Cc: initramfs-u79uwXL29TY76Z2rM5mHXA Am 11.04.2013 17:39, schrieb Dennis Schridde: > * Utilises fstab.{early,late} files in /etc > * Provides fs_add_mount function to mount in pre-mount (early) and pre-pivot (late) phases > * Code to mount a fstab file is moved over from 95fstab-sys > --- Why not make use of fstab and fstab of the real root? /etc/fstab in the initramfs == fstab.early $NEWROOT/etc/fstab == fstab.late ?? In systemd we introduced "x-initrd.mount" as a mount option, to mark those mount entries from $NEWROOT/etc/fstab to be mounted in pre-pivot. ^ permalink raw reply [flat|nested] 9+ messages in thread
[parent not found: <5166DB40.7040108-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>]
* Re: [PATCH 1/2] [99fs-lib] Create generic mount framework [not found] ` <5166DB40.7040108-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> @ 2013-04-11 16:10 ` Dennis Schridde 2013-05-17 16:22 ` Dennis Schridde 0 siblings, 1 reply; 9+ messages in thread From: Dennis Schridde @ 2013-04-11 16:10 UTC (permalink / raw) To: Harald Hoyer; +Cc: initramfs-u79uwXL29TY76Z2rM5mHXA [-- Attachment #1: Type: text/plain, Size: 1333 bytes --] Am Donnerstag, 11. April 2013, 17:48:16 schrieb Harald Hoyer: > Am 11.04.2013 17:39, schrieb Dennis Schridde: > > * Utilises fstab.{early,late} files in /etc > > * Provides fs_add_mount function to mount in pre-mount (early) and > > pre-pivot (late) phases * Code to mount a fstab file is moved over from > > 95fstab-sys > > --- > > Why not make use of fstab and fstab of the real root? > > /etc/fstab in the initramfs == fstab.early > $NEWROOT/etc/fstab == fstab.late I want to mount depending on the cmdline arguments of the kernel. Basically, what I need is a way to guarantee certain devices/directories to be mounted before dracut tries to mount the rootfs. Also, the mountpoints are inside the initramfs, not inside the rootfs. So having them in the rootfs' fstab (when the mountpoints do not exist there), seems wrong. For testing it was extremely helpful that I could provide these devices on the cmdline, because the initramfs takes quite a while to build on my machines, so replacing a file inside them each time I tried to get the path right would have been cumbersome. > In systemd we introduced "x-initrd.mount" as a mount option, to mark those > mount entries from $NEWROOT/etc/fstab to be mounted in pre-pivot. I assume there is nothing (yet) that mounts entries before the rootfs gets mounted? --Dennis [-- Attachment #2: This is a digitally signed message part. --] [-- Type: application/pgp-signature, Size: 198 bytes --] ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 1/2] [99fs-lib] Create generic mount framework 2013-04-11 16:10 ` Dennis Schridde @ 2013-05-17 16:22 ` Dennis Schridde 0 siblings, 0 replies; 9+ messages in thread From: Dennis Schridde @ 2013-05-17 16:22 UTC (permalink / raw) To: Harald Hoyer; +Cc: initramfs-u79uwXL29TY76Z2rM5mHXA [-- Attachment #1: Type: text/plain, Size: 237 bytes --] Hello! These 99fs-lib patches are still needed by my aufs/nfs extensions that are about to be submitted once any issues with these patches are resolved. Are there any issues with these patches? Can someone please merge them? --Dennis [-- Attachment #2: This is a digitally signed message part. --] [-- Type: application/pgp-signature, Size: 198 bytes --] ^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 1/2] [40network] Add variable parsing framework for network related variables [not found] ` <1365694762-7806-1-git-send-email-devurandom-hi6Y0CQ0nG0@public.gmane.org> 2013-04-11 15:39 ` [PATCH 2/2] [99fs-lib] Provide fs_mount_to_var utility function to parse /path:type:/dev,options style mountspecs Dennis Schridde 2013-04-11 15:48 ` [PATCH 1/2] [99fs-lib] Create generic mount framework Harald Hoyer @ 2013-05-17 16:17 ` Dennis Schridde [not found] ` <1368807440-9207-1-git-send-email-devurandom-hi6Y0CQ0nG0@public.gmane.org> 2 siblings, 1 reply; 9+ messages in thread From: Dennis Schridde @ 2013-05-17 16:17 UTC (permalink / raw) To: initramfs-u79uwXL29TY76Z2rM5mHXA; +Cc: Dennis Schridde * Provides net_add_parse_vars function to install net_parse_vars hook when an interface comes online * Provides net_parse_vars function to search and replace network related variables in a string --- modules.d/40network/net-lib.sh | 56 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/modules.d/40network/net-lib.sh b/modules.d/40network/net-lib.sh index f9b461b..f006874 100644 --- a/modules.d/40network/net-lib.sh +++ b/modules.d/40network/net-lib.sh @@ -366,3 +366,59 @@ linkup() { && wait_for_if_up $1 2>/dev/null } +# net_parse_vars STRING IFUP +# parse vars in STRING +# IFUP may contain the interface that came online, triggering this hook +net_parse_vars() { + local cur="$1" ifup="$2" var val iface + + var="${cur#*%\{}" + var="${var%%\}*}" + + while [ "${var}" != "${cur}" ] ; do + case "${var}" in + mac.*) + iface="${var##mac.}" + [ "${ifup}" = "${iface}" ] || exit + val="$(ip link show dev "${iface}" | sed -nre '/ether/s/^.*ether ([0-9a-f:]*) .*$/\1/' -e 's/://')" + ;; + hostname) + val="$(hostname)" + [ "${val}" = '(none)' ] && die 'No hostname (yet)' + ;; + *) + die "Unsupported cmdline variable '${var}'" + ;; + esac + + cur="$(echo "${cur}" | sed "s/%{${var}}/${val}/")" + unset val + + var="${cur#*%\{}" + var="${var%%\}*}" + done + + echo "${cur}" +} + +# net_add_parse_vars STRING LIB FUNCTION +# add initqueue/online hook to parse vars in STRING +# execute FUNCTION from LIB afterwards +net_add_parse_vars() { + local string="$1" lib="$2" func="$3" jobid="$(cat /proc/sys/kernel/random/uuid)" + + cat <<- EOF > "${hookdir}"/initqueue/online/40network.parse."${jobid}".sh + . /lib/"${lib}".sh + + string="\$(net_parse_vars "${string}" "\$@")" + ${func} "\${string}" + unset string + + > /tmp/40network.parse.finished."${jobid}" + EOF + + cat <<- EOF > "${hookdir}"/initqueue/finished/40network.parse.wait."${jobid}".sh + echo "Waiting for nfs_parse_vars (${jobid}) to complete ..." + [ -f /tmp/40network.parse.finished."${jobid}" ] + EOF +} -- 1.8.2.1 ^ permalink raw reply related [flat|nested] 9+ messages in thread
[parent not found: <1368807440-9207-1-git-send-email-devurandom-hi6Y0CQ0nG0@public.gmane.org>]
* [PATCH 2/2] [40network] Provide a hostname fallback function, in case there is no executable of this name [not found] ` <1368807440-9207-1-git-send-email-devurandom-hi6Y0CQ0nG0@public.gmane.org> @ 2013-05-17 16:17 ` Dennis Schridde 2013-05-17 16:22 ` [PATCH 1/2] [40network] Add variable parsing framework for network related variables Dennis Schridde 1 sibling, 0 replies; 9+ messages in thread From: Dennis Schridde @ 2013-05-17 16:17 UTC (permalink / raw) To: initramfs-u79uwXL29TY76Z2rM5mHXA; +Cc: Dennis Schridde --- modules.d/40network/net-lib.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/modules.d/40network/net-lib.sh b/modules.d/40network/net-lib.sh index f006874..7e8b2e5 100644 --- a/modules.d/40network/net-lib.sh +++ b/modules.d/40network/net-lib.sh @@ -422,3 +422,8 @@ net_add_parse_vars() { [ -f /tmp/40network.parse.finished."${jobid}" ] EOF } + +type hostname >/dev/null 2>&1 || \ +hostname() { + cat /proc/sys/kernel/hostname +} -- 1.8.2.1 ^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH 1/2] [40network] Add variable parsing framework for network related variables [not found] ` <1368807440-9207-1-git-send-email-devurandom-hi6Y0CQ0nG0@public.gmane.org> 2013-05-17 16:17 ` [PATCH 2/2] [40network] Provide a hostname fallback function, in case there is no executable of this name Dennis Schridde @ 2013-05-17 16:22 ` Dennis Schridde 1 sibling, 0 replies; 9+ messages in thread From: Dennis Schridde @ 2013-05-17 16:22 UTC (permalink / raw) To: initramfs-u79uwXL29TY76Z2rM5mHXA [-- Attachment #1: Type: text/plain, Size: 316 bytes --] Oups, sorry, these emails should have been referring to Message-Id: <1365694853-7881-1-git-send-email-devurandom-hi6Y0CQ0nG0@public.gmane.org> I will not resend them with the proper In-Reply-To in the hopes that this is not especially important and they will be considered for merging anyway. Best regards, Dennis [-- Attachment #2: This is a digitally signed message part. --] [-- Type: application/pgp-signature, Size: 198 bytes --] ^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2013-05-17 16:22 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-04-11 15:39 [PATCH 1/2] [99fs-lib] Create generic mount framework Dennis Schridde
[not found] ` <1365694762-7806-1-git-send-email-devurandom-hi6Y0CQ0nG0@public.gmane.org>
2013-04-11 15:39 ` [PATCH 2/2] [99fs-lib] Provide fs_mount_to_var utility function to parse /path:type:/dev,options style mountspecs Dennis Schridde
[not found] ` <1365694762-7806-2-git-send-email-devurandom-hi6Y0CQ0nG0@public.gmane.org>
2013-04-11 15:48 ` Dennis Schridde
2013-04-11 15:48 ` [PATCH 1/2] [99fs-lib] Create generic mount framework Harald Hoyer
[not found] ` <5166DB40.7040108-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2013-04-11 16:10 ` Dennis Schridde
2013-05-17 16:22 ` Dennis Schridde
2013-05-17 16:17 ` [PATCH 1/2] [40network] Add variable parsing framework for network related variables Dennis Schridde
[not found] ` <1368807440-9207-1-git-send-email-devurandom-hi6Y0CQ0nG0@public.gmane.org>
2013-05-17 16:17 ` [PATCH 2/2] [40network] Provide a hostname fallback function, in case there is no executable of this name Dennis Schridde
2013-05-17 16:22 ` [PATCH 1/2] [40network] Add variable parsing framework for network related variables Dennis Schridde
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.