[Yaird-devel] Bug#387543: yaird: Allow init to start with empty /dev on final rootfs

Matthijs Melchior matthijs at kayak.zwaan.xs4all.nl
Thu Sep 14 21:45:02 UTC 2006


Package: yaird
Version: 0.0.12-18
Severity: normal

init will only start when /dev/console is avalable.
This inplies the static /dev directory must contain a console entry.
This is not good, device numbers may have changed.
I have encoutered this problem when moving to an 'evms' environment,
where I had copied the rootfs to a new place and ended with an empty
/dev directory.  This is not bad since udev will populate everything
after booting. However /dev/console is needed before that time.

Further investigation has shown that /etc/init.d/udev is prepared
to continue with an already mounted tmpfs on /dev.

I have solved this problem by changing the /etc/yaird/Template.cfg file 
by mounting a tmpfs on /mnt/dev and creating /mnt/dev/console before
doing the 'switchroot'.

The attached patch contains this and some other 'clenups' for
file /etc/yaird/Template.cfg.


-- System Information:
Debian Release: testing/unstable
  APT prefers unstable
  APT policy: (500, 'unstable'), (500, 'testing'), (500, 'stable'), (1, 'experimental')
Architecture: i386 (i686)
Shell:  /bin/sh linked to /bin/bash
Kernel: Linux 2.6.17-2-686
Locale: LANG=en_US, LC_CTYPE=en_US (charmap=ISO-8859-1)

Versions of packages yaird depends on:
ii  cpio                         2.6-17      GNU cpio -- a program to manage ar
ii  dash                         0.5.3-3     The Debian Almquist Shell
ii  libc6                        2.3.6.ds1-4 GNU C Library: Shared libraries
ii  libhtml-template-perl        2.8-1       HTML::Template : A module for usin
ii  libparse-recdescent-perl     1.94.free-3 Generates recursive-descent parser
ii  perl                         5.8.8-6.1   Larry Wall's Practical Extraction 

yaird recommends no packages.

-- no debconf information
-------------- next part --------------
--- /etc/yaird/Templates.cfg	2006-08-27 05:36:05.000000000 +0200
+++ Templates.cfg	2006-09-11 21:20:49.000000000 +0200
@@ -91,14 +91,17 @@
 			!# Kernel version: <TMPL_VAR NAME=version>.
 			!#
 			!INIT_DEBUG=
-			!if [ "$INIT_DEBUG" != "" ]
-			!then
-			!	set -x
-			!fi
+			![ -n "$INIT_DEBUG" ] && set -x
 			!
 			!#
 			!#  Utility functions
 			!#
+			!debugshell () {
+			!	[ -n "$INIT_DEBUG" ] && {
+			!		echo "Debugging opportunity, type ^D to continue."
+			!		/bin/dash
+			!	}
+			!}
 			!mksymdev () {
 			!	devfile="$1"
 			!	sysfile="$2"
@@ -117,11 +120,7 @@
 			!	if [ "$devpair" = "" ]
 			!	then
 			!		echo "Device $sysfile seems to be down."
-			!		if [ "$INIT_DEBUG" != "" ]
-			!		then
-			!			echo "Debugging opportunity, type ^D to continue."
-			!			/bin/dash
-			!		fi
+			!		debugshell
 			!	fi
 			!
 			!	maj=${devpair%:*}
@@ -136,11 +135,7 @@
 			!}
 			!
 			!switchroot () {
-			!	if [ "$INIT_DEBUG" != "" ]
-			!	then
-			!		echo "Debugging opportunity, ^D to continue."
-			!		/bin/dash
-			!	fi
+			!	debugshell
 			!
 			!	echo "Switching root ..."
 			!	/bin/umount -n /sys
@@ -156,7 +151,7 @@
 			!/bin/mount -nt proc proc /proc
 			!#
 			!# We don't set up a separate /dev file system,
-			!# since rootfs is writable without problem.
+			!# since initial rootfs is writable without problem.
 			!#
 			!
 			!# /dev/tty is needed for eg cryptsetup.
@@ -219,10 +214,7 @@
 			!		INIT_DEBUG=yes
 			!	esac
 			!done
-			!if [ "$INIT_DEBUG" != "" ]
-			!then
-			!	set -x
-			!fi
+			![ -n "$INIT_DEBUG" ] && set -x
 		END SCRIPT
 	END TEMPLATE
 
@@ -263,10 +255,7 @@
 		SCRIPT "/init"
 		BEGIN
 			!# activate for <TMPL_VAR NAME=target>
-			!if [ ! -c /dev/evms ]
-			!then
-			!	/bin/mkdir /dev/evms
-			!fi
+			![ -c /dev/evms ] || /bin/mkdir /dev/evms
 			!/sbin/evms_activate 
 		END SCRIPT
 	END TEMPLATE
@@ -481,6 +470,10 @@
 	BEGIN
 		SCRIPT "/init"
 		BEGIN
+			!# allow starting with empty /dev in new rootfs while still ro
+			![ -c /mnt/dev/console ] || {
+			!	mount -n -o size=10M,mode=0755 -t tmpfs udev /mnt/dev
+			!	mkcdev /mnt/dev/console tty/console ;}
 			!switchroot "$@"
 		END SCRIPT
 	END TEMPLATE


More information about the Yaird-devel mailing list