netroot: modular support for network root devices
cover netroot: modular support for network root devices
This builds on the NFS root work to allow other network methods to hook into the parsing and network infrastructure. One network interface is configured at a time, but if we don't find a root there, it may not be unconfigured -- this should probably be added.
I implemented some of the legacy formats we talked about, but not all of them, and I may not have them 100% correct. That handling has seen less testing than the NFS methods I usually use. I have verified that this set will work with root=dhcp w/ NFS, and no root, but nbdroot= for NBD.
I think we can offer some support for LVM/LUKS over NBD, but that's low on my list at the moment -- it was more important to shine some light on this to see if it gets burned up. Documentation would be another high priority, as in the formats supported as well as the interfaces and expectations of the handlers.
David Dillow (9):
nfsroot: move to same sort order as block methods block root: split out resume parsing and udev rules
dracut: add cmdline hook
cmdline: cleanup handling and block: handler
resume: add support for labeled resume devices
dracut-lib: add source_all to library
netroot: add common handler for network root devices
nfsroot: move to netroot framework
Add NBD support
dracut | 2 +-
modules.d/40network/60-net.rules | 1 +
modules.d/40network/dhcp-fallback.sh | 14 +++
modules.d/40network/ifup | 8 +-
modules.d/40network/install | 2 +
modules.d/40network/netroot | 52 +++++++++
modules.d/40nfsroot/60-nfsroot.rules | 1 -
modules.d/40nfsroot/nfsroot | 125 ---------------------
modules.d/{40nfsroot => 95nbd}/check | 4 +-
modules.d/95nbd/install | 7 +
modules.d/95nbd/nbd-netroot.sh | 11 ++
modules.d/95nbd/nbdroot | 96 ++++++++++++++++
modules.d/95nbd/parse-nbdroot.sh | 49 ++++++++
modules.d/{40nfsroot => 95nfs}/check | 0
modules.d/{40nfsroot => 95nfs}/install | 10 +--
modules.d/95nfs/nfs-netroot.sh | 52 +++++++++
modules.d/95nfs/nfsroot | 82 ++++++++++++++
modules.d/{40nfsroot => 95nfs}/nfsroot-cleanup.sh | 0
modules.d/95nfs/parse-nfsroot.sh | 48 ++++++++
modules.d/95resume/install | 4 +-
modules.d/95resume/parse-resume.sh | 8 ++
modules.d/95resume/resume-genrules.sh | 8 ++
modules.d/95rootfs-block/block-genrules.sh | 10 ++
modules.d/95rootfs-block/genrules.sh | 14 ---
modules.d/95rootfs-block/install | 6 +-
modules.d/95rootfs-block/parse-block.sh | 16 +++
modules.d/95rootfs-block/parse-root-opts.sh | 21 +---
modules.d/99base/dracut-lib | 22 ++++
modules.d/99base/init | 31 ++++-
29 files changed, 522 insertions(+), 182 deletions(-)
create mode 100755 modules.d/40network/dhcp-fallback.sh
create mode 100755 modules.d/40network/netroot
delete mode 100644 modules.d/40nfsroot/60-nfsroot.rules
delete mode 100755 modules.d/40nfsroot/nfsroot
copy modules.d/{40nfsroot => 95nbd}/check (61%)
create mode 100755 modules.d/95nbd/install
create mode 100755 modules.d/95nbd/nbd-netroot.sh
create mode 100755 modules.d/95nbd/nbdroot
create mode 100755 modules.d/95nbd/parse-nbdroot.sh
rename modules.d/{40nfsroot => 95nfs}/check (100%)
rename modules.d/{40nfsroot => 95nfs}/install (83%)
create mode 100755 modules.d/95nfs/nfs-netroot.sh
create mode 100755 modules.d/95nfs/nfsroot
rename modules.d/{40nfsroot => 95nfs}/nfsroot-cleanup.sh (100%)
create mode 100755 modules.d/95nfs/parse-nfsroot.sh
create mode 100755 modules.d/95resume/resume-genrules.sh
create mode 100755 modules.d/95rootfs-block/block-genrules.sh
delete mode 100755 modules.d/95rootfs-block/genrules.sh
create mode 100755 modules.d/95rootfs-block/parse-block.sh--
To unsubscribe from this list: send the line "unsubscribe initramfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
A message that is not in the archive (sent off-list or not yet received): cover.1243833882.git.dave-i1Mk8JYDVaaSihdK6806/[email protected]
RFC PATCH 1/9 nfsroot: move to same sort order as block methods
There is no reason for this to be a 40nfsroot rather than 95nfs once other network root handlers are added. Go ahead and move it.
--- modules.d/40nfsroot/60-nfsroot.rules | 1 - modules.d/40nfsroot/check | 11 --- modules.d/40nfsroot/install | 27 ------- modules.d/40nfsroot/nfsroot | 125 -------------------------------- modules.d/40nfsroot/nfsroot-cleanup.sh | 19 ----- modules.d/95nfs/60-nfsroot.rules | 1 + modules.d/95nfs/check | 11 +++ modules.d/95nfs/install | 27 +++++++ modules.d/95nfs/nfsroot | 125 ++++++++++++++++++++++++++++++++ modules.d/95nfs/nfsroot-cleanup.sh | 19 +++++ 10 files changed, 183 insertions(+), 183 deletions(-) delete mode 100644 modules.d/40nfsroot/60-nfsroot.rules delete mode 100755 modules.d/40nfsroot/check delete mode 100755 modules.d/40nfsroot/install delete mode 100755 modules.d/40nfsroot/nfsroot delete mode 100644 modules.d/40nfsroot/nfsroot-cleanup.sh create mode 100644 modules.d/95nfs/60-nfsroot.rules create mode 100755 modules.d/95nfs/check create mode 100755 modules.d/95nfs/install create mode 100755 modules.d/95nfs/nfsroot create mode 100644 modules.d/95nfs/nfsroot-cleanup.sh
modules.d/40nfsroot/60-nfsroot.rules deleted +0 -1
@@ -1 +0,0 @@ -ACTION=="online", SUBSYSTEM=="net", RUN+="/sbin/nfsroot $env{INTERFACE}"
modules.d/40nfsroot/check deleted +0 -11
@@ -1,11 +0,0 @@ -#!/bin/sh -# We depend on network modules being loaded -[ "$1" = "-d" ] && echo network - -# If hostonly was requested, fail the check if we are not actually -# booting from root. -[ "$1" = "-h" ] && ! egrep -q '/ nfs[34 ]' /proc/mounts && exit 1 - -# If our prerequisites are not met, fail anyways. -which rpcbind rpc.statd mount.nfs mount.nfs4 umount >/dev/null 2>&1 || exit 1 -exit 0
modules.d/40nfsroot/install deleted +0 -27
@@ -1,27 +0,0 @@ -#!/bin/sh -dracut_install rpcbind rpc.statd mount.nfs mount.nfs4 umount -dracut_install /etc/netconfig /etc/passwd /etc/services - -# XXX debug stuff -dracut_install rpcinfo ping strace dmesg nc free df - -dracut_install rpc.idmapd /etc/idmapd.conf - -instmods nfs -inst_rules "$moddir/60-nfsroot.rules" -inst_hook pre-pivot 70 "$moddir/nfsroot-cleanup.sh" -inst "$moddir/nfsroot" "/sbin/nfsroot" -mkdir -p "$initdir/var/lib/nfs/rpc_pipefs" -mkdir -p "$initdir/var/lib/rpcbind" -mkdir -p "$initdir/var/lib/nfs/statd/sm" - -# XXX debug -mkdir -p "$initdir/mnt" - -# Rather than copy the passwd file in, just set a user for rpcbind -# We'll save the state and restart the daemon from the root anyway -#echo "rpc:x:32:32:Rpcbind:/var/lib/rpcbind:/bin/false" >> "$initdir/etc/passwd" - -# rpc user needs to be able to write to this directory to save the warmstart -# file -chmod 777 "$initdir/var/lib/rpcbind"
modules.d/40nfsroot/nfsroot deleted +0 -125
125 lines not on this page · raw message
modules.d/40nfsroot/nfsroot-cleanup.sh deleted +0 -19
@@ -1,19 +0,0 @@ -#!/bin/sh - -pid=$(pidof rpc.statd) -[ -n "$pid" ] && kill $pid - -pid=$(pidof rpcbind) -[ -n "$pid" ] && kill $pid - -if grep -q rpc_pipefs /proc/mounts; then - # try to create the destination directory - [ -d $NEWROOT/var/lib/nfs/rpc_pipefs ] || mkdir -p $NEWROOT/var/lib/nfs/rpc_pipefs 2>/dev/null - - if [ -d $NEWROOT/var/lib/nfs/rpc_pipefs ]; then - mount --move /var/lib/nfs/rpc_pipefs $NEWROOT/var/lib/nfs/rpc_pipefs - else - umount /var/lib/nfs/rpc_pipefs - fi -fi -
modules.d/95nfs/60-nfsroot.rules new file +1 -0
@@ -0,0 +1 @@ +ACTION=="online", SUBSYSTEM=="net", RUN+="/sbin/nfsroot $env{INTERFACE}"
modules.d/95nfs/check new file +11 -0
@@ -0,0 +1,11 @@ +#!/bin/sh +# We depend on network modules being loaded +[ "$1" = "-d" ] && echo network + +# If hostonly was requested, fail the check if we are not actually +# booting from root. +[ "$1" = "-h" ] && ! egrep -q '/ nfs[34 ]' /proc/mounts && exit 1 + +# If our prerequisites are not met, fail anyways. +which rpcbind rpc.statd mount.nfs mount.nfs4 umount >/dev/null 2>&1 || exit 1 +exit 0
modules.d/95nfs/install new file +27 -0
@@ -0,0 +1,27 @@ +#!/bin/sh +dracut_install rpcbind rpc.statd mount.nfs mount.nfs4 umount +dracut_install /etc/netconfig /etc/passwd /etc/services + +# XXX debug stuff +dracut_install rpcinfo ping strace dmesg nc free df + +dracut_install rpc.idmapd /etc/idmapd.conf + +instmods nfs +inst_rules "$moddir/60-nfsroot.rules" +inst_hook pre-pivot 70 "$moddir/nfsroot-cleanup.sh" +inst "$moddir/nfsroot" "/sbin/nfsroot" +mkdir -p "$initdir/var/lib/nfs/rpc_pipefs" +mkdir -p "$initdir/var/lib/rpcbind" +mkdir -p "$initdir/var/lib/nfs/statd/sm" + +# XXX debug +mkdir -p "$initdir/mnt" + +# Rather than copy the passwd file in, just set a user for rpcbind +# We'll save the state and restart the daemon from the root anyway +#echo "rpc:x:32:32:Rpcbind:/var/lib/rpcbind:/bin/false" >> "$initdir/etc/passwd" + +# rpc user needs to be able to write to this directory to save the warmstart +# file +chmod 777 "$initdir/var/lib/rpcbind"
modules.d/95nfs/nfsroot new file +125 -0
125 lines not on this page · raw message
modules.d/95nfs/nfsroot-cleanup.sh new file +19 -0
@@ -0,0 +1,19 @@ +#!/bin/sh + +pid=$(pidof rpc.statd) +[ -n "$pid" ] && kill $pid + +pid=$(pidof rpcbind) +[ -n "$pid" ] && kill $pid + +if grep -q rpc_pipefs /proc/mounts; then + # try to create the destination directory + [ -d $NEWROOT/var/lib/nfs/rpc_pipefs ] || mkdir -p $NEWROOT/var/lib/nfs/rpc_pipefs 2>/dev/null + + if [ -d $NEWROOT/var/lib/nfs/rpc_pipefs ]; then + mount --move /var/lib/nfs/rpc_pipefs $NEWROOT/var/lib/nfs/rpc_pipefs + else + umount /var/lib/nfs/rpc_pipefs + fi +fi +
Signature · 6 lines
1.6.0.6 -- To unsubscribe from this list: send the line "unsubscribe initramfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
A message that is not in the archive (sent off-list or not yet received): 145ca9e5b331c454ebe13005fdfaed3749ef50f5.1243833882.git.dave-i1Mk8JYDVaaSihdK6806/[email protected]
Re: [RFC PATCH 1/9] nfsroot: move to same sort order as block methods
David Dillow wrote:
[snip]
Quoted 84 lines
modules.d/95nfs/nfsroot new file +78
-0@@ -0,0 +1,125 @@ +#!/bin/sh + +. /lib/dracut-lib + +PATH=$PATH:/sbin:/usr/sbin + +# XXX needs error handling like ifup/dhclient-script + +# XXX need to lock our attempts if we're doing the mount here + +getarg rdnetdebug && { + exec > /tmp/nfsroot.$1.$$.out + exec 2>> /tmp/nfsroot.$1.$$.out + set -x +} + +[ "$NFS_LOCKED" ] || { + NFS_LOCKED=true + export NFS_LOCKED + exec flock -xo /tmp/nfs.lock -c "$0 $*" + exit 1 +} + +[ -e /tmp/nfsdone ] && exit 0 + +nfs_done() { + >/tmp/nfsdone + exit 0 +} + +root=$(getarg root) +case $root in + nfs|/dev/nfs) type=nfs ;; + nfs4|/dev/nfs4) type=nfs4 ;; + auto|'') type=auto ;; +esac + +rootfstype=$(getarg rootfstype) +case $rootfstype in + nfs|nfs4|auto) type=$rootfstype ;; +esac + +# If we're not doing NFS at all, don't keep banging our head +[ -n "$type" ] || nfs_done + +[ -e /tmp/net.$1.dhcpopts ] && . /tmp/net.$1.dhcpopts + +nfsroot=$(getarg nfsroot) +[ -n "$nfsroot" ] || nfsroot="$new_root_path" +[ -n "$nfsroot" ] || nfs_done + +# check for IP address at front, if there is none, use +# new_dhcp_server_identifier +# +# XXX kernel nfsroot uses , to separate NFS options at end +# +nfsserver=${nfsroot%%:*}; nfsroot=${nfsroot#*:} +nfspath=${nfsroot%%:*} +flags=${nfsroot#*:} +[ "$nfsserver" = "$nfspath" ] && nfsserver=$new_dhcp_server_identifier +[ "$nfspath" = "$flags" ] && unset flags + +[ -n "$nfsserver" ] || no_nfs + +# look through the flags and see if any are overridden by the command line +while [ -n "$flags" ]; do + f=${flags%%,*}; flags=${flags#*,} + [ "$f" = "nfs" -o "$f" = "nfs4" ] && { + [ "$type" = "auto" ] && type=$f + continue + } + [ "$f" = "ro" -o "$f" = "rw" ] && { + nfsrw=$f + continue + } + [ "$f" = "lock" -o "$f" = "nolock" ] && { + nfslock=$f + continue
modules.d/95nfs/nfsroot line 88
Quoted 10 lines
modules.d/95nfs/nfsroot new file +10
-0+ } + nfsflags=${nfsflags+$nfsflags,}$f +done + +getarg ro && nfsrw=ro +getarg rw && nfsrw=rw +nfsflags=${nfsflags+$nfsflags,}${nfsrw} + +# load our modules explicitly, so we can fail fast in the future +modprobe nfs || nfs_done
Hmmm... isn't that a bit dangerous? I mean what if nfs support is compiled into the kernel?
modules.d/95nfs/nfsroot line 96
Quoted 8 lines
modules.d/95nfs/nfsroot new file +8
-0+ +# XXX don't forget to move /var/lib/nfs/rpc_pipefs to new / +# XXX need host name set before now? + +# Start rpcbind and rpc.statd as mount won't let us use locks on a NFSv4 +# filesystem without talking to them, even though they are unneeded +# XXX occasionally saw 'rpcbind: fork failed: No such device' -- why? +[ -n "$(pidof rpcbind)" ] || rpcbind
I see a potential conflict here: Debian based distros use portmap not rpcbind.
modules.d/95nfs/nfsroot line 97
Quoted 1 line
modules.d/95nfs/nfsroot new file +1
-0+[ -n "$(pidof rpc.statd)" ] || rpc.statd
Question: Do we really need statd?
modules.d/95nfs/nfsroot line 101
Quoted 4 lines
modules.d/95nfs/nfsroot new file +4
-0+ +# XXX should I do rpc.idmapd here, or wait and start in the new root +# XXX waiting assumes root can read everything it needs right up until +# XXX we start it...
Dracut should only care about getting the root-fs. idmapd is really a system configuration, don't start that.
Quoted 38 lines
modules.d/95nfs/nfsroot new file +24
-0+ +# XXX really, want to retry in a loop I think, but not here... + +[ "$type" = "nfs4" -o "$type" = "auto" ] && { + # XXX really needed? Do we need non-root users before we start it in + # XXX the real root image? + [ -n "$(pidof rpc.idmapd)" ] || rpc.idmapd + + # NFSv4 does locks internally + mount -t nfs4 -o${nfsflags}${nfslock+,$nfslock} \ + $nfsserver:$nfspath /sysroot && nfs_done + + # If we're specified to be NFSv4, then stop when we fail + # Don't mark us done, as this may be transient + [ "$type" = "nfs4" ] && exit 0 +} + +# we're NFSv{2,3} or auto and NFSv4 failed. We don't support using locks +# on NFSv{2,3} because that requires a helper to transfer the rpcbind state +# rpcbind to the new root +[ -z "$nfslock" -o "$nfslock" = "lock" ] && + echo "Locks unsupported on NFSv{2,3}, using nolock" 1>&2 +mount -t nfs -onolock,$nfsflags $nfsserver:$nfspath /sysroot && nfs_done +exit 0modules.d/95nfs/nfsroot-cleanup.sh new file +8
-0@@ -0,0 +1,19 @@ +#!/bin/sh + +pid=$(pidof rpc.statd) +[ -n "$pid" ] && kill $pid + +pid=$(pidof rpcbind) +[ -n "$pid" ] && kill $pid +
modules.d/95nfs/nfsroot-cleanup.sh line 18
Quoted 10 lines
modules.d/95nfs/nfsroot-cleanup.sh new file +10
-0+if grep -q rpc_pipefs /proc/mounts; then + # try to create the destination directory + [ -d $NEWROOT/var/lib/nfs/rpc_pipefs ] || mkdir -p $NEWROOT/var/lib/nfs/rpc_pipefs 2>/dev/null + + if [ -d $NEWROOT/var/lib/nfs/rpc_pipefs ]; then + mount --move /var/lib/nfs/rpc_pipefs $NEWROOT/var/lib/nfs/rpc_pipefs + else + umount /var/lib/nfs/rpc_pipefs + fi +fi
Question: Do we really have to do that? I mean nfsroot worked until now without considering rpc_pipefs.
Regards,
Philippe
modules.d/95nfs/nfsroot-cleanup.sh line 19
Quoted 1 line
modules.d/95nfs/nfsroot-cleanup.sh new file +1
-0+
--
To unsubscribe from this list: send the line "unsubscribe initramfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
A message that is not in the archive (sent off-list or not yet received): [email protected]
Re: [RFC PATCH 1/9] nfsroot: move to same sort order as block methods
Quoted 6 lines · Seewer Philippe
modules.d/95nfs/nfsroot line 88
Quoted 2 lines · David Dillow
modules.d/95nfs/nfsroot new file +2
-0+# load our modules explicitly, so we can fail fast in the future +modprobe nfs || nfs_doneHmmm... isn't that a bit dangerous? I mean what if nfs support is compiled into the kernel?
Probably; we can either drop it or add a check for nfs in /proc/filesystems before calling it.
Quoted 4 lines
Quoted 1 line
+[ -n "$(pidof rpcbind)" ] || rpcbind
I see a potential conflict here: Debian based distros use portmap not rpcbind.
Go to know; I'll think about how to handle that.
Quoted 3 lines
Quoted 1 line
+[ -n "$(pidof rpc.statd)" ] || rpc.statd
Question: Do we really need statd?
Yes, if you want to use locks you need statd. We can avoid it on NFSv3 by using nolock, and it is not needed for NFSv4 to use locks, but mount will not even try to mount the filesystem without it or -onolock present.
Quoted 6 lines
modules.d/95nfs/nfsroot line 101
Quoted 3 lines
modules.d/95nfs/nfsroot new file +3
-0+# XXX should I do rpc.idmapd here, or wait and start in the new root +# XXX waiting assumes root can read everything it needs right up until +# XXX we start it...Dracut should only care about getting the root-fs. idmapd is really a system configuration, don't start that.
Somewhat vestigial from my purpose of getting RedHat to boot with a read only NFS root -- I wasn't sure if it needed to read files as a non-root user.
It could probably go.
Quoted 15 lines
modules.d/95nfs/nfsroot-cleanup.sh line 18
Quoted 12 lines
modules.d/95nfs/nfsroot-cleanup.sh +10
-0+if grep -q rpc_pipefs /proc/mounts; then + # try to create the destination directory + [ -d $NEWROOT/var/lib/nfs/rpc_pipefs ] || mkdir -p $NEWROOT/var/lib/nfs/rpc_pipefs 2>/dev/null + + if [ -d $NEWROOT/var/lib/nfs/rpc_pipefs ]; then + mount --move /var/lib/nfs/rpc_pipefs $NEWROOT/var/lib/nfs/rpc_pipefs + else + umount /var/lib/nfs/rpc_pipefs + fi +fiQuestion: Do we really have to do that? I mean nfsroot worked until now without considering
rpc_pipefs.
If idmapd goes, I think this could go as well. The problem is that you never get it mounted again, as it is usually handled on modprobe of sunrpc, which happens inside the initramfs.
nfsroot worked without it, because as far as I've seen, it's always been NFSv2/3 with nolock.
This can of course be fixed in the distros.
--
To unsubscribe from this list: send the line "unsubscribe initramfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
RFC PATCH 2/9 block root: split out resume parsing and udev rules
In reply to a message not in the archiveWe have a resume module, and these rules should live in it. Modify the sort order a bit to ensure the resume rules continue to execute first.
--- modules.d/95resume/install | 3 ++- modules.d/95resume/resume-genrules.sh | 6 ++++++ modules.d/95rootfs-block/block-genrules.sh | 6 ++++++ modules.d/95rootfs-block/genrules.sh | 14 -------------- modules.d/95rootfs-block/install | 4 ++-- modules.d/95rootfs-block/parse-root-opts.sh | 6 ------ 6 files changed, 16 insertions(+), 23 deletions(-) create mode 100755 modules.d/95resume/resume-genrules.sh create mode 100755 modules.d/95rootfs-block/block-genrules.sh delete mode 100755 modules.d/95rootfs-block/genrules.sh
modules.d/95resume/install +2 -1
@@ -1,4 +1,5 @@ #!/bin/bash +dracut_install echo inst_hook pre-udev 10 "$moddir/parse-resume.sh" +inst_hook pre-udev 30 "$moddir/resume-genrules.sh" inst_hook mount 90 "$moddir/resume.sh" -
modules.d/95resume/resume-genrules.sh new file +6 -0
@@ -0,0 +1,6 @@ +resume=$(getarg resume=) && ! getarg noresume && { +( + /bin/echo -e 'KERNEL=="'${resume#/dev/}'", RUN+="/bin/echo %M:%m > /sys/power/resume"' + /bin/echo -e 'SYMLINK=="'${resume#/dev/}'", RUN+="/bin/echo %M:%m > /sys/power/resume"' +) >> /etc/udev/rules.d/99-resume.rules +}
modules.d/95rootfs-block/block-genrules.sh new file +6 -0
@@ -0,0 +1,6 @@ +if [ "${root#/dev/}" != "$root" ]; then + ( + echo 'KERNEL=="'${root#/dev/}'", RUN+="/bin/mount '$fstype' -o '$rflags' '$root' '$NEWROOT'" ' + echo 'SYMLINK=="'${root#/dev/}'", RUN+="/bin/mount '$fstype' -o '$rflags' '$root' '$NEWROOT'" ' + ) >> /etc/udev/rules.d/99-mount.rules +fi
modules.d/95rootfs-block/genrules.sh deleted +0 -14
@@ -1,14 +0,0 @@ -if [ "${root#/dev/}" != "$root" ]; then - - resume=$(getarg resume=) && ! getarg noresume && { - ( - /bin/echo -e 'KERNEL=="'${resume#/dev/}'", RUN+="/bin/echo %M:%m > /sys/power/resume"' - /bin/echo -e 'SYMLINK=="'${resume#/dev/}'", RUN+="/bin/echo %M:%m > /sys/power/resume"' - ) >> /etc/udev/rules.d/99-resume.rules - } - - ( - echo 'KERNEL=="'${root#/dev/}'", RUN+="/bin/mount '$fstype' -o '$rflags' '$root' '$NEWROOT'" ' - echo 'SYMLINK=="'${root#/dev/}'", RUN+="/bin/mount '$fstype' -o '$rflags' '$root' '$NEWROOT'" ' - ) >> /etc/udev/rules.d/99-mount.rules -fi
modules.d/95rootfs-block/install +2 -2
@@ -1,5 +1,5 @@ #!/bin/sh dracut_install echo -inst_hook pre-udev 10 "$moddir/parse-root-opts.sh" -inst_hook pre-udev 20 "$moddir/genrules.sh" +inst_hook pre-udev 20 "$moddir/parse-root-opts.sh" +inst_hook pre-udev 30 "$moddir/block-genrules.sh" inst_hook mount 99 "$moddir/mount-root.sh"
modules.d/95rootfs-block/parse-root-opts.sh +0 -6
@@ -1,10 +1,4 @@ #!/bin/sh -if resume=$(getarg resume=) && ! getarg noresume; then - export resume - echo "$resume" >/.resume -else - unset resume -fi root=$(getarg root=) case $root in
Signature · 6 lines
1.6.0.6 -- To unsubscribe from this list: send the line "unsubscribe initramfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
RFC PATCH 3/9 dracut: add cmdline hook
In reply to a message not in the archiveThis hook is where each module should parse kernel command line options and perform any legacy translation.
--- dracut | 2 +- modules.d/95resume/install | 2 +- modules.d/95rootfs-block/install | 2 +- modules.d/99base/init | 4 ++++ 4 files changed, 7 insertions(+), 3 deletions(-)
dracut +1 -1
@@ -96,7 +96,7 @@ if [[ -f $outfile && ! $force ]]; then exit 1 fi -hookdirs="pre-udev pre-mount pre-pivot mount emergency" +hookdirs="cmdline pre-udev pre-mount pre-pivot mount emergency" readonly initdir=$(mktemp -d -t initramfs.XXXXXX) trap 'rm -rf "$initdir"' 0 # clean up after ourselves no matter how we die.
modules.d/95resume/install +1 -1
@@ -1,5 +1,5 @@ #!/bin/bash dracut_install echo -inst_hook pre-udev 10 "$moddir/parse-resume.sh" +inst_hook cmdline 10 "$moddir/parse-resume.sh" inst_hook pre-udev 30 "$moddir/resume-genrules.sh" inst_hook mount 90 "$moddir/resume.sh"
modules.d/95rootfs-block/install +1 -1
@@ -1,5 +1,5 @@ #!/bin/sh dracut_install echo -inst_hook pre-udev 20 "$moddir/parse-root-opts.sh" +inst_hook cmdline 20 "$moddir/parse-root-opts.sh" inst_hook pre-udev 30 "$moddir/block-genrules.sh" inst_hook mount 99 "$moddir/mount-root.sh"
modules.d/99base/init +4 -0
@@ -43,6 +43,10 @@ mknod /dev/console c 5 1 mkdir /dev/pts mount -t devpts -o gid=5,mode=620 /dev/pts /dev/pts >/dev/null 2>&1 +# run scriptlets to parse the command line +getarg 'rdbreak=cmdline' && emergency_shell +source_all cmdline + # pre-udev scripts run before udev starts, and are run only once. getarg 'rdbreak=pre-udev' && emergency_shell source_all pre-udev
Signature · 6 lines
1.6.0.6 -- To unsubscribe from this list: send the line "unsubscribe initramfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
RFC PATCH 4/9 cmdline: cleanup handling and block: handler
In reply to a message not in the archiveNow init checks that we understood the root= option, and can act upon it, presenting and error if not. Also, clean up the generation of udev rules such that we don't require /bin/echo.
--- modules.d/95rootfs-block/block-genrules.sh | 10 +++++++--- modules.d/95rootfs-block/install | 4 ++-- modules.d/95rootfs-block/parse-block.sh | 16 ++++++++++++++++ modules.d/95rootfs-block/parse-root-opts.sh | 15 +++++---------- modules.d/99base/init | 12 ++++++++++++ 5 files changed, 42 insertions(+), 15 deletions(-) create mode 100755 modules.d/95rootfs-block/parse-block.sh
modules.d/95rootfs-block/block-genrules.sh +7 -3
@@ -1,6 +1,10 @@ -if [ "${root#/dev/}" != "$root" ]; then +#!/bin/bash # for highlighting + +if [ "${root%%:*}" = "block" ]; then ( - echo 'KERNEL=="'${root#/dev/}'", RUN+="/bin/mount '$fstype' -o '$rflags' '$root' '$NEWROOT'" ' - echo 'SYMLINK=="'${root#/dev/}'", RUN+="/bin/mount '$fstype' -o '$rflags' '$root' '$NEWROOT'" ' + printf 'KERNEL=="%s", RUN+="/bin/mount -t %s -o %s %s %s"\n' \ + ${root#block:/dev/} "$fstype" "$rflags" "${root#block:}" "$NEWROOT" + printf 'SYMLINK=="%s", RUN+="/bin/mount -t %s -o %s %s %s"\n' \ + ${root#block:/dev/} "$fstype" "$rflags" "${root#block:}" "$NEWROOT" ) >> /etc/udev/rules.d/99-mount.rules fi
modules.d/95rootfs-block/install +2 -2
@@ -1,5 +1,5 @@ #!/bin/sh -dracut_install echo -inst_hook cmdline 20 "$moddir/parse-root-opts.sh" +inst_hook cmdline 10 "$moddir/parse-root-opts.sh" +inst_hook cmdline 95 "$moddir/parse-block.sh" inst_hook pre-udev 30 "$moddir/block-genrules.sh" inst_hook mount 99 "$moddir/mount-root.sh"
modules.d/95rootfs-block/parse-block.sh new file +16 -0
@@ -0,0 +1,16 @@ +#!/bin/bash # for highlighting + +case "$root" in + block:LABEL=*|LABEL=*) + root="${root#block:}" + root="$(echo $root | sed 's,/,\\x2f,g')" + root="block:/dev/disk/by-label/${root#LABEL=}" + rootok=1 ;; + block:UUID=*|UUID=*) + root="${root#block:}" + root="block:/dev/disk/by-uuid/${root#UUID=}" + rootok=1 ;; + /dev/*) + root="block:${root}" + rootok=1 ;; +esac
modules.d/95rootfs-block/parse-root-opts.sh +5 -10
@@ -1,14 +1,6 @@ -#!/bin/sh +#!/bin/bash # for highlighting 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"
@@ -16,6 +8,9 @@ else getarg rw && rflags=rw || rflags=ro fi -fstype="$(getarg rootfstype=)" && fstype="-t ${fstype}" +fstype="$(getarg rootfstype=)" +if [ -z "$fstype" ]; then + fstype="auto" +fi export fstype rflags root
modules.d/99base/init +12 -0
@@ -47,6 +47,18 @@ mount -t devpts -o gid=5,mode=620 /dev/pts /dev/pts >/dev/null 2>&1 getarg 'rdbreak=cmdline' && emergency_shell source_all cmdline +if [ -z "$rootok" -a -n "${root%%error:*}" ]; then + root="error: No handler for root=${root}" +fi + +if [ -z "${root%%error:*}" ]; then + case "${root%%:*}" in + '') echo "FATAL: no root= option specified" ;; + error) echo "FATAL: ${root#error:}" ;; + esac + emergency_shell +fi + # pre-udev scripts run before udev starts, and are run only once. getarg 'rdbreak=pre-udev' && emergency_shell source_all pre-udev
Signature · 6 lines
1.6.0.6 -- To unsubscribe from this list: send the line "unsubscribe initramfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
A message that is not in the archive (sent off-list or not yet received): d15c7a1ab71af9ab4fccd51fa02915e949f39c86.1243833882.git.dave-i1Mk8JYDVaaSihdK6806/[email protected]
Re: [RFC PATCH 4/9] cmdline: cleanup handling and block: handler
modules.d/95rootfs-block/block-genrules.sh line 1
Quoted 10 lines · David Dillow
Now init checks that we understood the root= option, and can act upon it, presenting and error if not. Also, clean up the generation of udev rules such that we don't require
/bin/echo.modules.d/95rootfs-block/block-genrules.sh +1
-1@@ -1,6 +1,10 @@ -if [ "${root#/dev/}" != "$root" ]; then +#!/bin/bash # for highlighting
Please don't do this.
modules.d/95rootfs-block/block-genrules.sh line 1
Quoted 3 lines
modules.d/95rootfs-block/block-genrules.sh +2
-0+++ b/modules.d/95rootfs-block/parse-block.sh@@ -0,0 +1,16 @@ +#!/bin/bash # for highlighting
Or this
modules.d/95rootfs-block/parse-root-opts.sh line 1
Quoted 7 lines
modules.d/95rootfs-block/parse-root-opts.sh +1
-1@@ -1,14 +1,6 @@ -#!/bin/sh +#!/bin/bash # for highlighting
And so on...
Which editor are you using that highlights bash but not sh correctly?
Signature · 8 lines
Victor Lowther RHCE# 805008539634727 LPIC-2# LPI000140019 -- To unsubscribe from this list: send the line "unsubscribe initramfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
A message that is not in the archive (sent off-list or not yet received): 1243848391.647.13.camel-76q0VzFBGGr21HsLBtNmTckMGDeJXHgy@public.gmane.org
Re: [RFC PATCH 4/9] cmdline: cleanup handling and block: handler
Quoted 3 lines · Victor Lowther
Quoted 1 line
+#!/bin/bash # for highlighting
Please don't do this.
The # for highlighting part? Sure, I thought I killed those. #!/bin/bash as well? I can go along with that -- it is a work around for broken highlighting:
Quoted 1 line
Which editor are you using that highlights bash but not sh correctly?
vim on F10 has different rules for sh and bash -- things like $() and ${t%%:*} are lit in red for sh, but they are valid; they don't highlight that way if vim sees #!/bin/bash
--
To unsubscribe from this list: send the line "unsubscribe initramfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
A message that is not in the archive (sent off-list or not yet received): 1243853668.3844.117.camel-1q1vX8mYZiGLUyTwlgNVppKKF0rrzTr+@public.gmane.org
Re: [RFC PATCH 4/9] cmdline: cleanup handling and block: handler
Quoted 6 lines · David Dillow
Quoted 1 line · Victor Lowther
Which editor are you using that highlights bash but not sh correctly?
vim on F10 has different rules for sh and bash -- things like $() and ${t%%:*} are lit in red for sh, but they are valid; they don't highlight that way if vim sees #!/bin/bash
Ah, that explains it. I am a fan of the OS with an editor tacked onto the side.
<insert rambling pointless flamewar over editors here>
Signature · 8 lines
Victor Lowther RHCE# 805008539634727 LPIC-2# LPI000140019 -- To unsubscribe from this list: send the line "unsubscribe initramfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
A message that is not in the archive (sent off-list or not yet received): 1243854157.647.22.camel-76q0VzFBGGr21HsLBtNmTckMGDeJXHgy@public.gmane.org
Re: [RFC PATCH 4/9] cmdline: cleanup handling and block: handler
Quoted 10 lines · Victor Lowther
Quoted 6 lines · David Dillow
Quoted 1 line · Victor Lowther
Which editor are you using that highlights bash but not sh correctly?
vim on F10 has different rules for sh and bash -- things like $() and ${t%%:*} are lit in red for sh, but they are valid; they don't highlight that way if vim sees #!/bin/bash
Ah, that explains it. I am a fan of the OS with an editor tacked onto the side.
So, ditch the whole shebang at the top? No #!/bin/sh or #!/bin/bash?
--
To unsubscribe from this list: send the line "unsubscribe initramfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
A message that is not in the archive (sent off-list or not yet received): 1243854952.3844.134.camel-1q1vX8mYZiGLUyTwlgNVppKKF0rrzTr+@public.gmane.org
Re: [RFC PATCH 4/9] cmdline: cleanup handling and block: handler
Quoted 5 lines · David Dillow
Quoted 4 lines · Victor Lowther
Quoted 3 lines · David Dillow
Quoted 1 line · Victor Lowther
Which editor are you using that highlights bash but not sh correctly?
Quoted 8 lines
Quoted 6 lines
Quoted 3 lines
vim on F10 has different rules for sh and bash -- things like $() and ${t%%:*} are lit in red for sh, but they are valid; they don't highlight that way if vim sees #!/bin/bash
Ah, that explains it. I am a fan of the OS with an editor tacked onto the side.
So, ditch the whole shebang at the top? No #!/bin/sh or #!/bin/bash?
All scripts on the initramfs should be POSIX -- #!/bin/sh is another way of declaring that for people who haven't R'ed TFM. #!/bin/bash is misleading.
Signature · 8 lines
Victor Lowther RHCE# 805008539634727 LPIC-2# LPI000140019 -- To unsubscribe from this list: send the line "unsubscribe initramfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
A message that is not in the archive (sent off-list or not yet received): 1243856759.647.34.camel-76q0VzFBGGr21HsLBtNmTckMGDeJXHgy@public.gmane.org
Re: [RFC PATCH 4/9] cmdline: cleanup handling and block: handler
Quoted 10 lines · Victor Lowther
Quoted 9 lines · David Dillow
Quoted 8 lines · Victor Lowther
Quoted 6 lines · David Dillow
Quoted 1 line · Victor Lowther
Which editor are you using that highlights bash but not sh correctly?
vim on F10 has different rules for sh and bash -- things like $() and ${t%%:*} are lit in red for sh, but they are valid; they don't highlight that way if vim sees #!/bin/bash
Quoted 8 lines
Quoted 4 lines
Quoted 2 lines
Ah, that explains it. I am a fan of the OS with an editor tacked onto the side.
So, ditch the whole shebang at the top? No #!/bin/sh or #!/bin/bash?
All scripts on the initramfs should be POSIX -- #!/bin/sh is another way of declaring that for people who haven't R'ed TFM. #!/bin/bash is misleading.
I agreed with that, I just wondered if you wanted #!/bin/sh gone as well for the scripts that are being sourced.
--
To unsubscribe from this list: send the line "unsubscribe initramfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [RFC PATCH 4/9] cmdline: cleanup handling and block: handler
In reply to a message not in the archiveQuoted 3 lines · David Dillow
vim on F10 has different rules for sh and bash -- things like $() and ${t%%:*} are lit in red for sh, but they are valid; they don't highlight that way if vim sees #!/bin/bash
Add "let g:is_posix = 1" to your .vimrc (see :help ft-sh-syntax for other possible settings).
A message that is not in the archive (sent off-list or not yet received): 20090601125908.GB4160-TEYkr/UGJhVKdHEj4xO92LjjLBE8jN/[email protected]
Re: [RFC PATCH 4/9] cmdline: cleanup handling and block: handler
Quoted 7 lines · Sergey Vlasov
Quoted 3 lines · David Dillow
vim on F10 has different rules for sh and bash -- things like $() and ${t%%:*} are lit in red for sh, but they are valid; they don't highlight that way if vim sees #!/bin/bash
Add "let g:is_posix = 1" to your .vimrc (see :help ft-sh-syntax for other possible settings).
Thanks for the tip, that works nicely.
--
To unsubscribe from this list: send the line "unsubscribe initramfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
RFC PATCH 5/9 resume: add support for labeled resume devices
In reply to a message not in the archiveI noticed when doing the block root= parser that resume didn't support labeled resume devices. Fix that up and get rid of a dependency on /bin/echo in the process.
--- modules.d/95resume/install | 1 - modules.d/95resume/parse-resume.sh | 8 ++++++++ modules.d/95resume/resume-genrules.sh | 14 ++++++++------ 3 files changed, 16 insertions(+), 7 deletions(-)
modules.d/95resume/install +0 -1
@@ -1,5 +1,4 @@ #!/bin/bash -dracut_install echo inst_hook cmdline 10 "$moddir/parse-resume.sh" inst_hook pre-udev 30 "$moddir/resume-genrules.sh" inst_hook mount 90 "$moddir/resume.sh"
modules.d/95resume/parse-resume.sh +8 -0
@@ -5,3 +5,11 @@ if resume=$(getarg resume=) && ! getarg noresume; then else unset resume fi + +case "$resume" in + LABEL=*) + resume="$(echo $resume | sed 's,/,\\x2f,g')" + resume="/dev/disk/by-label/${resume#LABEL=}" ;; + UUID=*) + resume="/dev/disk/by-uuid/${resume#UUID=}" ;; +esac
modules.d/95resume/resume-genrules.sh +8 -6
@@ -1,6 +1,8 @@ -resume=$(getarg resume=) && ! getarg noresume && { -( - /bin/echo -e 'KERNEL=="'${resume#/dev/}'", RUN+="/bin/echo %M:%m > /sys/power/resume"' - /bin/echo -e 'SYMLINK=="'${resume#/dev/}'", RUN+="/bin/echo %M:%m > /sys/power/resume"' -) >> /etc/udev/rules.d/99-resume.rules -} +if [ -n "$resume" ]; then + ( + printf 'KERNEL=="%s", RUN+="/bin/echo %%M:%%m > /sys/power/resume"\n' \ + ${resume#/dev/} + printf 'SYMLINK=="%s", RUN+="/bin/echo %%M:%%m > /sys/power/resume"\n' \ + ${resume#/dev/} + ) >> /etc/udev/rules.d/99-resume.rules +fi
Signature · 6 lines
1.6.0.6 -- To unsubscribe from this list: send the line "unsubscribe initramfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
A message that is not in the archive (sent off-list or not yet received): 9810ce7e38ec1ba52a9c2f5f5047ea779d1006a3.1243833882.git.dave-i1Mk8JYDVaaSihdK6806/[email protected]
Re: [RFC PATCH 5/9] resume: add support for labeled resume devices
Quoted 16 lines · David Dillow
I noticed when doing the block root= parser that resume didn't support labeled resume devices. Fix that up and get rid of a dependency on
/bin/echoin the process.--- modules.d/95resume/install | 1 - modules.d/95resume/parse-resume.sh | 8 ++++++++ modules.d/95resume/resume-genrules.sh | 14 ++++++++------ 3 files changed, 16 insertions(+), 7 deletions(-)modules.d/95resume/install +0
-0
modules.d/95resume/install line 2
Quoted 2 lines
modules.d/95resume/install +0
-1@@ -1,5 +1,4 @@ #!/bin/bash -dracut_install echo
erm, not exactly.
Quoted 24 lines
modules.d/95resume/install +0
-0inst_hook cmdline 10 "$moddir/parse-resume.sh" inst_hook pre-udev 30 "$moddir/resume-genrules.sh" inst_hook mount 90 "$moddir/resume.sh"modules.d/95resume/parse-resume.sh +8
-0@@ -5,3 +5,11 @@ if resume=$(getarg resume=) && ! getarg noresume; then else unset resume fi + +case "$resume" in + LABEL=*) + resume="$(echo $resume | sed 's,/,\\x2f,g')" + resume="/dev/disk/by-label/${resume#LABEL=}" ;; + UUID=*) + resume="/dev/disk/by-uuid/${resume#UUID=}" ;; +esacmodules.d/95resume/resume-genrules.sh +0
-0
modules.d/95resume/resume-genrules.sh line 6
Quoted 6 lines
modules.d/95resume/resume-genrules.sh +0
-6@@ -1,6 +1,8 @@ -resume=$(getarg resume=) && ! getarg noresume && { -( - /bin/echo -e 'KERNEL=="'${resume#/dev/}'", RUN+="/bin/echo %M:%m > /sys/power/resume"' - /bin/echo -e 'SYMLINK=="'${resume#/dev/}'", RUN+="/bin/echo %M:%m > /sys/power/resume"' -) >> /etc/udev/rules.d/99-resume.rules -}
The real dependency is in the RUN+= part.
Quoted 8 lines
modules.d/95resume/resume-genrules.sh +8
-0+if [ -n "$resume" ]; then + ( + printf 'KERNEL=="%s", RUN+="/bin/echo %%M:%%m > /sys/power/resume"\n' \ + ${resume#/dev/} + printf 'SYMLINK=="%s", RUN+="/bin/echo %%M:%%m > /sys/power/resume"\n' \ + ${resume#/dev/} + ) >> /etc/udev/rules.d/99-resume.rules +fi
Signature · 8 lines
Victor Lowther RHCE# 805008539634727 LPIC-2# LPI000140019 -- To unsubscribe from this list: send the line "unsubscribe initramfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
A message that is not in the archive (sent off-list or not yet received): 1243848618.647.15.camel-76q0VzFBGGr21HsLBtNmTckMGDeJXHgy@public.gmane.org
Re: [RFC PATCH 5/9] resume: add support for labeled resume devices
Quoted 9 lines · Victor Lowther
modules.d/95resume/install line 2
Quoted 5 lines · David Dillow
modules.d/95resume/install +0
-1@@ -1,5 +1,4 @@ #!/bin/bash -dracut_install echoerm, not exactly.
Quoted 11 lines
modules.d/95resume/resume-genrules.sh line 6
Quoted 9 lines
modules.d/95resume/resume-genrules.sh +0
-6@@ -1,6 +1,8 @@ -resume=$(getarg resume=) && ! getarg noresume && { -( - /bin/echo -e 'KERNEL=="'${resume#/dev/}'", RUN+="/bin/echo %M:%m > /sys/power/resume"' - /bin/echo -e 'SYMLINK=="'${resume#/dev/}'", RUN+="/bin/echo %M:%m > /sys/power/resume"' -) >> /etc/udev/rules.d/99-resume.rules -}The real dependency is in the RUN+= part.
Of course, and it is obvious. -ESLEEPY is my excuse.
--
To unsubscribe from this list: send the line "unsubscribe initramfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
RFC PATCH 6/9 dracut-lib: add source_all to library
In reply to a message not in the archiveThe network root handler will need this.
--- modules.d/99base/dracut-lib | 6 ++++++ modules.d/99base/init | 6 ------ 2 files changed, 6 insertions(+), 6 deletions(-)
modules.d/99base/dracut-lib +6 -0
@@ -14,3 +14,9 @@ getarg() { done return 1 } + +source_all() { + local f + [ "$1" ] && [ -d "/$1" ] || return + for f in "/$1"/*.sh; do [ -f "$f" ] && . "$f"; done +}
modules.d/99base/init +0 -6
@@ -14,12 +14,6 @@ emergency_shell() sh -i } -source_all() { - local f - [ "$1" ] && [ -d "/$1" ] || return - for f in "/$1"/*.sh; do [ -f "$f" ] && . "$f"; done -} - export PATH=/sbin:/bin:/usr/sbin:/usr/bin export TERM=linux NEWROOT="/sysroot"
Signature · 6 lines
1.6.0.6 -- To unsubscribe from this list: send the line "unsubscribe initramfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
RFC PATCH 7/9 netroot: add common handler for network root devices
In reply to a message not in the archive/sbin/netroot is a jumping off point to allow various network root devices to share infrastructure. It will loop over scriptlets in the netroot handler, looking for a handler to run for this type of netroot. Handlers can do choose to act based on command line options to the kernel, or via DHCP options received on this interface. They should massage root= into a form suitable for their handler.
--- dracut | 2 +- modules.d/40network/60-net.rules | 1 + modules.d/40network/dhcp-fallback.sh | 14 +++++++++ modules.d/40network/ifup | 8 ++-- modules.d/40network/install | 2 + modules.d/40network/netroot | 52 ++++++++++++++++++++++++++++++++++ modules.d/99base/init | 11 ++++++- 7 files changed, 84 insertions(+), 6 deletions(-) create mode 100755 modules.d/40network/dhcp-fallback.sh create mode 100755 modules.d/40network/netroot
dracut +1 -1
@@ -96,7 +96,7 @@ if [[ -f $outfile && ! $force ]]; then exit 1 fi -hookdirs="cmdline pre-udev pre-mount pre-pivot mount emergency" +hookdirs="cmdline pre-udev netroot pre-mount pre-pivot mount emergency" readonly initdir=$(mktemp -d -t initramfs.XXXXXX) trap 'rm -rf "$initdir"' 0 # clean up after ourselves no matter how we die.
modules.d/40network/60-net.rules +1 -0
@@ -1 +1,2 @@ ACTION=="add", SUBSYSTEM=="net", RUN+="/sbin/ifup $env{INTERFACE}" +ACTION=="online", SUBSYSTEM=="net", RUN+="/sbin/netroot $env{INTERFACE}"
modules.d/40network/dhcp-fallback.sh new file +14 -0
@@ -0,0 +1,14 @@ +# We should go last, and default the root if needed + +if [ -z "$root" ]; then + root=dhcp +fi + +if [ "$root" = "dhcp" -a -z "$netroot" ]; then + rootok=1 + netroot=dhcp +fi + +if [ "${netroot+set}" = "set" ]; then + eval "echo netroot='$netroot'" > /tmp/netroot.info +fi
modules.d/40network/ifup +4 -4
@@ -12,8 +12,10 @@ getarg rdnetdebug && { netif=$1 -# bail immediatly if the interface is already up +# bail immediately if the interface is already up +# or we don't need the network [ -f "/tmp/net.$netif.up" ] && exit 0 +[ ! -f /tmp/netroot.info ] && exit 0 # loopback is always handled the same way [ "$netif" = "lo" ] && {
@@ -93,10 +95,8 @@ ip_to_var() { [ -n "$autoconf" ] || autoconf=off } -root=$(getarg root) ip=$(getarg ip) - -if [ "$root" = "dhcp" -a -z "$ip" ]; then +if [ -z "$ip" ]; then do_dhcp; else # spin through the kernel command line, looking for ip= lines
modules.d/40network/install +2 -0
@@ -2,8 +2,10 @@ dracut_install ip dhclient hostname instmods =net inst "$moddir/ifup" "/sbin/ifup" +inst "$moddir/netroot" "/sbin/netroot" inst "$moddir/dhclient-script" "/sbin/dhclient-script" instmods =networking ecb arc4 inst_rules "$moddir/60-net.rules" +inst_hook cmdline 99 "$moddir/dhcp-fallback.sh" inst_hook pre-pivot 10 "$moddir/kill-dhclient.sh" mkdir -p "${initdir}/var/run"
modules.d/40network/netroot new file +52 -0
52 lines not on this page · raw message
modules.d/99base/init +10 -1
@@ -47,12 +47,21 @@ fi if [ -z "${root%%error:*}" ]; then case "${root%%:*}" in - '') echo "FATAL: no root= option specified" ;; + '') echo "FATAL: no root= option specified, and no network support" ;; error) echo "FATAL: ${root#error:}" ;; esac emergency_shell fi +# Network root scripts may need updated root= options, +# so deposit them where they can see them (udev purges the env) +{ + echo "root='$root'" + echo "rflags='$rflags'" + echo "fstype='$fstype'" + echo "NEWROOT='$NEWROOT'" +} > /tmp/root.info + # pre-udev scripts run before udev starts, and are run only once. getarg 'rdbreak=pre-udev' && emergency_shell source_all pre-udev
Signature · 6 lines
1.6.0.6 -- To unsubscribe from this list: send the line "unsubscribe initramfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
A message that is not in the archive (sent off-list or not yet received): 7d7efa4a3d959a5f834cd1d5e73c1e15112aa77c.1243833882.git.dave-i1Mk8JYDVaaSihdK6806/[email protected]
Re: [RFC PATCH 7/9] netroot: add common handler for network root devices
Quoted 46 lines · David Dillow
/sbin/netrootis a jumping off point to allow various network root devices to share infrastructure. It will loop over scriptlets in the netroot handler, looking for a handler to run for this type of netroot. Handlers can do choose to act based on command line options to the kernel, or via DHCP options received on this interface. They should massage root= into a form suitable for their handler.--- dracut | 2 +- modules.d/40network/60-net.rules | 1 + modules.d/40network/dhcp-fallback.sh | 14 +++++++++ modules.d/40network/ifup | 8 ++-- modules.d/40network/install | 2 + modules.d/40network/netroot | 52 ++++++++++++++++++++++++++++++++++ modules.d/99base/init | 11 ++++++- 7 files changed, 84 insertions(+), 6 deletions(-) create mode 100755 modules.d/40network/dhcp-fallback.sh create mode 100755 modules.d/40network/netrootdracut +1
-1@@ -96,7 +96,7 @@ if [[ -f $outfile && ! $force ]]; then exit 1 fi -hookdirs="cmdline pre-udev pre-mount pre-pivot mount emergency" +hookdirs="cmdline pre-udev netroot pre-mount pre-pivot mount emergency" readonly initdir=$(mktemp -d -t initramfs.XXXXXX) trap 'rm -rf "$initdir"' 0 # clean up after ourselves no matter how we die.modules.d/40network/60-net.rules +1
-0@@ -1 +1,2 @@ ACTION=="add", SUBSYSTEM=="net", RUN+="/sbin/ifup $env{INTERFACE}" +ACTION=="online", SUBSYSTEM=="net", RUN+="/sbin/netroot $env{INTERFACE}"modules.d/40network/dhcp-fallback.sh new file +0
-0
modules.d/40network/dhcp-fallback.sh line 5
Quoted 5 lines
modules.d/40network/dhcp-fallback.sh new file +5
-0@@ -0,0 +1,14 @@ +# We should go last, and default the root if needed + +if [ -z "$root" ]; then + root=dhcp +fi
Is this really necessary? I mean if no root option is supplied, we don't really know if dhcp is really desired or the default /dev/sda1 fallback should be used.
I'd suggest to only ever do netroot if the user explicitely requests it. This would include disabling all network related udev scripts if we don't want netroot.
Quoted 26 lines
modules.d/40network/dhcp-fallback.sh new file +9
-0+ +if [ "$root" = "dhcp" -a -z "$netroot" ]; then + rootok=1 + netroot=dhcp +fi + +if [ "${netroot+set}" = "set" ]; then + eval "echo netroot='$netroot'" > /tmp/netroot.info +fimodules.d/40network/ifup +3
-1@@ -12,8 +12,10 @@ getarg rdnetdebug && { netif=$1 -# bail immediatly if the interface is already up +# bail immediately if the interface is already up +# or we don't need the network [ -f "/tmp/net.$netif.up" ] && exit 0 +[ ! -f /tmp/netroot.info ] && exit 0 # loopback is always handled the same way [ "$netif" = "lo" ] && {
modules.d/40network/ifup ip_to_var() { · line 99
Quoted 7 lines
modules.d/40network/ifup +0
-3@@ -93,10 +95,8 @@ ip_to_var() { [ -n "$autoconf" ] || autoconf=off } -root=$(getarg root) ip=$(getarg ip) - -if [ "$root" = "dhcp" -a -z "$ip" ]; then
Hmmm... Weird configuration: What do we do if root=dhcp and the ip options contain's non-dhcp related stuff? (Never thought of that before)
Quoted 67 lines
modules.d/40network/ifup +1
-0+if [ -z "$ip" ]; then do_dhcp; else # spin through the kernel command line, looking for ip= linesmodules.d/40network/install +2
-0@@ -2,8 +2,10 @@ dracut_install ip dhclient hostname instmods =net inst "$moddir/ifup" "/sbin/ifup" +inst "$moddir/netroot" "/sbin/netroot" inst "$moddir/dhclient-script" "/sbin/dhclient-script" instmods =networking ecb arc4 inst_rules "$moddir/60-net.rules" +inst_hook cmdline 99 "$moddir/dhcp-fallback.sh" inst_hook pre-pivot 10 "$moddir/kill-dhclient.sh" mkdir -p "${initdir}/var/run"modules.d/40network/netroot new file +42
-0@@ -0,0 +1,52 @@ +#!/bin/sh + +. /lib/dracut-lib + +getarg rdnetdebug && { + exec >/tmp/netroot.$1.$$.out + exec 2>>/tmp/netroot.$1.$$.out + set -x +} + +# Only try to configure from one network interface at a time +# +[ "$NETROOT_LOCKED" ] || { + NETROOT_LOCKED=true + export NETROOT_LOCKED + exec flock -xo /tmp/netroot.lock -c "$0 $*" + exit 1 +} + +netif=$1 + +# If we've already found a root, or we don't have the info we need, +# then no point in looking further +# +[ -e /tmp/netroot.done ] && exit 0 +[ -s /tmp/netroot.info -a -s /tmp/root.info ] || exit 0 + +# Pick up our config from the command line; we may already know the +# handler to run +# +. /tmp/root.info +. /tmp/netroot.info +[ -e /tmp/net.$netif.dhcpopts ] && . /tmp/net.$netif.dhcpopts + +# Now, let the installed network root handlers figure this out +# +source_all netroot + +# If we didn't get a handler set, then we're done +# +if [ -z "$handler" ]; then + # XXX informative error message?
modules.d/40network/netroot line 52
Quoted 10 lines
modules.d/40network/netroot new file +10
-0+ exit 0 +fi + +# Run the handler; don't store the root, it may change from device to device +# XXX other variables to export? +export NEWROOT +if $handler $netif $root; then + >/tmp/netroot.done +fi +exit 0
Question 1: Is it really necessary to have each handler implements it's own mount-call? I don't know about iSCSI but isn't it usually just a matter of setting fstype, options and source? I think this could be generalized.
Question 2: How do plan to loop over mount-scripts? As you described if might be desirable to retry mounting if the server is overloaded. I see a few problems there if we loop inside netboot/handler-scripts: We could be trying to mount on the wrong interface.
Quoted 17 lines
modules.d/99base/init +3
-1@@ -47,12 +47,21 @@ fi if [ -z "${root%%error:*}" ]; then case "${root%%:*}" in - '') echo "FATAL: no root= option specified" ;; + '') echo "FATAL: no root= option specified, and no network support" ;; error) echo "FATAL: ${root#error:}" ;; esac emergency_shell fi +# Network root scripts may need updated root= options, +# so deposit them where they can see them (udev purges the env)
modules.d/99base/init fi · line 67
Quoted 10 lines
modules.d/99base/init +7
-0+{ + echo "root='$root'" + echo "rflags='$rflags'" + echo "fstype='$fstype'" + echo "NEWROOT='$NEWROOT'" +} > /tmp/root.info + # pre-udev scripts run before udev starts, and are run only once. getarg 'rdbreak=pre-udev' && emergency_shell source_all pre-udev
--
To unsubscribe from this list: send the line "unsubscribe initramfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
A message that is not in the archive (sent off-list or not yet received): [email protected]
Re: [RFC PATCH 7/9] netroot: add common handler for network root devices
Quoted 8 lines · Seewer Philippe
modules.d/40network/dhcp-fallback.sh line 5
Quoted 3 lines · David Dillow
modules.d/40network/dhcp-fallback.sh new file +3
-0+if [ -z "$root" ]; then + root=dhcp +fiIs this really necessary? I mean if no root option is supplied, we don't really know if dhcp is really desired or the default
/dev/sda1fallback should be used.
I tend to think that any default root= needs to go -- a quick glance through nash's source code doesn't seem show a default root device there. In this case, we'd only default to dhcp if the network module is included.
Quoted 3 lines
I'd suggest to only ever do netroot if the user explicitely requests it. This would include disabling all network related udev scripts if we don't want netroot.
This happens if you don't include the network module, or specify a root= line that doesn't require the network. In that case we just exit early from ifup and never do any configuration.
Quoted 4 lines
Quoted 1 line
-if [ "$root" = "dhcp" -a -z "$ip" ]; then
Hmmm... Weird configuration: What do we do if root=dhcp and the ip options contain's non-dhcp related stuff? (Never thought of that before)
Currently, I use the ip= lines as an override on what we get back from DHCP. If you specify enough info, no DHCP is used.
Quoted 4 lines
Quoted 4 lines
modules.d/40network/netroot new file +4
-0+# Run the handler; don't store the root, it may change from device to device +# XXX other variables to export? +export NEWROOT +if $handler $netif $root; then
Quoted 8 lines
modules.d/40network/netroot line 52
Quoted 3 lines
modules.d/40network/netroot new file +3
-0+ >/tmp/netroot.done +fi +exit 0Question 1: Is it really necessary to have each handler implements it's own mount-call? I don't know about iSCSI but isn't it usually just a matter of setting fstype, options and source? I think this could be generalized.
In the case of network-block-device, I'd like to be able to use the existing block udev handlers. NFS root can mount itself.
Quoted 4 lines
Question 2: How do plan to loop over mount-scripts? As you described if might be desirable to retry mounting if the server is overloaded. I see a few problems there if we loop inside netboot/handler-scripts: We could be trying to mount on the wrong interface.
The loop over the mount-scripts seems to be vestigial -- we mount block root via udev now. I haven't thought too hard about how to handle the fail loop for netboot, but I figure it would either just walk the list of network interfaces and send uevents, or just do another udevadm trigger and settle pair.
Speaking of which, at some point the network root stuff is going to want to be able to change the settle timeout.
--
To unsubscribe from this list: send the line "unsubscribe initramfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
RFC PATCH 8/9 nfsroot: move to netroot framework
In reply to a message not in the archiveParse and convert commandline options in the cmdline hook, and fill in the missing pieces in the netroot hook. This also allows root=dhcp to work as expected.
--- modules.d/95nfs/60-nfsroot.rules | 1 - modules.d/95nfs/install | 10 +--- modules.d/95nfs/nfs-netroot.sh | 52 +++++++++++++++++++ modules.d/95nfs/nfsroot | 105 +++++++++++-------------------------- modules.d/95nfs/parse-nfsroot.sh | 48 +++++++++++++++++ modules.d/99base/dracut-lib | 16 ++++++ 6 files changed, 149 insertions(+), 83 deletions(-) delete mode 100644 modules.d/95nfs/60-nfsroot.rules create mode 100755 modules.d/95nfs/nfs-netroot.sh create mode 100755 modules.d/95nfs/parse-nfsroot.sh
modules.d/95nfs/60-nfsroot.rules deleted +0 -1
@@ -1 +0,0 @@ -ACTION=="online", SUBSYSTEM=="net", RUN+="/sbin/nfsroot $env{INTERFACE}"
modules.d/95nfs/install +2 -8
@@ -1,23 +1,17 @@ #!/bin/sh dracut_install rpcbind rpc.statd mount.nfs mount.nfs4 umount dracut_install /etc/netconfig /etc/passwd /etc/services - -# XXX debug stuff -dracut_install rpcinfo ping strace dmesg nc free df - dracut_install rpc.idmapd /etc/idmapd.conf instmods nfs -inst_rules "$moddir/60-nfsroot.rules" +inst_hook cmdline 90 "$moddir/parse-nfsroot.sh" +inst_hook netroot 90 "$moddir/nfs-netroot.sh" inst_hook pre-pivot 70 "$moddir/nfsroot-cleanup.sh" inst "$moddir/nfsroot" "/sbin/nfsroot" mkdir -p "$initdir/var/lib/nfs/rpc_pipefs" mkdir -p "$initdir/var/lib/rpcbind" mkdir -p "$initdir/var/lib/nfs/statd/sm" -# XXX debug -mkdir -p "$initdir/mnt" - # Rather than copy the passwd file in, just set a user for rpcbind # We'll save the state and restart the daemon from the root anyway #echo "rpc:x:32:32:Rpcbind:/var/lib/rpcbind:/bin/false" >> "$initdir/etc/passwd"
modules.d/95nfs/nfs-netroot.sh new file +52 -0
52 lines not on this page · raw message
modules.d/95nfs/nfsroot +31 -74
143 lines not on this page · raw message
modules.d/95nfs/parse-nfsroot.sh new file +48 -0
48 lines not on this page · raw message
modules.d/99base/dracut-lib +16 -0
@@ -20,3 +20,19 @@ source_all() { [ "$1" ] && [ -d "/$1" ] || return for f in "/$1"/*.sh; do [ -f "$f" ] && . "$f"; done } + +check_occurances() { + # Count the number of times the character $ch occurs in $str + # Return 0 if the count matches the expected number, 1 otherwise + local str="$1" + local ch="$2" + local expected="$3" + local count=0 + + while [ "${str#*$ch}" != "${str}" ]; do + str="${str#*$ch}" + count=$(( $count + 1 )) + done + + [ $count -eq $expected ] +}
Signature · 6 lines
1.6.0.6 -- To unsubscribe from this list: send the line "unsubscribe initramfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
RFC PATCH 9/9 Add NBD support
In reply to a message not in the archiveThis adds basic support for root on a network block device to the netroot framework.
--- modules.d/95nbd/check | 11 ++++ modules.d/95nbd/install | 7 +++ modules.d/95nbd/nbd-netroot.sh | 11 ++++ modules.d/95nbd/nbdroot | 96 ++++++++++++++++++++++++++++++++++++++ modules.d/95nbd/parse-nbdroot.sh | 49 +++++++++++++++++++ 5 files changed, 174 insertions(+), 0 deletions(-) create mode 100755 modules.d/95nbd/check create mode 100755 modules.d/95nbd/install create mode 100755 modules.d/95nbd/nbd-netroot.sh create mode 100755 modules.d/95nbd/nbdroot create mode 100755 modules.d/95nbd/parse-nbdroot.sh
modules.d/95nbd/check new file +11 -0
@@ -0,0 +1,11 @@ +#!/bin/sh +# We depend on network modules being loaded +[ "$1" = "-d" ] && echo network + +# If hostonly was requested, fail the check if we are not actually +# booting from root. +[ "$1" = "-h" ] && ! egrep -q '/ /dev/nbd[0-9]*' /proc/mounts && exit 1 + +# If our prerequisites are not met, fail anyways. +which nbd-client >/dev/null 2>&1 || exit 1 +exit 0
modules.d/95nbd/install new file +7 -0
@@ -0,0 +1,7 @@ +#!/bin/bash + +inst nbd-client +inst_hook cmdline 90 "$moddir/parse-nbdroot.sh" +inst_hook netroot 90 "$moddir/nbd-netroot.sh" +inst "$moddir/nbdroot" "/sbin/nbdroot" +instmods nbd
modules.d/95nbd/nbd-netroot.sh new file +11 -0
@@ -0,0 +1,11 @@ +#!/bin/sh # for highlighting + +if [ "$root" = "dhcp" ]; then + if [ -n "$new_root_path" -a -z "${new_root_path%%nbd:*}" ]; then + root="$new_root_path" + fi +fi + +if [ -z "${root%nbd:*}" ]; then + handler=/sbin/nbdroot +fi
modules.d/95nbd/nbdroot new file +96 -0
96 lines not on this page · raw message
modules.d/95nbd/parse-nbdroot.sh new file +49 -0
49 lines not on this page · raw message
Signature · 6 lines
1.6.0.6 -- To unsubscribe from this list: send the line "unsubscribe initramfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
A message that is not in the archive (sent off-list or not yet received): 2b117123ecd2d93cec8598593e966029dfb4777e.1243833882.git.dave-i1Mk8JYDVaaSihdK6806/[email protected]
Re: [RFC PATCH 9/9] Add NBD support
Quoted 147 lines · David Dillow
This adds basic support for root on a network block device to the netroot framework.
--- modules.d/95nbd/check | 11 ++++ modules.d/95nbd/install | 7 +++ modules.d/95nbd/nbd-netroot.sh | 11 ++++ modules.d/95nbd/nbdroot | 96 ++++++++++++++++++++++++++++++++++++++ modules.d/95nbd/parse-nbdroot.sh | 49 +++++++++++++++++++ 5 files changed, 174 insertions(+), 0 deletions(-) create mode 100755 modules.d/95nbd/check create mode 100755 modules.d/95nbd/install create mode 100755 modules.d/95nbd/nbd-netroot.sh create mode 100755 modules.d/95nbd/nbdroot create mode 100755 modules.d/95nbd/parse-nbdroot.shmodules.d/95nbd/check new file +11
-0@@ -0,0 +1,11 @@ +#!/bin/sh +# We depend on network modules being loaded +[ "$1" = "-d" ] && echo network + +# If hostonly was requested, fail the check if we are not actually +# booting from root. +[ "$1" = "-h" ] && ! egrep -q '/ /dev/nbd[0-9]*' /proc/mounts && exit 1 + +# If our prerequisites are not met, fail anyways. +which nbd-client >/dev/null 2>&1 || exit 1 +exit 0modules.d/95nbd/install new file +7
-0@@ -0,0 +1,7 @@ +#!/bin/bash + +inst nbd-client +inst_hook cmdline 90 "$moddir/parse-nbdroot.sh" +inst_hook netroot 90 "$moddir/nbd-netroot.sh" +inst "$moddir/nbdroot" "/sbin/nbdroot" +instmods nbdmodules.d/95nbd/nbd-netroot.sh new file +11
-0@@ -0,0 +1,11 @@ +#!/bin/sh # for highlighting + +if [ "$root" = "dhcp" ]; then + if [ -n "$new_root_path" -a -z "${new_root_path%%nbd:*}" ]; then + root="$new_root_path" + fi +fi + +if [ -z "${root%nbd:*}" ]; then + handler=/sbin/nbdroot +fimodules.d/95nbd/nbdroot new file +77
-0@@ -0,0 +1,96 @@ +#!/bin/sh + +. /lib/dracut-lib + +PATH=$PATH:/sbin:/usr/sbin + +# XXX needs error handling like ifup/dhclient-script + +if getarg rdnetdebug; then + exec > /tmp/nbdroot.$1.$$.out + exec 2>> /tmp/nbdroot.$1.$$.out + set -x +fi + +# root is in the form root=nbd:server:port:fstype:fsopts:nbdopts +netif="$1" +root="$2" + +root=${root#nbd:} +nbdserver=${root%%:*}; root=${root#*:} +nbdport=${root%%:*}; root=${root#*:} +nbdfstype=${root%%:*}; root=${root#*:} +nbdflags=${root%%:*} +nbdopts=${root#*:} + +if [ "$nbdopts" = "$nbdflags" ]; then + unset nbdopts +fi +if [ "$nbdflags" = "$nbdfstype" ]; then + unset nbdflags +fi +if [ "$nbdfstype" = "$nbdport" ]; then + unset nbdfstype +fi +if [ -z "$nbdfstype" ]; then + nbdfstype=auto +fi + +# look through the NBD options and pull out the ones that need to +# go before the host etc. Append a ',' so we know we terminate the loop +nbdopts=${nbdopts}, +while [ -n "$nbdopts" ]; do + f=${nbdopts%%,*} + nbdopts=${nbdopts#*,} + if [ -z "$f" ]; then + break + fi + if [ -z "${f%bs=*}" -o -z "${f%timeout=*}" ]; then + preopts="$preopts $f" + continue + fi + opts="$opts $f" +done + +# look through the flags and see if any are overridden by the command line +nbdflags=${nbdflags}, +while [ -n "$nbdflags" ]; do + f=${nbdflags%%,*} + nbdflags=${nbdflags#*,} + if [ -z "$f" ]; then + break + fi + if [ "$f" = "ro" -o "$f" = "rw" ]; then + nbdrw=$f + continue + fi + fsopts=${fsopts+$fsopts,}$f +done + +getarg ro && nbdrw=ro +getarg rw && nbdrw=rw +fsopts=${fsopts+$fsopts,}${nbdrw} + +modprobe nbd || exit 1 + +# XXX better way to wait for the device to be made? +i=0
modules.d/95nbd/nbdroot line 87
Quoted 10 lines
modules.d/95nbd/nbdroot new file +10
-0+while [ ! -b /dev/nbd0 ]; do + [ $i -ge 20 ] && exit 1 + sleep 0.1 + i=$(( $i + 1)) +done + +# XXX netroot expects to have the handler mount things, but we should +# XXX allow LVM, LUKS, etc over nbd + +nbd-client $preopts "$nbdserver" "$nbdport" /dev/nbd0 $opts || exit 1
Ah, but we are not really a netroot in the sense that NFS is -- all we are doing is attaching a block device. Once it is attached the usual root-on-block-device rules should kick in as soon as udev sees the block devices.
modules.d/95nbd/nbdroot line 94
Quoted 6 lines
modules.d/95nbd/nbdroot new file +6
-0+if ! mount -t $nbdfstype -o$fsopts /dev/nbd0 $NEWROOT; then + # Mount failed, clean up after ourselves so if we try a different + # interface it can succeed + nbd-client -d /dev/nbd0 + exit 1 +fi
why not just poke udev with udevadm trigger if there is any doubt?
Quoted 56 lines
modules.d/95nbd/nbdroot new file +1
-0+exit 0modules.d/95nbd/parse-nbdroot.sh new file +49
-0@@ -0,0 +1,49 @@ +#!/bin/dash + +# It'd be nice if this could share rules with 99-block.sh, but since +# the kernel side adds nbd{1..16} when the module is loaded -- before +# they are associated with a server -- we cannot use the udev add rule +# to find it +# +# XXX actually we could, if we move to root=XXX and netroot=XXX, then +# you could do root=LABEL=/ nbdroot=XXX, or netroot=nbd:XXX +# +# However, we need to be 90-nbd.sh to catch root=/dev/nbd* +# +# Preferred format: +# root=nbd:srv:port[:fstype[:rootflags[:nbdopts]]] +# +# nbdopts is a comma seperated list of options to give to nbd-client +# +# +# Legacy formats: +# nbdroot=srv,port +# nbdroot=srv:port[:fstype[:rootflags[:nbdopts]]] +# root=dhcp nbdroot=srv:port[:fstype[:rootflags[:nbdopts]]] +# root=nbd nbdroot=srv:port[:fstype[:rootflags[:nbdopts]]] +# + +case "$root" in + nbd|dhcp|'') + if getarg nbdroot= > /dev/null; then + root=nbd:$(getarg nbdroot=) + fi + ;; +esac + +# Convert the Debian style to our syntax, but avoid matches on fs arguments +case "$root" in + nbd:*,*) + if check_occurances "$root" ',' 1 && check_occurances "$root" ':' 1; + then + root=${root%*,}:${root#*,} + fi + ;; +esac + +if [ "${root%%:*}" = "nbd" ]; then + # XXX validate options here? + # XXX generate udev rules? + rootok=1 + netroot=nbd +fi
Signature · 8 lines
Victor Lowther RHCE# 805008539634727 LPIC-2# LPI000140019 -- To unsubscribe from this list: send the line "unsubscribe initramfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
A message that is not in the archive (sent off-list or not yet received): 1243849301.647.20.camel-76q0VzFBGGr21HsLBtNmTckMGDeJXHgy@public.gmane.org
Re: [RFC PATCH 9/9] Add NBD support
Quoted 11 lines · Victor Lowther
modules.d/95nbd/nbdroot line 87
Quoted 4 lines · David Dillow
modules.d/95nbd/nbdroot new file +4
-0+# XXX netroot expects to have the handler mount things, but we should +# XXX allow LVM, LUKS, etc over nbd + +nbd-client $preopts "$nbdserver" "$nbdport" /dev/nbd0 $opts || exit 1Ah, but we are not really a netroot in the sense that NFS is -- all we are doing is attaching a block device. Once it is attached the usual root-on-block-device rules should kick in as soon as udev sees the block devices.
Exactly, hence the comment -- and one elsewhere about wanting to move the mount to the network block devices via udev. Unfortunately, NBD does all of its device adds at module load time, so we cannot trigger a mount on those as there's nothing behind the device.
I was thinking about 'echo add /path/to/nbd0/uevent' here so we could force another loop through udev.
Quoted 8 lines
modules.d/95nbd/nbdroot line 94
Quoted 6 lines
modules.d/95nbd/nbdroot new file +6
-0+if ! mount -t $nbdfstype -o$fsopts /dev/nbd0 $NEWROOT; then + # Mount failed, clean up after ourselves so if we try a different + # interface it can succeed + nbd-client -d /dev/nbd0 + exit 1 +fiwhy not just poke udev with udevadm trigger if there is any doubt?
Not sure what you mean by that in this context -- do you mean the root mount via udev as discussed above, or the cleanup right here?
I'm not sure how to do the cleanup when mounting via udev; I'd need to think. I'm not sure doing udevadm trigger or udevadm settle inside a udev handler is a good thing...
--
To unsubscribe from this list: send the line "unsubscribe initramfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
A message that is not in the archive (sent off-list or not yet received): 1243853722.3844.122.camel-1q1vX8mYZiGLUyTwlgNVppKKF0rrzTr+@public.gmane.org
Re: [RFC PATCH 9/9] Add NBD support
Quoted 13 lines · David Dillow
Quoted 11 lines · Victor Lowther
modules.d/95nbd/nbdroot line 87
Quoted 4 lines · David Dillow
modules.d/95nbd/nbdroot new file +4
-0+# XXX netroot expects to have the handler mount things, but we should +# XXX allow LVM, LUKS, etc over nbd + +nbd-client $preopts "$nbdserver" "$nbdport" /dev/nbd0 $opts || exit 1Ah, but we are not really a netroot in the sense that NFS is -- all we are doing is attaching a block device. Once it is attached the usual root-on-block-device rules should kick in as soon as udev sees the block devices.
Quoted 4 lines
Exactly, hence the comment -- and one elsewhere about wanting to move the mount to the network block devices via udev. Unfortunately, NBD does all of its device adds at module load time, so we cannot trigger a mount on those as there's nothing behind the device.
ew, narsty. Sounds just as annoying as the loopback device.
Quoted 12 lines
I was thinking about 'echo add /path/to/nbd0/uevent' here so we could force another loop through udev.
Quoted 8 lines
modules.d/95nbd/nbdroot line 94
Quoted 6 lines
modules.d/95nbd/nbdroot new file +6
-0+if ! mount -t $nbdfstype -o$fsopts /dev/nbd0 $NEWROOT; then + # Mount failed, clean up after ourselves so if we try a different + # interface it can succeed + nbd-client -d /dev/nbd0 + exit 1 +fiwhy not just poke udev with udevadm trigger if there is any doubt?
Quoted 2 lines
Not sure what you mean by that in this context -- do you mean the root mount via udev as discussed above, or the cleanup right here?
The root mount.
Quoted 2 lines
I'm not sure how to do the cleanup when mounting via udev; I'd need to think.
Perhaps a mount-failed hook?
Quoted 1 line
Signature · 8 lines
Victor Lowther RHCE# 805008539634727 LPIC-2# LPI000140019 -- To unsubscribe from this list: send the line "unsubscribe initramfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Looks good!
Quoted 4 lines · David Dillow
This builds on the NFS root work to allow other network methods to hook into the parsing and network infrastructure. One network interface is configured at a time, but if we don't find a root there, it may not be unconfigured -- this should probably be added.
This is a definite must. Actually, to support multiple interfaces we should even go so far and ensure that there is only one interface configured at any one time.
--> Consider the following case: Two interfaces and both receive a valid default route via dhcp. If we allow both interfaces to be configured after receiving the dhcp-reply, the second default-route will go byebye. I suggest to move the actual interface (de-)configuration into the netroot script.
Regards,
Philippe
--
To unsubscribe from this list: send the line "unsubscribe initramfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html