SVN: geninitrd/trunk/geninitrd
glen
glen at pld-linux.org
Fri Oct 20 18:05:26 CEST 2006
Author: glen
Date: Fri Oct 20 18:05:26 2006
New Revision: 7883
Modified:
geninitrd/trunk/geninitrd
Log:
Resolve /dev/dm-0 to LVM names (/dev/sys/rootfs) which we get when using LABEL or UUID.
Modified: geninitrd/trunk/geninitrd
==============================================================================
--- geninitrd/trunk/geninitrd (original)
+++ geninitrd/trunk/geninitrd Fri Oct 20 18:05:26 2006
@@ -306,7 +306,7 @@
exit 1
fi
uuid=${rootdev#"UUID="}
- for dev in `awk 'BEGIN {getline;getline} {print "/dev/" $4}' /proc/partitions` ; do
+ for dev in $(awk 'BEGIN {getline;getline} {print "/dev/" $4}' /proc/partitions); do
if [ -r $dev ] && [ "$uuid" = "`$get_uuid $dev`" ] ; then
if [ -n "$verbose" ] ; then
echo "Using $dev as device for rootfs"
@@ -510,6 +510,31 @@
fi
}
+# resolve /dev/dm-0 to lvm2 node
+# which they got from /proc/partitions when rootfs is UUID=
+_lvm2_node_resolve() {
+ local node="$1"
+
+ # redirect output to tmpfile so we won't get subshell
+ local tmp ret
+ tmp=$(mktemp) || exit 1
+
+ lvdisplay -c 2>/dev/null|awk -F: '{print $1}' > $tmp
+ while read dev; do
+ count=$(ls -Ll $dev $node | awk '{print $5, $6}' | sort -u | wc -l)
+ if [ "$count" = 1 ]; then
+ ret="$dev"
+ break
+ fi
+ done < $tmp
+ rm -f $tmp
+
+ if [ -z "$ret" ]; then
+ ret=$node
+ fi
+ echo "$ret"
+}
+
# return true if node is lvm node
_check_lvm() {
local node="$1"
@@ -528,6 +553,7 @@
return 0
fi
+ node=$(_lvm2_node_resolve $node)
/sbin/lvm lvdisplay "$node" > /dev/null 2>&1
rc=$?
if [ $rc -gt 127 ]; then
@@ -548,8 +574,9 @@
if [ -z "$1" ]; then
echo "ERROR: no argument passed to find_modules_for() - is your /etc/fstab correct?" >&2
exit
+ fi
- elif is_yes "`echo "$1" | awk '/^([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+:|\/dev\/nfs)/ { print "yes"; }'`"; then
+ if is_yes "`echo "$1" | awk '/^([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+:|\/dev\/nfs)/ { print "yes"; }'`"; then
if [ ! -x /usr/bin/pcidev -a -z "$NFS_ETH_MODULES" ] ; then
echo "ERROR: root on NFS but /usr/bin/pcidev not found." >&2
echo "Please install correct pci-database package and rerun $0." >&2
@@ -614,6 +641,8 @@
findmodule "-$loopFs"
BASICMODULES="$BASICMODULES -${loopFs}"
elif _check_lvm "$1"; then
+ node=$(_lvm2_node_resolve "$1")
+
if [ ! -f /sbin/initrd-lvm -o ! -x /sbin/lvdisplay -o ! -x /sbin/pvdisplay ] ; then
echo "ERROR: root on LVM but /sbin/initrd-lvm, /sbin/lvdisplay and /sbin/pvdisplay not found." >&2
echo "Please install lvm(2) and lvm(2)-initrd package and rerun $0." >&2
@@ -628,7 +657,7 @@
fi
fi
if [ -z "$PVDEVICES" ] ; then
- VGVOLUME=$(/sbin/lvdisplay -c "$1" 2> /dev/null | awk -F":" ' { print $2 } ')
+ VGVOLUME=$(/sbin/lvdisplay -c "$node" 2> /dev/null | awk -F":" ' { print $2 } ')
PVDEVICES=$(/sbin/pvdisplay -c | awk -F":" -v vg="$VGVOLUME" ' BEGIN { devices="" } { if ($2 == vg) { devices = devices " " $1 } } END { print devices } ')
fi
if [ -n "$PVDEVICES" ] ; then
@@ -1329,6 +1358,7 @@
echo "umount /dev" >> "$s"
echo "umount /proc" >> "$s"
else
+ org_rootdev=$(_lvm2_node_resolve "$org_rootdev")
echo "cat /etc/lvm.conf > /tmp/lvm.conf" >> "$s"
echo "global {" > "$MNTIMAGE/etc/lvm.conf"
echo " locking_type = 0" >> "$MNTIMAGE/etc/lvm.conf"
More information about the pld-cvs-commit
mailing list