Skip to contentSkip to conversation

*** SUBJECT HERE ***

PATCH In review Harald Hoyer 4 participants 21 messages Jul 3, 2009 – Jul 13, 2009 10 messages not in the archive

lore
Share & tools
lore
#0 lore raw

cover *** SUBJECT HERE ***

Some important things I changed today.

Harald Hoyer (10):
add binutiles requirement to specfile (because of nm) output everything to /dev/kmesg and add dmesg for the emergency_shell Defer mount to the real mount loop
remove 50plymouth-pre0.7 module
add firmware packages to be required by the dracut-generic package add rm to be installed for initqueue
fail iscsiroot, if iscsistart fails
put back the nfs mount in the udev event
initqueue now loops until /dev/root exists or root is mounted add "rdshell" command line argument

 dracut.8                                           |    3 +
 dracut.spec                                        |    8 ++-
 modules.d/40network/net-genrules.sh                |    8 +-
 modules.d/50plymouth-pre0.7/63-luks.rules          |   11 --
 modules.d/50plymouth-pre0.7/check                  |    3 -
 modules.d/50plymouth-pre0.7/cryptroot-ask.sh       |    4 -
 modules.d/50plymouth-pre0.7/install                |    8 --
 modules.d/50plymouth-pre0.7/plymouth-newroot.sh    |    4 -
 .../50plymouth-pre0.7/plymouth-populate-initrd     |   25 -----
 modules.d/50plymouth-pre0.7/plymouth-start.sh      |   31 ------
 modules.d/50plymouth/63-luks.rules                 |    2 +-
 modules.d/90crypt/70-luks.rules                    |    2 +-
 modules.d/90dmraid/61-dmraid.rules                 |   12 ++
 modules.d/90dmraid/dmraid.sh                       |    3 -
 modules.d/90dmraid/dmraid_scan                     |    8 ++
 modules.d/90dmraid/install                         |    3 +-
 modules.d/95debug/install                          |    2 +-
 modules.d/95iscsi/iscsiroot                        |    4 +-
 modules.d/95nbd/nbdroot                            |    7 +-
 modules.d/95nfs/nfsroot                            |   22 ++--
 modules.d/95rootfs-block/block-genrules.sh         |   12 ++-
 modules.d/95rootfs-block/install                   |    1 +
 modules.d/99base/init                              |  111 ++++++++++++--------
 modules.d/99base/initqueue                         |   11 ++-
 modules.d/99base/install                           |    3 +-
 test/TEST-10-RAID/test.sh                          |    4 +-
 test/TEST-20-NFS/test.sh                           |    2 +-
 test/TEST-30-ISCSI/test.sh                         |    4 +-
 test/TEST-40-NBD/test.sh                           |    4 +-
 29 files changed, 153 insertions(+), 169 deletions(-)
 delete mode 100644 modules.d/50plymouth-pre0.7/63-luks.rules
 delete mode 100755 modules.d/50plymouth-pre0.7/check
 delete mode 100755 modules.d/50plymouth-pre0.7/cryptroot-ask.sh
 delete mode 100755 modules.d/50plymouth-pre0.7/install
 delete mode 100755 modules.d/50plymouth-pre0.7/plymouth-newroot.sh
 delete mode 100755 modules.d/50plymouth-pre0.7/plymouth-populate-initrd
 delete mode 100755 modules.d/50plymouth-pre0.7/plymouth-start.sh
 create mode 100644 modules.d/90dmraid/61-dmraid.rules
 delete mode 100644 modules.d/90dmraid/dmraid.sh
 create mode 100755 modules.d/90dmraid/dmraid_scan

--
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): 1246639520-3094-1-git-send-email-harald-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org

#2 lore raw

PATCH 1/10 add binutiles requirement to specfile (because of nm)

---
 dracut.spec |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
dracut.spec +1 -0
index 7b7a224..3e33819 100644
@@ -27,6 +27,7 @@ Requires: module-init-tools
 Requires: cpio
 Requires: coreutils
 Requires: findutils
+Requires: binutils
 Requires: grep
 Requires: mktemp
 Requires: mount
Signature · 6 lines
1.6.2.5

--
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
#3 lore raw

PATCH 2/10 output everything to /dev/kmesg and add dmesg for the emergency_shell

In reply to a message not in the archive
---
 modules.d/99base/init    |    9 ++++++++-
 modules.d/99base/install |    2 +-
 2 files changed, 9 insertions(+), 2 deletions(-)
modules.d/99base/init +8 -1
index 701706d..b49ba21 100755
@@ -7,6 +7,8 @@
 
 emergency_shell()
 {
+    exec >/dev/console 2>&1 </dev/console
+    getarg rdinitdebug || dmesg
     source_all emergency
     echo ; echo
     echo "Bug in initramfs /init detected. Dropping to a shell. Good luck!"
@@ -64,7 +66,12 @@ if [ ! -c /dev/ptmx ]; then
     fi
 fi
 
-getarg rdinitdebug && set -x
+if getarg rdinitdebug; then
+    set -x
+else
+    exec >/dev/kmsg 2>&1
+fi
+
 mkdir /dev/shm
 mkdir /dev/pts
 mount -t devpts -o gid=5,mode=620 /dev/pts /dev/pts >/dev/null 2>&1
modules.d/99base/install +1 -1
index ff15200..4ecba9c 100755
@@ -1,5 +1,5 @@
 #!/bin/bash
-dracut_install mount mknod mkdir modprobe pidof sleep chroot sed ls flock cp mv
+dracut_install mount mknod mkdir modprobe pidof sleep chroot sed ls flock cp mv dmesg 
 if [ ! -e "${initdir}/bin/sh" ]; then
     dracut_install bash
     (ln -s bash "${initdir}/bin/sh" || :)
Signature · 6 lines
1.6.2.5

--
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): 1246639520-3094-3-git-send-email-harald-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org

#5 lore raw

Re: [PATCH 02/10] output everything to /dev/kmesg and add dmesg for the emergency_shell

modules.d/99base/init line 11

Quoted 10 lines · Harald Hoyer
modules.d/99base/init +2 -0
index 701706d..b49ba21 100755
@@ -7,6 +7,8 @@
 
 emergency_shell()
 {
+    exec >/dev/console 2>&1 </dev/console
+    getarg rdinitdebug || dmesg

Ugh, please no. If I want dmesg output in my emergency shell, I can type 'dmesg'. Doing it for me means I may push valuable information from rdinitdebug out of my scrollback buffer before I've had a chance to review it and write it down.

Also, this adds a dependency on dmesg to a stripped down install, which is counter to (my) goal of a smaller initramfs over time.

modules.d/99base/init if [ ! -c /dev/ptmx ]; then · line 73

Quoted 6 lines
modules.d/99base/init +5 -1
-getarg rdinitdebug && set -x
+if getarg rdinitdebug; then
+    set -x
+else
+    exec >/dev/kmsg 2>&1
+fi

I'm really not happy about polluting the kernel message source with dracut messages. I know it is convenient, but in my opinion, dmesg should only show me kernel messages, not a mixture of kernel and userspace.

At the very least, we need to add an indication that the message is from dracut, not the kernel.

--
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): 1246644686.13823.5.camel-1q1vX8mYZiGLUyTwlgNVppKKF0rrzTr+@public.gmane.org

#7 lore raw

Re: [PATCH 02/10] output everything to /dev/kmesg and add dmesg for the emergency_shell

Am 03.07.2009 20:11, schrieb David Dillow:

Quoted 8 lines · Harald Hoyer
Quoted 7 lines
modules.d/99base/init +0 -0
index 701706d..b49ba21 100755
@@ -7,6 +7,8 @@
 
Quoted 9 lines

modules.d/99base/init line 11

Quoted 4 lines
modules.d/99base/init +2 -0
  emergency_shell()
  {
+    exec>/dev/console 2>&1</dev/console
+    getarg rdinitdebug || dmesg

Ugh, please no. If I want dmesg output in my emergency shell, I can type 'dmesg'. Doing it for me means I may push valuable information from rdinitdebug out of my scrollback buffer before I've had a chance to review it and write it down.

ok

Quoted 16 lines

Also, this adds a dependency on dmesg to a stripped down install, which is counter to (my) goal of a smaller initramfs over time.

modules.d/99base/init if [ ! -c /dev/ptmx ]; then · line 73

Quoted 6 lines
modules.d/99base/init +5 -1
-getarg rdinitdebug&&  set -x
+if getarg rdinitdebug; then
+    set -x
+else
+    exec>/dev/kmsg 2>&1
+fi

I'm really not happy about polluting the kernel message source with dracut messages. I know it is convenient, but in my opinion, dmesg should only show me kernel messages, not a mixture of kernel and userspace.

Quoted 2 lines

At the very least, we need to add an indication that the message is from dracut, not the kernel.

hmm, ok

#8 lore raw

PATCH 3/10 Defer mount to the real mount loop

In reply to a message not in the archive

Udev rules set a /dev/root symlink to the real root and add a mount script to /mount/. This enables the proper use of pre-mount scripts and prevents mount being killed by a udev timeout.

---
 modules.d/40network/net-genrules.sh        |    8 ++++----
 modules.d/95debug/install                  |    2 +-
 modules.d/95iscsi/iscsiroot                |    2 +-
 modules.d/95nbd/nbdroot                    |    7 ++++---
 modules.d/95nfs/nfsroot                    |   23 +++++++++++++----------
 modules.d/95rootfs-block/block-genrules.sh |    8 ++++----
 modules.d/99base/init                      |    9 ++++++++-
 7 files changed, 35 insertions(+), 24 deletions(-)
modules.d/40network/net-genrules.sh +4 -4
index f843c53..dbd0474 100755
@@ -19,20 +19,20 @@ fix_bootif() {
     BOOTIF=$(getarg 'BOOTIF=')
     if [ -n "$BOOTIF" ] ; then
 	BOOTIF=$(fix_bootif "$BOOTIF")
-	printf 'ACTION=="add", SUBSYSTEM=="net", ATTR{address}=="%s", RUN+="/sbin/initqueue /sbin/ifup $env{INTERFACE}"\n' "$BOOTIF"
+	printf 'ACTION=="add", SUBSYSTEM=="net", ATTR{address}=="%s", RUN+="/sbin/ifup $env{INTERFACE}"\n' "$BOOTIF"
 
     # If we have to handle multiple interfaces, handle only them.
     elif [ -n "$IFACES" ] ; then
 	for iface in $IFACES ; do
-	    printf 'ACTION=="add", SUBSYSTEM=="net", KERNEL=="%s", RUN+="/sbin/initqueue /sbin/ifup $env{INTERFACE}"\n' "$iface"
+	    printf 'ACTION=="add", SUBSYSTEM=="net", KERNEL=="%s", RUN+="/sbin/ifup $env{INTERFACE}"\n' "$iface"
 	done
 
     # Default: We don't know the interface to use, handle all
     else
-	printf 'ACTION=="add", SUBSYSTEM=="net", RUN+="/sbin/initqueue /sbin/ifup $env{INTERFACE}"\n'
+	printf 'ACTION=="add", SUBSYSTEM=="net", RUN+="/sbin/ifup $env{INTERFACE}"\n'
     fi
 
     # Udev event 'online' only gets fired from ifup/dhclient-script.
     # No special rules required
-    printf 'ACTION=="online", SUBSYSTEM=="net", RUN+="/sbin/initqueue /sbin/netroot $env{INTERFACE}"\n'
+    printf 'ACTION=="online", SUBSYSTEM=="net", RUN+="/sbin/netroot $env{INTERFACE}"\n'
 } > /etc/udev/rules.d/60-net.rules
modules.d/95debug/install +1 -1
index 33a724d..6d4f089 100755
@@ -1,3 +1,3 @@
 #!/bin/bash
-dracut_install ln ps grep more dmesg cat rm strace free showmount
+dracut_install ln ps grep more cat rm strace free showmount 
 dracut_install ping netstat rpcinfo
modules.d/95iscsi/iscsiroot +1 -1
index 8ee7cbc..316d8f4 100755
@@ -122,7 +122,7 @@ echo "InitiatorName='$iscsi_initiator'" > /dev/.initiatorname.iscsi
 
 # FIXME $iscsi_protocol??
 
-echo "iscsi_lun=$iscsi_lun . /bin/mount-lun.sh " > /mount/iscsi.sh
+echo "iscsi_lun=$iscsi_lun . /bin/mount-lun.sh " > /mount/01-$$-iscsi.sh
 
 iscsistart -i $iscsi_initiator -t $iscsi_target_name	\
     -g $iscsi_target_group -a $iscsi_target_ip	\
modules.d/95nbd/nbdroot +4 -3
index ad2e906..ecac211 100755
@@ -93,9 +93,10 @@ done
 # If we didn't get a root= on the command line, then we need to
 # add the udev rules for mounting the nbd0 device
 if [ ! -e /etc/udev/rules.d/99-mount.rules ]; then
-    printf 'KERNEL=="%s", RUN+="/sbin/initqueue /bin/mount -t %s -o %s %s %s"\n' \
-	nbd0 "$nbdfstype" "$fsopts" /dev/nbd0 "$NEWROOT" \
-		> /etc/udev/rules.d/99-mount.rules
+    printf 'KERNEL=="nbd0", SYMLINK+="root"\n'> /etc/udev/rules.d/99-mount.rules
+    printf '/bin/mount -t %s -o %s %s %s\n' \
+	   "$nbdfstype" "$fsopts" /dev/nbd0 "$NEWROOT" \
+	> /mount/01-$$-nbd.sh
 fi
 
 nbd-client $preopts "$nbdserver" "$nbdport" /dev/nbd0 $opts || exit 1
modules.d/95nfs/nfsroot +13 -10
index 0da8ee3..5f5b08f 100755
@@ -142,14 +142,17 @@ if [ "$nfs" = "nfs4" ]; then
     [ -z "$(pidof rpc.idmapd)" ] && rpc.idmapd
 
     # XXX Should we loop here?
-    exec mount -t nfs4 -o$options${nfslock+,$nfslock} \
-	$server:$path $NEWROOT
-fi
-
-# NFSv{2,3} doesn't support using locks as it requires a helper to transfer
-# the rpcbind state to the new root
-[ "$nfslock" = "lock" ] && \
-    warn "Locks unsupported on NFSv{2,3}, using nolock" 1>&2
+    echo mount -t nfs4 -o$options${nfslock+,$nfslock} \
+	$server:$path $NEWROOT > /mount/01-$$-nfs4.sh
+    [ -e /dev/root ] || >/dev/root
+else
+    # NFSv{2,3} doesn't support using locks as it requires a helper to transfer
+    # the rpcbind state to the new root
+    [ "$nfslock" = "lock" ] && \
+        warn "Locks unsupported on NFSv{2,3}, using nolock" 1>&2
 
-# XXX Should we loop here?
-exec mount -t nfs -o$options${options:+,}nolock $server:$path $NEWROOT
+    # XXX Should we loop here?
+    echo mount -t nfs -o$options${options:+,}nolock $server:$path $NEWROOT \
+        > /mount/01-$$-nfs.sh
+    [ -e /dev/root ] || >/dev/root
+fi
modules.d/95rootfs-block/block-genrules.sh +4 -4
index 2706dbb..5d1a669 100644
@@ -1,8 +1,8 @@
 if [ "${root%%:*}" = "block" ]; then
     (
-    printf 'KERNEL=="%s", RUN+="/sbin/initqueue /bin/mount -t %s -o %s %s %s"\n' \
-	${root#block:/dev/} "$fstype" "$rflags" "${root#block:}" "$NEWROOT"
-    printf 'SYMLINK=="%s", RUN+="/sbin/initqueue /bin/mount -t %s -o %s %s %s"\n' \
-	${root#block:/dev/} "$fstype" "$rflags" "${root#block:}" "$NEWROOT"
+    printf 'KERNEL=="%s", SYMLINK+="root"\n' \
+	${root#block:/dev/} 
+    printf 'SYMLINK=="%s", SYMLINK+="root"\n' \
+	${root#block:/dev/} 
     ) >> /etc/udev/rules.d/99-mount.rules
 fi
modules.d/99base/init +8 -1
index b49ba21..bb20220 100755
@@ -22,8 +22,11 @@ do_initqueue()
         # bail out, if we have mounted the root filesystem
 	[ -d "$NEWROOT/proc" ] && break;
 
+        # check if root can be mounted
+        [ -e /dev/root ] && break;
+
 	if [ $UDEVVERSION -ge 143 ]; then
-	    udevadm settle --exit-if-exists=/initqueue/work
+	    udevadm settle --exit-if-exists=/initqueue/work --exit-if-exists=/dev/root
 	else
 	    udevadm settle --timeout=30
 	fi
@@ -33,8 +36,12 @@ do_initqueue()
 	for job in /initqueue/*.job; do
 	    . $job
 	    rm -f $job
+
             # bail out, if we have mounted the root filesystem
 	    [ -d "$NEWROOT/proc" ] && break;
+
+            # check if root can be mounted
+	    [ -e /dev/root ] && break;
 	done
     done
 }
Signature · 6 lines
1.6.2.5

--
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): 1246639520-3094-4-git-send-email-harald-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org

#10 lore raw

Re: [PATCH 03/10] Defer mount to the real mount loop

Quoted 3 lines · Harald Hoyer

Udev rules set a /dev/root symlink to the real root and add a mount script to /mount/. This enables the proper use of pre-mount scripts and prevents mount being killed by a udev timeout.

This looks look good. Network initialization now done asynchronously and in parallel again. Thank you!

Some comments below.

Quoted 53 lines
---
 modules.d/40network/net-genrules.sh        |    8 ++++----
 modules.d/95debug/install                  |    2 +-
 modules.d/95iscsi/iscsiroot                |    2 +-
 modules.d/95nbd/nbdroot                    |    7 ++++---
 modules.d/95nfs/nfsroot                    |   23 +++++++++++++----------
 modules.d/95rootfs-block/block-genrules.sh |    8 ++++----
 modules.d/99base/init                      |    9 ++++++++-
 7 files changed, 35 insertions(+), 24 deletions(-)
modules.d/40network/net-genrules.sh +4 -4
index f843c53..dbd0474 100755
@@ -19,20 +19,20 @@ fix_bootif() {
     BOOTIF=$(getarg 'BOOTIF=')
     if [ -n "$BOOTIF" ] ; then
 	BOOTIF=$(fix_bootif "$BOOTIF")
-	printf 'ACTION=="add", SUBSYSTEM=="net", ATTR{address}=="%s", RUN+="/sbin/initqueue /sbin/ifup $env{INTERFACE}"\n' "$BOOTIF"
+	printf 'ACTION=="add", SUBSYSTEM=="net", ATTR{address}=="%s", RUN+="/sbin/ifup $env{INTERFACE}"\n' "$BOOTIF"
 
     # If we have to handle multiple interfaces, handle only them.
     elif [ -n "$IFACES" ] ; then
 	for iface in $IFACES ; do
-	    printf 'ACTION=="add", SUBSYSTEM=="net", KERNEL=="%s", RUN+="/sbin/initqueue /sbin/ifup $env{INTERFACE}"\n' "$iface"
+	    printf 'ACTION=="add", SUBSYSTEM=="net", KERNEL=="%s", RUN+="/sbin/ifup $env{INTERFACE}"\n' "$iface"
 	done
 
     # Default: We don't know the interface to use, handle all
     else
-	printf 'ACTION=="add", SUBSYSTEM=="net", RUN+="/sbin/initqueue /sbin/ifup $env{INTERFACE}"\n'
+	printf 'ACTION=="add", SUBSYSTEM=="net", RUN+="/sbin/ifup $env{INTERFACE}"\n'
     fi
 
     # Udev event 'online' only gets fired from ifup/dhclient-script.
     # No special rules required
-    printf 'ACTION=="online", SUBSYSTEM=="net", RUN+="/sbin/initqueue /sbin/netroot $env{INTERFACE}"\n'
+    printf 'ACTION=="online", SUBSYSTEM=="net", RUN+="/sbin/netroot $env{INTERFACE}"\n'
 } > /etc/udev/rules.d/60-net.rules
modules.d/95debug/install +1 -1
index 33a724d..6d4f089 100755
@@ -1,3 +1,3 @@
 #!/bin/bash
-dracut_install ln ps grep more dmesg cat rm strace free showmount
+dracut_install ln ps grep more cat rm strace free showmount 
 dracut_install ping netstat rpcinfo
modules.d/95iscsi/iscsiroot +0 -0
index 8ee7cbc..316d8f4 100755

modules.d/95iscsi/iscsiroot echo "InitiatorName='$iscsi_initiator'" > /dev/.initiatorname.iscsi · line 125

Quoted 5 lines
modules.d/95iscsi/iscsiroot +1 -1
@@ -122,7 +122,7 @@ echo "InitiatorName='$iscsi_initiator'" > /dev/.initiatorname.iscsi
 
 # FIXME $iscsi_protocol??
 
-echo "iscsi_lun=$iscsi_lun . /bin/mount-lun.sh " > /mount/iscsi.sh
+echo "iscsi_lun=$iscsi_lun . /bin/mount-lun.sh " > /mount/01-$$-iscsi.sh

I'd do that after iscsistart. That way the file is only written if iscsistart succeeded.

Quoted 9 lines
modules.d/95iscsi/iscsiroot +0 -0
 iscsistart -i $iscsi_initiator -t $iscsi_target_name	\
     -g $iscsi_target_group -a $iscsi_target_ip	\
modules.d/95nbd/nbdroot +0 -0
index ad2e906..ecac211 100755
@@ -93,9 +93,10 @@ done
 # If we didn't get a root= on the command line, then we need to

modules.d/95nbd/nbdroot done · line 100

Quoted 10 lines
modules.d/95nbd/nbdroot +4 -3
 # add the udev rules for mounting the nbd0 device
 if [ ! -e /etc/udev/rules.d/99-mount.rules ]; then
-    printf 'KERNEL=="%s", RUN+="/sbin/initqueue /bin/mount -t %s -o %s %s %s"\n' \
-	nbd0 "$nbdfstype" "$fsopts" /dev/nbd0 "$NEWROOT" \
-		> /etc/udev/rules.d/99-mount.rules
+    printf 'KERNEL=="nbd0", SYMLINK+="root"\n'> /etc/udev/rules.d/99-mount.rules
+    printf '/bin/mount -t %s -o %s %s %s\n' \
+	   "$nbdfstype" "$fsopts" /dev/nbd0 "$NEWROOT" \
+	> /mount/01-$$-nbd.sh
 fi

Same here, I'd only write a mount-script if nbdclient succeeds.

Quoted 71 lines
modules.d/95nbd/nbdroot +0 -0
 nbd-client $preopts "$nbdserver" "$nbdport" /dev/nbd0 $opts || exit 1
modules.d/95nfs/nfsroot +13 -10
index 0da8ee3..5f5b08f 100755
@@ -142,14 +142,17 @@ if [ "$nfs" = "nfs4" ]; then
     [ -z "$(pidof rpc.idmapd)" ] && rpc.idmapd
 
     # XXX Should we loop here?
-    exec mount -t nfs4 -o$options${nfslock+,$nfslock} \
-	$server:$path $NEWROOT
-fi
-
-# NFSv{2,3} doesn't support using locks as it requires a helper to transfer
-# the rpcbind state to the new root
-[ "$nfslock" = "lock" ] && \
-    warn "Locks unsupported on NFSv{2,3}, using nolock" 1>&2
+    echo mount -t nfs4 -o$options${nfslock+,$nfslock} \
+	$server:$path $NEWROOT > /mount/01-$$-nfs4.sh
+    [ -e /dev/root ] || >/dev/root
+else
+    # NFSv{2,3} doesn't support using locks as it requires a helper to transfer
+    # the rpcbind state to the new root
+    [ "$nfslock" = "lock" ] && \
+        warn "Locks unsupported on NFSv{2,3}, using nolock" 1>&2
 
-# XXX Should we loop here?
-exec mount -t nfs -o$options${options:+,}nolock $server:$path $NEWROOT
+    # XXX Should we loop here?
+    echo mount -t nfs -o$options${options:+,}nolock $server:$path $NEWROOT \
+        > /mount/01-$$-nfs.sh
+    [ -e /dev/root ] || >/dev/root
+fi
modules.d/95rootfs-block/block-genrules.sh +4 -4
index 2706dbb..5d1a669 100644
@@ -1,8 +1,8 @@
 if [ "${root%%:*}" = "block" ]; then
     (
-    printf 'KERNEL=="%s", RUN+="/sbin/initqueue /bin/mount -t %s -o %s %s %s"\n' \
-	${root#block:/dev/} "$fstype" "$rflags" "${root#block:}" "$NEWROOT"
-    printf 'SYMLINK=="%s", RUN+="/sbin/initqueue /bin/mount -t %s -o %s %s %s"\n' \
-	${root#block:/dev/} "$fstype" "$rflags" "${root#block:}" "$NEWROOT"
+    printf 'KERNEL=="%s", SYMLINK+="root"\n' \
+	${root#block:/dev/} 
+    printf 'SYMLINK=="%s", SYMLINK+="root"\n' \
+	${root#block:/dev/} 
     ) >> /etc/udev/rules.d/99-mount.rules
 fi
modules.d/99base/init +4 -1
index b49ba21..bb20220 100755
@@ -22,8 +22,11 @@ do_initqueue()
         # bail out, if we have mounted the root filesystem
 	[ -d "$NEWROOT/proc" ] && break;
 
+        # check if root can be mounted
+        [ -e /dev/root ] && break;
+
 	if [ $UDEVVERSION -ge 143 ]; then
-	    udevadm settle --exit-if-exists=/initqueue/work
+	    udevadm settle --exit-if-exists=/initqueue/work --exit-if-exists=/dev/root
 	else
 	    udevadm settle --timeout=30
 	fi
@@ -33,8 +36,12 @@ do_initqueue()
 	for job in /initqueue/*.job; do
 	    . $job

modules.d/99base/init do_initqueue() · line 47

Quoted 10 lines
modules.d/99base/init +4 -0
 	    rm -f $job
+
             # bail out, if we have mounted the root filesystem
 	    [ -d "$NEWROOT/proc" ] && break;
+
+            # check if root can be mounted
+	    [ -e /dev/root ] && break;
 	done
     done
 }

--
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]

#12 lore raw

Re: [PATCH 03/10] Defer mount to the real mount loop

Quoted 5 lines · Seewer Philippe

modules.d/95iscsi/iscsiroot echo "InitiatorName='$iscsi_initiator'" > /dev/.initiatorname.iscsi · line 125

Quoted 2 lines
modules.d/95iscsi/iscsiroot +1 -1
-echo "iscsi_lun=$iscsi_lun . /bin/mount-lun.sh " > /mount/iscsi.sh
+echo "iscsi_lun=$iscsi_lun . /bin/mount-lun.sh " > /mount/01-$$-iscsi.sh

I'd do that after iscsistart. That way the file is only written if iscsistart succeeded.

right

Quoted 16 lines
Quoted 16 lines

iscsistart -i $iscsi_initiator -t $iscsi_target_name \

(quoted diff) +0 -1
-g $iscsi_target_group -a $iscsi_target_ip \
modules.d/95nbd/nbdroot +0 -0
index ad2e906..ecac211 100755
@@ -93,9 +93,10 @@ done
 # If we didn't get a root= on the command line, then we need to
 # add the udev rules for mounting the nbd0 device

if [ ! -e /etc/udev/rules.d/99-mount.rules ]; then
- printf 'KERNEL=="%s", RUN+="/sbin/initqueue /bin/mount -t %s -o %s %s %s"\n' \
- nbd0 "$nbdfstype" "$fsopts" /dev/nbd0 "$NEWROOT" \
- > /etc/udev/rules.d/99-mount.rules

Quoted 8 lines
Quoted 6 lines

+ printf 'KERNEL=="nbd0", SYMLINK+="root"\n'>
/etc/udev/rules.d/99-mount.rules
+ printf '/bin/mount -t %s -o %s %s %s\n' \
+ "$nbdfstype" "$fsopts" /dev/nbd0 "$NEWROOT" \
+ > /mount/01-$$-nbd.sh
fi

Same here, I'd only write a mount-script if nbdclient succeeds.

yep
--
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

#13 lore raw

PATCH 4/10 remove 50plymouth-pre0.7 module

In reply to a message not in the archive
---
 modules.d/50plymouth-pre0.7/63-luks.rules          |   11 -------
 modules.d/50plymouth-pre0.7/check                  |    3 --
 modules.d/50plymouth-pre0.7/cryptroot-ask.sh       |    4 --
 modules.d/50plymouth-pre0.7/install                |    8 -----
 modules.d/50plymouth-pre0.7/plymouth-newroot.sh    |    4 --
 .../50plymouth-pre0.7/plymouth-populate-initrd     |   25 ----------------
 modules.d/50plymouth-pre0.7/plymouth-start.sh      |   31 --------------------
 7 files changed, 0 insertions(+), 86 deletions(-)
 delete mode 100644 modules.d/50plymouth-pre0.7/63-luks.rules
 delete mode 100755 modules.d/50plymouth-pre0.7/check
 delete mode 100755 modules.d/50plymouth-pre0.7/cryptroot-ask.sh
 delete mode 100755 modules.d/50plymouth-pre0.7/install
 delete mode 100755 modules.d/50plymouth-pre0.7/plymouth-newroot.sh
 delete mode 100755 modules.d/50plymouth-pre0.7/plymouth-populate-initrd
 delete mode 100755 modules.d/50plymouth-pre0.7/plymouth-start.sh
modules.d/50plymouth-pre0.7/63-luks.rules deleted +0 -11
deleted file mode 100644
index 711e865..0000000
@@ -1,11 +0,0 @@
-# hacky rules to try to try unlocking dm-crypt devs
-#
-# Copyright 2008, Red Hat, Inc.
-# Jeremy Katz <[email protected]>
-
-
-SUBSYSTEM!="block", GOTO="luks_end"
-ACTION!="add|change", GOTO="luks_end"
-ENV{ID_FS_TYPE}=="crypto_LUKS", RUN+="cryptroot-ask $env{DEVNAME} luks-$env{ID_FS_UUID}"
-
-LABEL="luks_end"
modules.d/50plymouth-pre0.7/check deleted +0 -3
deleted file mode 100755
index 018c0e9..0000000
@@ -1,3 +0,0 @@
-#!/bin/bash
-[[ $1 = -d ]] && echo crypt
-[[ -x /sbin/plymouthd && -x /bin/plymouth && ! /usr/sbin/plymouth-set-default-theme ]]
modules.d/50plymouth-pre0.7/cryptroot-ask.sh deleted +0 -4
deleted file mode 100755
index fadb502..0000000
@@ -1,4 +0,0 @@
-#!/bin/sh
-
-[ -b /dev/mapper/$2 ] || exec /bin/plymouth ask-for-password --command="/sbin/cryptsetup luksOpen -T1 $1 $2"
-
modules.d/50plymouth-pre0.7/install deleted +0 -8
deleted file mode 100755
index 4d3f7dc..0000000
@@ -1,8 +0,0 @@
-#!/bin/bash
-. "$moddir"/plymouth-populate-initrd
-inst_hook pre-udev 10 "$moddir"/plymouth-start.sh
-inst_hook pre-pivot 90 "$moddir"/plymouth-newroot.sh
-inst_rules "$moddir/63-luks.rules"
-inst "$moddir"/cryptroot-ask.sh /lib/udev/cryptroot-ask
-inst cryptsetup
-
modules.d/50plymouth-pre0.7/plymouth-newroot.sh deleted +0 -4
deleted file mode 100755
index c6f8c6d..0000000
@@ -1,4 +0,0 @@
-#!/bin/sh
-
-[ -x /bin/plymouth ] && /bin/plymouth --newroot=$NEWROOT
-
modules.d/50plymouth-pre0.7/plymouth-populate-initrd deleted +0 -25
deleted file mode 100755
index 1802b25..0000000
@@ -1,25 +0,0 @@
-#!/bin/bash
-if ldd /sbin/plymouthd |grep -q lib64; then
-    LIBDIR="/usr/lib64"
-else
-    LIBDIR="/usr/lib"
-fi
-PLYMOUTH_LOGO_FILE="/usr/share/pixmaps/system-logo-white.png"
-PLYMOUTH_PLUGIN_NAME=$(plymouth-set-default-plugin)
-
-inst /sbin/plymouthd /bin/plymouthd
-dracut_install /bin/plymouth "${LIBDIR}/plymouth/text.so" \
-    "${LIBDIR}/plymouth/details.so" "${PLYMOUTH_LOGO_FILE}" \
-    /etc/system-release "${LIBDIR}/plymouth/${PLYMOUTH_PLUGIN_NAME:=text}.so"
-mkdir -p "${initdir}/usr/share/plymouth"
-
-[[ -f ${LIBDIR}/plymouth/default.so ]] && inst ${LIBDIR}/plymouth/default.so
-
-if [[ -d /usr/share/plymouth/${PLYMOUTH_PLUGIN_NAME} ]]; then
-    for x in "/usr/share/plymouth/${PLYMOUTH_PLUGIN_NAME}"/* ; do
-        [[ -f "$x" ]] || break
-        inst $x
-    done
-fi
-
-# vim:ts=8:sw=4:sts=4:et
modules.d/50plymouth-pre0.7/plymouth-start.sh deleted +0 -31
deleted file mode 100755
index 310042d..0000000
@@ -1,31 +0,0 @@
-#!/bin/sh
-
-[ -c /dev/null ] || mknod /dev/null c 1 3
-mknod /dev/zero c 1 5
-mknod /dev/systty c 4 0
-mknod /dev/tty c 5 0
-[ -c /dev/console ] || mknod /dev/console c 5 1
-[ -c /dev/ptmx ] || mknod /dev/ptmx c 5 2
-mknod /dev/fb c 29 0
-mknod /dev/tty0 c 4 0
-mknod /dev/tty1 c 4 1
-mknod /dev/tty2 c 4 2
-mknod /dev/tty3 c 4 3
-mknod /dev/tty4 c 4 4
-mknod /dev/tty5 c 4 5
-mknod /dev/tty6 c 4 6
-mknod /dev/tty7 c 4 7
-mknod /dev/tty8 c 4 8
-mknod /dev/tty9 c 4 9
-mknod /dev/tty10 c 4 10
-mknod /dev/tty11 c 4 11
-mknod /dev/tty12 c 4 12
-mknod /dev/ttyS0 c 4 64
-mknod /dev/ttyS1 c 4 65
-mknod /dev/ttyS2 c 4 66
-mknod /dev/ttyS3 c 4 67
-/lib/udev/console_init tty0
-
-[ -x /bin/plymouthd ] && /bin/plymouthd 
-[ -x /bin/plymouth ] && /bin/plymouth --show-splash
-
Signature · 6 lines
1.6.2.5

--
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
#14 lore raw

PATCH 5/10 add firmware packages to be required by the dracut-generic package

In reply to a message not in the archive
---
 dracut.spec |    7 ++++++-
 1 files changed, 6 insertions(+), 1 deletions(-)
dracut.spec +6 -1
index 3e33819..4fae92b 100644
@@ -60,12 +60,17 @@ Requires: rpcbind nfs-utils
 Requires: iscsi-initiator-utils
 Requires: nbd
 Requires: net-tools iproute
+Requires: kernel-firmware
+Requires: ql2100-firmware
+Requires: ql2200-firmware
+Requires: ql23xx-firmware
+Requires: ql2400-firmware
+Requires: ql2500-firmware
 
 %description generic
 This package requires everything which is needed to build a generic
 all purpose initramfs.
 
-
 %prep
 %setup -q -n %{name}-%{version}%{?dashgittag}
 
Signature · 6 lines
1.6.2.5

--
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
#15 lore raw

PATCH 6/10 add rm to be installed for initqueue

In reply to a message not in the archive
---
 modules.d/99base/install |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
modules.d/99base/install +2 -1
index 4ecba9c..3f5b29a 100755
@@ -1,5 +1,6 @@
 #!/bin/bash
-dracut_install mount mknod mkdir modprobe pidof sleep chroot sed ls flock cp mv dmesg 
+dracut_install mount mknod mkdir modprobe pidof sleep chroot \
+    sed ls flock cp mv dmesg rm
 if [ ! -e "${initdir}/bin/sh" ]; then
     dracut_install bash
     (ln -s bash "${initdir}/bin/sh" || :)
Signature · 6 lines
1.6.2.5

--
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
#16 lore raw

PATCH 7/10 fail iscsiroot, if iscsistart fails

In reply to a message not in the archive
---
 modules.d/95iscsi/iscsiroot |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
modules.d/95iscsi/iscsiroot +1 -1
index 316d8f4..b7e3cf8 100755
@@ -130,7 +130,7 @@ iscsistart -i $iscsi_initiator -t $iscsi_target_name	\
     ${iscsi_username+-u $iscsi_username} \
     ${iscsi_password+-w $iscsi_password} \
     ${iscsi_in_username+-U $iscsi_in_username} \
-    ${iscsi_in_password+-W $iscsi_in_password}
+    ${iscsi_in_password+-W $iscsi_in_password} || exit 1
 
 # now we have a root filesystem somewhere in /dev/sda*
 # let the normal block handler handle root=
Signature · 6 lines
1.6.2.5

--
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
#17 lore raw

PATCH 8/10 put back the nfs mount in the udev event

In reply to a message not in the archive

it solves the following case:

root=/dev/nfs nfsroot=server:/path

- the server could be reachable on any interface
- any interface can get an IP by dhcp
- only one IP is allowed to mount the root

---
 modules.d/95nfs/nfsroot |   11 +++++------
 1 files changed, 5 insertions(+), 6 deletions(-)
modules.d/95nfs/nfsroot +5 -6
index 5f5b08f..0add977 100755
@@ -142,9 +142,9 @@ if [ "$nfs" = "nfs4" ]; then
     [ -z "$(pidof rpc.idmapd)" ] && rpc.idmapd
 
     # XXX Should we loop here?
-    echo mount -t nfs4 -o$options${nfslock+,$nfslock} \
-	$server:$path $NEWROOT > /mount/01-$$-nfs4.sh
-    [ -e /dev/root ] || >/dev/root
+    mount -t nfs4 -o$options${nfslock+,$nfslock} \
+	$server:$path $NEWROOT \
+	&& { [ -e /dev/root ] || >/dev/root ; }
 else
     # NFSv{2,3} doesn't support using locks as it requires a helper to transfer
     # the rpcbind state to the new root
@@ -152,7 +152,6 @@ else
         warn "Locks unsupported on NFSv{2,3}, using nolock" 1>&2
 
     # XXX Should we loop here?
-    echo mount -t nfs -o$options${options:+,}nolock $server:$path $NEWROOT \
-        > /mount/01-$$-nfs.sh
-    [ -e /dev/root ] || >/dev/root
+    mount -t nfs -o$options${options:+,}nolock $server:$path $NEWROOT \
+	&& { [ -e /dev/root ] || >/dev/root ; }
 fi
Signature · 6 lines
1.6.2.5

--
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): 1246639520-3094-9-git-send-email-harald-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org

#19 lore raw

Re: [PATCH 08/10] put back the nfs mount in the udev event

Quoted 7 lines · Harald Hoyer

it solves the following case:

root=/dev/nfs nfsroot=server:/path

- the server could be reachable on any interface
- any interface can get an IP by dhcp
- only one IP is allowed to mount the root

Thanks.

For the record, some further explanations:

If netroot is in "guess-the-interface-mode", netroot calls the root-handler for each interface that has a useable IP configuration. If the root-handler fails, the interface is deconfigured so that the next interface netroot tries does not suffer from side-effects.

This is accomplished by depending on mount-handlers having an exit-code
telling us whether mounting (would) succeed or not. For devicefile based network mounts, this isn't a problem since we need to call some sort of client-utility that makes the device nodes available (or not if
contacting the server fails). For network-filesystems like NFS that do
not use devicefiles, the actual mount call is needed.

Quoted 22 lines
---
 modules.d/95nfs/nfsroot |   11 +++++------
 1 files changed, 5 insertions(+), 6 deletions(-)
modules.d/95nfs/nfsroot +3 -3
index 5f5b08f..0add977 100755
@@ -142,9 +142,9 @@ if [ "$nfs" = "nfs4" ]; then
     [ -z "$(pidof rpc.idmapd)" ] && rpc.idmapd
 
     # XXX Should we loop here?
-    echo mount -t nfs4 -o$options${nfslock+,$nfslock} \
-	$server:$path $NEWROOT > /mount/01-$$-nfs4.sh
-    [ -e /dev/root ] || >/dev/root
+    mount -t nfs4 -o$options${nfslock+,$nfslock} \
+	$server:$path $NEWROOT \
+	&& { [ -e /dev/root ] || >/dev/root ; }
 else
     # NFSv{2,3} doesn't support using locks as it requires a helper to transfer
     # the rpcbind state to the new root

modules.d/95nfs/nfsroot else · line 157

Quoted 9 lines
modules.d/95nfs/nfsroot +2 -3
@@ -152,7 +152,6 @@ else
         warn "Locks unsupported on NFSv{2,3}, using nolock" 1>&2
 
     # XXX Should we loop here?
-    echo mount -t nfs -o$options${options:+,}nolock $server:$path $NEWROOT \
-        > /mount/01-$$-nfs.sh
-    [ -e /dev/root ] || >/dev/root
+    mount -t nfs -o$options${options:+,}nolock $server:$path $NEWROOT \
+	&& { [ -e /dev/root ] || >/dev/root ; }
 fi

--
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

#20 lore raw

PATCH 9/10 initqueue now loops until /dev/root exists or root is mounted

In reply to a message not in the archive

init now has the following points to inject scripts:

/cmdline/*.sh
scripts for command line parsing

/pre-udev/*.sh
scripts to run before udev is started

/pre-trigger/*.sh
scripts to run before the main udev trigger is pulled

/initqueue/*.sh
runs in parallel to the udev trigger
Udev events can add scripts here with /sbin/initqueue.
If /sbin/initqueue is called with the "--onetime" option, the script will be removed after it was run.
If /initqueue/work is created and udev >= 143 then this loop can process the jobs in parallel to the udevtrigger.
If the udev queue is empty and no root device is found or no root filesystem was mounted, the user will be dropped to a shell after a timeout.
Scripts can remove themselves from the initqueue by "rm $job".

/pre-mount/*.sh
scripts to run before the root filesystem is mounted NFS is an exception, because it has no device node to be created and mounts in the udev events

/mount/*.sh
scripts to mount the root filesystem
NFS is an exception, because it has no device node to be created and mounts in the udev events
If the udev queue is empty and no root device is found or no root filesystem was mounted, the user will be dropped to a shell after a timeout.

/pre-pivot/*.sh
scripts to run before the real init is executed and the initramfs disappears
All processes started before should be killed here.

The behaviour of the dmraid module demonstrates how to use the new mechanism. If it detects a device which is part of a raidmember from a udev rule, it installs a job to scan for dmraid devices, if the udev queue is empty. After a scan, it removes itsself from the queue.

---
 modules.d/50plymouth/63-luks.rules         |    2 +-
 modules.d/90crypt/70-luks.rules            |    2 +-
 modules.d/90dmraid/61-dmraid.rules         |   12 ++++
 modules.d/90dmraid/dmraid.sh               |    3 -
 modules.d/90dmraid/dmraid_scan             |    8 +++
 modules.d/90dmraid/install                 |    3 +-
 modules.d/95rootfs-block/block-genrules.sh |    4 ++
 modules.d/95rootfs-block/install           |    1 +
 modules.d/99base/init                      |   82 +++++++++++++++-------------
 modules.d/99base/initqueue                 |   11 +++-
 test/TEST-10-RAID/test.sh                  |    2 +-
 test/TEST-30-ISCSI/test.sh                 |    2 +-
 test/TEST-40-NBD/test.sh                   |    2 +-
 13 files changed, 85 insertions(+), 49 deletions(-)
 create mode 100644 modules.d/90dmraid/61-dmraid.rules
 delete mode 100644 modules.d/90dmraid/dmraid.sh
 create mode 100755 modules.d/90dmraid/dmraid_scan
modules.d/50plymouth/63-luks.rules +1 -1
index c3c6627..f55bf39 100644
@@ -7,6 +7,6 @@
 SUBSYSTEM!="block", GOTO="luks_end"
 ACTION!="add|change", GOTO="luks_end"
 
-ENV{ID_FS_TYPE}=="crypto_LUKS", RUN+="/sbin/initqueue /sbin/cryptroot-ask $env{DEVNAME} luks-$env{ID_FS_UUID}"
+ENV{ID_FS_TYPE}=="crypto_LUKS", RUN+="/sbin/initqueue --onetime /sbin/cryptroot-ask $env{DEVNAME} luks-$env{ID_FS_UUID}"
 
 LABEL="luks_end"
modules.d/90crypt/70-luks.rules +1 -1
index c3c6627..f55bf39 100644
@@ -7,6 +7,6 @@
 SUBSYSTEM!="block", GOTO="luks_end"
 ACTION!="add|change", GOTO="luks_end"
 
-ENV{ID_FS_TYPE}=="crypto_LUKS", RUN+="/sbin/initqueue /sbin/cryptroot-ask $env{DEVNAME} luks-$env{ID_FS_UUID}"
+ENV{ID_FS_TYPE}=="crypto_LUKS", RUN+="/sbin/initqueue --onetime /sbin/cryptroot-ask $env{DEVNAME} luks-$env{ID_FS_UUID}"
 
 LABEL="luks_end"
modules.d/90dmraid/61-dmraid.rules new file +12 -0
new file mode 100644
index 0000000..a8034db
@@ -0,0 +1,12 @@
+# This file causes block devices with Linux RAID (mdadm) signatures to
+# automatically cause mdadm to be run.
+# See udev(8) for syntax
+
+SUBSYSTEM!="block", GOTO="dm_end"
+ACTION!="add|change", GOTO="dm_end"
+
+ENV{ID_FS_TYPE}=="linux_raid_member", GOTO="dm_end"
+
+ENV{ID_FS_TYPE}=="*_raid_member", RUN+="/sbin/initqueue /sbin/dmraid_scan"
+
+LABEL="dm_end"
modules.d/90dmraid/dmraid.sh deleted +0 -3
deleted file mode 100644
index 4e2d5bf..0000000
@@ -1,3 +0,0 @@
-dmraid -ay -Z
-udevadm settle --timeout=30 >/dev/null 2>&1 
-
modules.d/90dmraid/dmraid_scan new file +8 -0
new file mode 100755
index 0000000..433e5d3
@@ -0,0 +1,8 @@
+#!/bin/sh
+
+if udevadm settle --timeout=0 >/dev/null 2>&1; then
+    # run dmraid if udev has settled
+    dmraid -ay -Z
+    [ -e "$job" ] && rm -f "$job"
+fi
+
modules.d/90dmraid/install +2 -1
index 636f1d2..9314c00 100755
@@ -1,4 +1,5 @@
 #!/bin/bash
 dracut_install dmraid 
-inst_hook pre-mount 10 "$moddir/dmraid.sh"
+inst "$moddir/dmraid_scan" /sbin/dmraid_scan
 inst_rules 64-md-raid.rules
+inst_rules "$moddir/61-dmraid.rules"
modules.d/95rootfs-block/block-genrules.sh +4 -0
index 5d1a669..10471ea 100644
@@ -5,4 +5,8 @@ if [ "${root%%:*}" = "block" ]; then
     printf 'SYMLINK=="%s", SYMLINK+="root"\n' \
 	${root#block:/dev/} 
     ) >> /etc/udev/rules.d/99-mount.rules
+    (
+    printf '[ -e "%s" ] && { ln -s "%s" /dev/root; rm "$job"; }\n' \
+	"${root#block:}" "${root#block:}"
+    ) >> /initqueue/blocksymlink.sh
 fi
modules.d/95rootfs-block/install +1 -0
index 618d357..d6c161a 100755
@@ -1,4 +1,5 @@
 #!/bin/sh
+dracut_install ln
 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/99base/init +44 -38

110 lines not on this page · raw message

modules.d/99base/initqueue +9 -2
index 0a760b7..a5c6ef6 100755
@@ -1,5 +1,12 @@
 #!/bin/sh
 
-echo "$@" > /tmp/$$.job
-mv /tmp/$$.job /initqueue/
+if [ "$1" = "--onetime" ]; then
+    onetime="yes"
+    shift
+fi
+echo "$@" > /tmp/$$.sh
+if [ -n "$onetime" ]; then
+   echo '[ -e "$job" ] && rm "$job"' >> /tmp/$$.sh
+fi
+mv /tmp/$$.sh /initqueue/
 >> /initqueue/work
test/TEST-10-RAID/test.sh +1 -1
index 23f9aff..700c377 100755
@@ -38,7 +38,7 @@ test_setup() {
 	initdir=overlay
 	. $basedir/dracut-functions
 	dracut_install sfdisk mke2fs poweroff cp umount 
-	inst_simple ./create-root.sh /pre-mount/01create-root.sh
+	inst_simple ./create-root.sh /initqueue/01create-root.sh
     )
  
     # create an initramfs that will create the target root filesystem.
test/TEST-30-ISCSI/test.sh +1 -1
index 6469950..d9da529 100755
@@ -81,7 +81,7 @@ test_setup() {
 	initdir=overlay
 	. $basedir/dracut-functions
 	dracut_install sfdisk mke2fs poweroff cp umount 
-	inst_simple ./create-root.sh /pre-mount/01create-root.sh
+	inst_simple ./create-root.sh /initqueue/01create-root.sh
     )
  
     # create an initramfs that will create the target root filesystem.
test/TEST-40-NBD/test.sh +1 -1
index 2f54511..07de7fe 100755
@@ -184,7 +184,7 @@ make_encrypted_root() {
 	initdir=overlay
 	. $basedir/dracut-functions
 	dracut_install mke2fs poweroff cp umount
-	inst_simple ./create-root.sh /pre-mount/01create-root.sh
+	inst_simple ./create-root.sh /initqueue/01create-root.sh
     )
 
     # create an initramfs that will create the target root filesystem.
Signature · 6 lines
1.6.2.5

--
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): 1246639520-3094-10-git-send-email-harald-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org

#22 lore raw

Re: [PATCH 09/10] initqueue now loops until /dev/root exists or root is mounted

Quoted 11 lines · Harald Hoyer

init now has the following points to inject scripts:

/cmdline/*.sh
scripts for command line parsing

/pre-udev/*.sh
scripts to run before udev is started

/pre-trigger/*.sh
scripts to run before the main udev trigger is pulled

Quoted 11 lines

/initqueue/*.sh
runs in parallel to the udev trigger
Udev events can add scripts here with /sbin/initqueue.
If /sbin/initqueue is called with the "--onetime" option, the script will be removed after it was run.
If /initqueue/work is created and udev >= 143 then this loop can process the jobs in parallel to the udevtrigger.
If the udev queue is empty and no root device is found or no root filesystem was mounted, the user will be dropped to a shell after a timeout.
Scripts can remove themselves from the initqueue by "rm $job".

I like this. It introduces a bit more complexity than I'd like, but allows us to solves a lot of timeing issues between asynchronous and parallel tasks in udev.

Quoted 4 lines

/pre-mount/*.sh
scripts to run before the root filesystem is mounted NFS is an exception, because it has no device node to be created and mounts in the udev events

Suggestion: If this description goes into a README or something similar, I'd rewrite this as "...network filesystems like NFS that do not use devicefiles are an exception,..."

Quoted 4 lines

/mount/*.sh
scripts to mount the root filesystem
NFS is an exception, because it has no device node to be created and mounts in the udev events

Same here, although I'd just drop it since its already mentioned or change it to say "network filesystems like NFS that do not use devicefiles should mount directly inside their netroot root-handlers."

Quoted 13 lines

If the udev queue is empty and no root device is found or no root filesystem was mounted, the user will be dropped to a shell after a timeout.

/pre-pivot/*.sh
scripts to run before the real init is executed and the initramfs disappears
All processes started before should be killed here.

The behaviour of the dmraid module demonstrates how to use the new mechanism. If it detects a device which is part of a raidmember from a udev rule, it installs a job to scan for dmraid devices, if the udev queue is empty. After a scan, it removes itsself from the queue.

[snip]

modules.d/90dmraid/dmraid_scan line 7

Quoted 13 lines
modules.d/90dmraid/dmraid_scan new file +7 -0
new file mode 100755
index 0000000..433e5d3
@@ -0,0 +1,8 @@
+#!/bin/sh
+
+if udevadm settle --timeout=0 >/dev/null 2>&1; then
+    # run dmraid if udev has settled
+    dmraid -ay -Z
+    [ -e "$job" ] && rm -f "$job"
+fi

Please do not use 'udevadm settle timeout=0'. Older version of udev, especially the one on debian lenny does not support a value of 0.

I suggest to increase that timeout to 1.

[snip]

Quoted 68 lines
modules.d/99base/init +22 -31
index bb20220..f082765 100755
@@ -16,36 +16,6 @@ emergency_shell()
     sh -i
 }
 
-do_initqueue()
-{
-    while :; do
-        # bail out, if we have mounted the root filesystem
-	[ -d "$NEWROOT/proc" ] && break;
-
-        # check if root can be mounted
-        [ -e /dev/root ] && break;
-
-	if [ $UDEVVERSION -ge 143 ]; then
-	    udevadm settle --exit-if-exists=/initqueue/work --exit-if-exists=/dev/root
-	else
-	    udevadm settle --timeout=30
-	fi
-	[ -f /initqueue/work ] || break
-	rm /initqueue/work
-	
-	for job in /initqueue/*.job; do
-	    . $job
-	    rm -f $job
-
-            # bail out, if we have mounted the root filesystem
-	    [ -d "$NEWROOT/proc" ] && break;
-
-            # check if root can be mounted
-	    [ -e /dev/root ] && break;
-	done
-    done
-}
-
 export PATH=/sbin:/bin:/usr/sbin:/usr/bin
 export TERM=linux
 NEWROOT="/sysroot"
@@ -116,7 +86,47 @@ source_all pre-trigger
 # then the rest
 udevadm trigger $udevtriggeropts  >/dev/null 2>&1
 
-do_initqueue
+i=0
+while :; do
+    # bail out, if we have mounted the root filesystem
+    [ -d "$NEWROOT/proc" ] && break;
+
+    # check if root can be mounted
+    [ -e /dev/root ] && break;
+
+    if [ $UDEVVERSION -ge 143 ]; then
+        udevadm settle --exit-if-exists=/initqueue/work --exit-if-exists=/dev/root 
+    else
+        udevadm settle --timeout=30
+    fi
+    unset queuetriggered
+    if [ -f /initqueue/work ]; then
+        rm /initqueue/work
+	queuetriggered="1"
+    fi
+    	
+    for job in /initqueue/*.sh; do
+	[ -e "$job" ] || break
+        job=$job . $job

modules.d/99base/init source_all pre-trigger · line 120

Quoted 10 lines
modules.d/99base/init +10 -0
+
+        # bail out, if we have mounted the root filesystem
+        [ -d "$NEWROOT/proc" ] && break;
+        # check if root can be mounted
+        [ -e /dev/root ] && break;
+    done
+
+    [ -n "$queuetriggered" ] && continue
+
+    if udevadm settle --timeout=0 >/dev/null 2>&1; then

Same here. Please increase the timeout to 1.

modules.d/99base/init source_all pre-trigger · line 125

Quoted 5 lines
modules.d/99base/init +5 -0
+        # no more udev jobs
+        sleep 0.5
+        i=$(($i+1))
+        [ $i -gt 20 ] && getarg rdshell \
+            && { flock -s 9 ; emergency_shell; } 9>/.console_lock

Question: Would it make sense to reset i to 0 after we've opened a shell? Or is it the intention that if a shell is opened and closed that we drop in again as soon as possible?

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

A message that is not in the archive (sent off-list or not yet received): [email protected]

#24 lore raw

Re: [PATCH 09/10] initqueue now loops until /dev/root exists or root is mounted

Quoted 3 lines · Seewer Philippe

Suggestion: If this description goes into a README or something similar, I'd rewrite this as "...network filesystems like NFS that do not use devicefiles are an exception,..."

ok, will do

Quoted 6 lines

Please do not use 'udevadm settle timeout=0'. Older version of udev, especially the one on debian lenny does not support a value of 0.

I suggest to increase that timeout to 1.

ok, will do

Quoted 3 lines

Question: Would it make sense to reset i to 0 after we've opened a shell? Or is it the intention that if a shell is opened and closed that we drop in again as soon as possible?

Well, if the user had a shell, he had the chance to find the real root, so I don't think 20 more loops will solve the problem. --
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

#25 lore raw

PATCH 10/10 add "rdshell" command line argument

In reply to a message not in the archive

Only drop to an interactive shell if "rdshell" is specified on the command line. This prevents malicious users from gaining easy shell access to the host system (grub might be secured with a password).

---
 dracut.8                   |    3 +++
 modules.d/99base/init      |   37 ++++++++++++++++++++++---------------
 test/TEST-10-RAID/test.sh  |    2 +-
 test/TEST-20-NFS/test.sh   |    2 +-
 test/TEST-30-ISCSI/test.sh |    2 +-
 test/TEST-40-NBD/test.sh   |    2 +-
 6 files changed, 29 insertions(+), 19 deletions(-)
dracut.8 +3 -0
index 4bf29a7..4d6ac29 100644
@@ -167,6 +167,9 @@ do not load kernel module <drivername>
 
 .SH Debug
 .TP
+.B rdshell
+drop to a shell, if the imitramfs fails
+.TP
 .B rdinitdebug
 set -x for the dracut shell
 .TP
modules.d/99base/init +22 -15
index f082765..cc42527 100755
@@ -8,19 +8,25 @@
 emergency_shell()
 {
     exec >/dev/console 2>&1 </dev/console
+    echo ; echo
+    echo $@
     getarg rdinitdebug || dmesg
     source_all emergency
-    echo ; echo
-    echo "Bug in initramfs /init detected. Dropping to a shell. Good luck!"
-    echo
-    sh -i
+    if getarg rdshell; then
+        echo ; echo
+        echo "Dropping to a shell. Good luck!"
+        echo
+        sh -i
+    else
+        while :; do sleep 1;done
+    fi
 }
 
 export PATH=/sbin:/bin:/usr/sbin:/usr/bin
 export TERM=linux
 NEWROOT="/sysroot"
 
-trap "emergency_shell" 0
+trap "emergency_shell Unkown signal caught!" 0
 
 . /lib/dracut-lib.sh
 
@@ -56,7 +62,7 @@ mount -t devpts -o gid=5,mode=620 /dev/pts /dev/pts >/dev/null 2>&1
 UDEVVERSION=$(udevadm --version)
 
 # run scriptlets to parse the command line
-getarg 'rdbreak=cmdline' && emergency_shell
+getarg 'rdbreak=cmdline' && emergency_shell "Break before cmdline"
 source_all cmdline
 
 [ -z "$root" ] && die "No or empty root= argument"
@@ -73,7 +79,7 @@ source_all cmdline
 } > /tmp/root.info
 
 # pre-udev scripts run before udev starts, and are run only once.
-getarg 'rdbreak=pre-udev' && emergency_shell
+getarg 'rdbreak=pre-udev' && emergency_shell "Break before pre-udev"
 source_all pre-udev
 
 # start up udev and trigger cold plugs
@@ -121,8 +127,8 @@ while :; do
         # no more udev jobs
         sleep 0.5
         i=$(($i+1))
-        [ $i -gt 20 ] && getarg rdshell \
-            && { flock -s 9 ; emergency_shell; } 9>/.console_lock
+        [ $i -gt 20 ] \
+            && { flock -s 9 ; emergency_shell "No root device found"; } 9>/.console_lock
     fi
 done
 unset job
@@ -130,10 +136,11 @@ unset queuetriggered
 
 # pre-mount happens before we try to mount the root filesystem,
 # and happens once.
-getarg 'rdbreak=pre-mount' && emergency_shell
+getarg 'rdbreak=pre-mount' && emergency_shell "Break pre-mount"
 source_all pre-mount
-getarg 'rdbreak=mount' && emergency_shell
 
+
+getarg 'rdbreak=mount' && emergency_shell "Break mount"
 # 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
@@ -145,8 +152,8 @@ while :; do
     done
 
     i=$(($i+1))
-    [ $i -gt 20 ] && getarg rdshell \
-        && { flock -s 9 ; emergency_shell; } 9>/.console_lock
+    [ $i -gt 20 ] \
+        && { flock -s 9 ; emergency_shell "Can't mount root filesystem"; } 9>/.console_lock
 done
 
 # pre pivot scripts are sourced just before we switch over to the new root.
@@ -159,8 +166,8 @@ for i in "$(getarg init=)" /sbin/init /etc/init /init /bin/sh; do
     [ -f "$NEWROOT$i" -a -x "$NEWROOT$i" ] && { INIT="$i"; break; }
 done
 [ "$INIT" ] || {
-    echo "Cannot find init! Please check to make sure you passed"
-    echo "a valid root filesystem!  Dropping to a shell."
+    echo "Cannot find init!"
+    echo "Please check to make sure you passed a valid root filesystem!"
     emergency_shell
 }
 
test/TEST-10-RAID/test.sh +1 -1
index 700c377..fbad51a 100755
@@ -9,7 +9,7 @@ KVERSION=${KVERSION-$(uname -r)}
 test_run() {
     $testdir/run-qemu -hda root.ext2 -m 256M -nographic \
 	-net none -kernel /boot/vmlinuz-$KVERSION \
-	-append "root=/dev/dracut/root rw quiet console=ttyS0,115200n81 $DEBUGFAIL" \
+	-append "root=/dev/dracut/root rw quiet console=ttyS0,115200n81 rdshell $DEBUGFAIL" \
 	-initrd initramfs.testing
     grep -m 1 -q dracut-root-block-success root.ext2 || return 1
 }
test/TEST-20-NFS/test.sh +1 -1
index 4410751..1811eca 100755
@@ -46,7 +46,7 @@ client_test() {
   	-net nic,macaddr=$mac,model=e1000 \
   	-net socket,mcast=230.0.0.1:1234 \
   	-kernel /boot/vmlinuz-$KVERSION \
-  	-append "$cmdline $DEBUGFAIL ro quiet console=ttyS0,115200n81" \
+  	-append "$cmdline $DEBUGFAIL rdshell ro quiet console=ttyS0,115200n81" \
   	-initrd initramfs.testing
 
     if [[ $? -ne 0 ]] || ! grep -m 1 -q nfs-OK client.img; then
test/TEST-30-ISCSI/test.sh +1 -1
index d9da529..440cd16 100755
@@ -37,7 +37,7 @@ run_client() {
   	-net nic,macaddr=52:54:00:12:34:00,model=e1000 \
   	-net socket,mcast=230.0.0.1:1235 \
   	-kernel /boot/vmlinuz-$KVERSION \
-	-append "root=dhcp rw quiet console=ttyS0,115200n81 $DEBUGFAIL" \
+	-append "root=dhcp rw quiet console=ttyS0,115200n81 rdshell $DEBUGFAIL" \
   	-initrd initramfs.testing
     grep -m 1 -q iscsi-OK client.img || return 1
 }
test/TEST-40-NBD/test.sh +1 -1
index 07de7fe..c3d8bfc 100755
@@ -50,7 +50,7 @@ client_test() {
 	-net nic,macaddr=$mac,model=e1000 \
 	-net socket,mcast=230.0.0.1:1236 \
 	-kernel /boot/vmlinuz-$KVERSION \
-	-append "$cmdline $DEBUGFAIL ro quiet console=ttyS0,115200n81" \
+	-append "$cmdline $DEBUGFAIL rdshell ro quiet console=ttyS0,115200n81" \
 	-initrd initramfs.testing
 
     if [[ $? -ne 0 ]] || ! grep -m 1 -q nbd-OK flag.img; then
Signature · 6 lines
1.6.2.5

--
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): 1246639520-3094-11-git-send-email-harald-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org

#27 lore raw

Re: [PATCH 10/10] add "rdshell" command line argument

Quoted 3 lines · Harald Hoyer

Only drop to an interactive shell if "rdshell" is specified on the command line. This prevents malicious users from gaining easy shell access to the host system (grub might be secured with a password).

I don't have a strong opinion about doing this vs not, but how could they end up getting easy shell access? If grub is secured with a password, they can't change kernel arguments. If they can change kernel arguments, they can just add rdshell rather than change the root= specifier.

Jeremy
--
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]

#29 lore raw

Re: [PATCH 10/10] add "rdshell" command line argument

Quoted 5 lines · Jeremy Katz
Quoted 3 lines · Harald Hoyer

Only drop to an interactive shell if "rdshell" is specified on the command line. This prevents malicious users from gaining easy shell access to the host system (grub might be secured with a password).

Quoted 7 lines

I don't have a strong opinion about doing this vs not, but how could they end up getting easy shell access? If grub is secured with a password, they can't change kernel arguments. If they can change kernel arguments, they can just add rdshell rather than change the root= specifier.

Jeremy

If root is on a network device, they can just unplug the network cable and end up with a shell, then they can replug the cable and do whatever they want in the shell. --
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

#30 lore raw

Re: [PATCH 10/10] add "rdshell" command line argument

In reply to a message not in the archive
Quoted 5 lines · Jeremy Katz
Quoted 3 lines · Harald Hoyer

Only drop to an interactive shell if "rdshell" is specified on the command line. This prevents malicious users from gaining easy shell access to the host system (grub might be secured with a password).

Quoted 7 lines

I don't have a strong opinion about doing this vs not, but how could they end up getting easy shell access? If grub is secured with a password, they can't change kernel arguments. If they can change kernel arguments, they can just add rdshell rather than change the root= specifier.

Jeremy

If root is on a network device, they can just unplug the network cable and end up with a shell, then they can replug the cable and do whatever they want in the shell. --
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