[readonly/geninitrd: 549/1068] - --with-blkid support to allow use root=LABEL=somewhere - disabled by default

draenog draenog at pld-linux.org
Sat Nov 2 19:58:34 CET 2013


commit 289fbc9b54fab0f469e22c64f8c36bf7c1fd5b7d
Author: undefine <undefine at pld-linux.org>
Date:   Sun Jan 27 13:37:07 2008 +0000

    - --with-blkid support to allow use root=LABEL=somewhere
    - disabled by default
    
    
    svn-id: @9202

 geninitrd | 26 +++++++++++++++++++++++++-
 1 file changed, 25 insertions(+), 1 deletion(-)
---
diff --git a/geninitrd b/geninitrd
index 9904d8b..a30fed8 100755
--- a/geninitrd
+++ b/geninitrd
@@ -91,6 +91,7 @@ usage() {
 	echo "       [--with-suspend] [--without-suspend]"
 	echo "       [--with-tuxonice] [--without-tuxonice]"
 	echo "       [--without-dmraid] [--without-multipath]"
+	echo "       [--with-blkid]"
 	echo "       <initrd-image> <kernel-version>"
 	echo ""
 	echo "example:"
@@ -1511,10 +1512,23 @@ initrd_gen_lvm() {
 	fi
 }
 
+initrd_gen_blkid()
+{
+	debug "Adding BLKID support to initrd"
+	inst /sbin/initrd-blkid /bin/blkid
+	initrd_gen_devices
+	add_linuxrc <<-'EOF'
+		device=/dev/no_partition_found
+		label="$(echo "$CMDLINE" | busybox awk '/root=LABEL=/ { gsub(/.*root=/,NIL,$0); gsub(/ .*/,NIL,$0); print $0; } ')"
+		root="$(/bin/blkid -t $label -o device -l |busybox awk '/dev/ { gsub(/\/dev\//,NIL,$0); print $0; } ' )"
+		[ -n "$root" ] && device=/dev/$root
+	EOF
+}
+
 initrd_gen_procdata() {
 	debug "Adding rootfs finding based on kernel cmdline root= option support."
 	add_linuxrc <<-'EOF'
-		root="$(echo "$CMDLINE" | busybox awk ' /root=\/dev\// { gsub(/.*root=\/dev\//,NIL,$0); gsub(/ .*/,NIL,$0); print $0; } ')"
+		[ -z "$root" ] && root="$(echo "$CMDLINE" | busybox awk ' /root=\/dev\// { gsub(/.*root=\/dev\//,NIL,$0); gsub(/ .*/,NIL,$0); print $0; } ')"
 		if [ -n "$root" ]; then
 			rootnr="$(busybox awk -v root="$root" ' { if ($4 == root) { print 256*$1+$2; } } ' /proc/partitions)"
 			if [ -n "$rootnr" ]; then
@@ -1627,6 +1641,9 @@ while [ $# -gt 0 ]; do
 	--without-multipath)
 		USE_MULTPATH=no
 		;;
+	--with-blkid)
+		USE_BLKID=yes
+		;;
 	--with=*)
 		BASICMODULES="$BASICMODULES ${1#--with=}"
 		;;
@@ -1939,6 +1956,10 @@ if is_yes "$have_multipath"; then
 	initrd_gen_multipath
 fi
 
+if is_yes "$USE_BLKID" ]; then
+	initrd_gen_blkid
+fi
+
 if is_yes "$have_nfs"; then
 	initrd_gen_nfs
 elif is_yes "$USERAIDSTART" && is_yes "$have_md"; then
@@ -1967,6 +1988,8 @@ if [ "$INITRDFS" = "initramfs" ]; then
 	# Parsing root parameter
 	# We support passing root as hda3 /dev/hda3 0303 0x0303 and 303
 	add_linuxrc <<-'EOF'
+		[ -z "$device" ] && device=/dev/no_partition_found 
+		if [ "$device" = '/dev/no_partition_found' ]; then
 		eval "$(busybox awk -v c="$CMDLINE" '
 		BEGIN {
 			num_pattern_short = "[0-9a-f][0-9a-f][0-9a-f]";
@@ -1996,6 +2019,7 @@ if [ "$INITRDFS" = "initramfs" ]; then
 				partition, maj, min);
 		}
 		' /proc/partitions)"
+		fi
 		if [ "$device" != '/dev/no_partition_found' -a ! -b $device ]; then
 			mknod $device b $maj $min
 		fi
================================================================

---- gitweb:

http://git.pld-linux.org/gitweb.cgi/readonly/geninitrd.git/commitdiff/147754ca159d40ca5eb541074dc043d8cbd92090



More information about the pld-cvs-commit mailing list