[readonly/geninitrd: 491/1068] - avoid lvdisplay errors killing whole /linuxrc

draenog draenog at pld-linux.org
Sat Nov 2 19:53:40 CET 2013


commit ec49b7e6f93aed6e9aa99c8e4385282053480bae
Author: Elan Ruusamäe <glen at pld-linux.org>
Date:   Wed Oct 31 17:44:07 2007 +0000

    - avoid lvdisplay errors killing whole /linuxrc
    
    svn-id: @8916

 geninitrd | 35 +++++++++++++++++++++++------------
 1 file changed, 23 insertions(+), 12 deletions(-)
---
diff --git a/geninitrd b/geninitrd
index 09d1752..b5afa24 100755
--- a/geninitrd
+++ b/geninitrd
@@ -197,7 +197,11 @@ mount_tmp() {
 
 # unmount all mountpoints mounted by geninitrd
 umount_all() {
-	echo 'debugshell' | add_linuxrc
+
+	add_linuxrc <<-'EOF'
+	: Last shell before umounting all and giving control over to real init
+	debugshell
+	EOF
 
 	if is_yes "$dev_mounted"; then
 		echo 'umount /dev' | add_linuxrc
@@ -1663,8 +1667,12 @@ initrd_gen_lvm() {
 		initrd_gen_devices
 
 		add_linuxrc <<-EOF
+			export LVM_ROOTDEV=$rootdev
+			export LVM_VGVOLUME=$VGVOLUME
+		EOF
+		add_linuxrc <<-'EOF'
 			# disable noise from lvm accessing devices that aren't ready.
-			printk=\$(cat /proc/sys/kernel/printk)
+			printk=$(cat /proc/sys/kernel/printk)
 			echo 0 > /proc/sys/kernel/printk
 
 			export LVM_SYSTEM_DIR=/tmp
@@ -1672,19 +1680,22 @@ initrd_gen_lvm() {
 			lvm vgscan --mknodes --ignorelockingfailure 2>/dev/null
 
 			: 'Activating Volume Groups'
-			lvm vgchange --ignorelockingfailure -a y $VGVOLUME 2>/dev/null
+			lvm vgchange --ignorelockingfailure -a y $LVM_VGVOLUME 2>/dev/null
 
-			echo "\$printk" > /proc/sys/kernel/printk
+			echo "$printk" > /proc/sys/kernel/printk
 
 			# Find out major/minor
-			majmin="\$(lvm lvdisplay --ignorelockingfailure -c $rootdev 2>/dev/null)"
-			majmin="\${majmin#*/}"
-			majmin="\${majmin#*:*:*:*:*:*:*:*:*:*:*:*}"
-			major="\${majmin%:*}"
-			minor="\${majmin#*:}"
-			# Pass it to kernel
-			val=\$((256 * \$major + \$minor))
-			echo \$val > /proc/sys/kernel/real-root-dev
+			attrs="$(lvm lvdisplay --ignorelockingfailure -c $LVM_ROOTDEV 2>/dev/null)"
+			if [ "$attrs" ]; then
+				majmin="${attrs#*/}"
+				majmin="${majmin#*:*:*:*:*:*:*:*:*:*:*:*}"
+				major="${majmin%:*}"
+				minor="${majmin#*:}"
+			fi
+			if [ "$major" -a "$minor" ]; then
+				# Pass it to kernel
+				echo $((256 * $major + $minor)) > /proc/sys/kernel/real-root-dev
+			fi
 		EOF
 	fi
 }
================================================================

---- gitweb:

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



More information about the pld-cvs-commit mailing list