geninitrd 8385 patches and comments

Jacek Konieczny jajcus at jajcus.net
Tue May 22 15:11:06 CEST 2007


Hello,

I was working several hours to make my PLD-derived system to boot
with our geninitrd generated initrd. 

I had a few problems:

1. my busybox included other shell, which couldn't handle $((...))
   Ok, this is my own problem, nothing about PLD

2. the initrd (initramfs in fact) was unable to mount my root device,
   which was an LVM volume.

I made two patches (attached) to address the second problem:

1. geninitrd-rootdev.patch

   This didn't fix the problem for me, but seems a good fallback: if the
   device provided by the "root=" kernel parameter cannot be found, then 
   use the 'compile time default' (root device known when geninitrd ran)

2. geninitrd-lvm_initramfs.patch

   This one disables mounting tmpfs on /dev when initramfs is
   used. Using tmpfs inside of initramfs makes no sense, as initramfs
   is already a volatile read/write filesystem.
   TODO: disable mounting tmpfs on /tmp too (used for LVM stuff)
   Also "--mknodes" is added to vgscan invocation -- it should not hurt
   in any case, but makes the LVM devices available for mount before
   switch_root.

Other comments:

- There are a few "set +x" lines in the generated 'init' scripts which
make initrd/initramfs debugging very hard. 'debuginitrd' option (which
calls 'set -s') won't help, as after the first "set +x" the trace output
is deactivated.

- Do we still need non-initramfs initrd images? Dropping the legacy
  would make things much simpler: writtable filesystem (no need for
  temporary tmpfs mounts), the image could be generated with no
  mknode/mount/chown privileges. Functionality of the initramfs image
  could be easily extended by appending other cpio archives to it.

Greets,
        Jacek
-------------- next part --------------
diff -dur geninitrd-8385.orig/geninitrd geninitrd-8385/geninitrd
--- geninitrd-8385.orig/geninitrd	2007-05-22 10:45:56.000000000 +0000
+++ geninitrd-8385/geninitrd	2007-05-22 10:47:53.000000000 +0000
@@ -1393,11 +1393,15 @@
 		partition, maj, min);
 }
 ' /proc/partitions)"
-if [ ! -b $device ]; then
+if [ "$device" != '/dev/no_partition_found' -a ! -b $device ]; then
 	mknod $device b $maj $min
 fi
 EOF
 	cat << EOF >> "$s"
+if [ "\$device" = '/dev/no_partition_found' ] ; then
+	device="$rootdev"
+fi
+
 mount -t $rootFs -r \$device /newroot
 init="\$(busybox awk ' /init=\// { gsub(/.*init=/,NIL,\$0); gsub(/ .*/,NIL,\$0); print \$0; }  ' /proc/cmdline )"
 if [ -z "\$init" -o ! -x "/newroot\$init" ]; then
-------------- next part --------------
diff -dur geninitrd-8385.orig/geninitrd geninitrd-8385/geninitrd
--- geninitrd-8385.orig/geninitrd	2007-05-22 11:18:39.000000000 +0000
+++ geninitrd-8385/geninitrd	2007-05-22 12:37:41.000000000 +0000
@@ -978,6 +978,8 @@
 mknod "$MNTIMAGE/dev/console" c 5 1
 mknod "$MNTIMAGE/dev/null" c 1 3
 mknod "$MNTIMAGE/dev/zero" c 1 5
+mkdir "$MNTIMAGE/dev/pts"
+mkdir "$MNTIMAGE/dev/shm"
 
 s="$RCFILE"
 ln -s /linuxrc $MNTIMAGE/init
@@ -1049,6 +1051,10 @@
 }
 
 initrd_gen_tmpfs_dev() {
+    if [ "$INITRDFS" = "initramfs" ]; then
+		# initramfs is read-write filesystem, no need for tmpfs
+		return
+	fi
 	tmpfs_dev=yes
 	cat <<-EOF
 : 'Creating /dev'
@@ -1090,7 +1096,7 @@
 		cat >> "$s" <<- 'EOF'
 			killall udevd
 			umount /proc
-			umount /dev
+			umount /dev 2>/dev/null
 			umount /sys
 			EOF
 	fi
@@ -1250,7 +1256,7 @@
 		echo "lvm vgchange -T -a y $VGVOLUME" >> "$s"
 		echo "umount /tmp" >> "$s"
 		# fail to umount
-		echo "umount /dev" >> "$s"
+		echo "umount /dev 2>/dev/null" >> "$s"
 		echo "umount /proc" >> "$s"
 	else
 		echo "cat /etc/lvm.conf > /tmp/lvm.conf" >> "$s"
@@ -1281,7 +1287,7 @@
 		echo 0 > /proc/sys/kernel/printk
 
 		: 'Scanning for Volume Groups'
-		LVM_SYSTEM_DIR=/tmp lvm vgscan --ignorelockingfailure 2>/dev/null
+		LVM_SYSTEM_DIR=/tmp lvm vgscan --mknodes --ignorelockingfailure 2>/dev/null
 
 		: 'Activating Volume Groups'
 		LVM_SYSTEM_DIR=/tmp lvm vgchange --ignorelockingfailure -a y $VGVOLUME 2>/dev/null
@@ -1298,7 +1304,7 @@
 		val=\`expr 256 '*' \$major '+' \$minor\`
 		echo \$val > /proc/sys/kernel/real-root-dev
 		umount /tmp
-		umount /dev
+		umount /dev 2>/dev/null
 		umount /proc
 EOF
 	fi


More information about the pld-devel-en mailing list