SVN: geninitrd/trunk/geninitrd
glen
glen at pld-linux.org
Wed May 14 20:53:05 CEST 2008
Author: glen
Date: Wed May 14 20:53:05 2008
New Revision: 9751
Modified:
geninitrd/trunk/geninitrd
Log:
- code changes to allow resume dev from lvm.
Modified: geninitrd/trunk/geninitrd
==============================================================================
--- geninitrd/trunk/geninitrd (original)
+++ geninitrd/trunk/geninitrd Wed May 14 20:53:05 2008
@@ -63,8 +63,15 @@
# LVM devices that should not be included in vgscan on initrd
lvm_ignore_devices=''
-# LVM volume that is used for rootfs
-VGVOLUME=
+
+# LVM volumes that are needed to activate
+# VG for root dev
+ROOTVG=""
+# VG for suspend resume dev
+SUSPENDVG=""
+
+# resume device
+resume_dev=""
# if we should init NFS at boot
have_nfs=no
@@ -615,7 +622,7 @@
}
# return true if node is lvm node
-_check_lvm() {
+is_lvm_node() {
local node="$1"
if [ ! -e "$node" ]; then
warn "WARNING: check_lvm(): node $node doesn't exist!"
@@ -879,7 +886,7 @@
return
fi
- if _check_lvm "$devpath"; then
+ if is_lvm_node "$devpath"; then
node="$devpath"
if [ ! -f /sbin/initrd-lvm -o ! -x /sbin/lvdisplay -o ! -x /sbin/pvdisplay ]; then
@@ -891,10 +898,12 @@
die "Can't determine LVM tools version. Please set LVMTOOLSVERSION and rerun $PROGRAM."
fi
fi
- if [ -z "$PVDEVICES" ]; then
- VGVOLUME=$(/sbin/lvdisplay -c "$node" 2> /dev/null | awk -F":" ' { print $2 } ')
- PVDEVICES=$(/sbin/pvdisplay -c 2>/dev/null | awk -F":" -v vg="$VGVOLUME" ' BEGIN { devices="" } { if ($2 == vg) { devices = devices " " $1 } } END { print devices } ')
- fi
+
+ local vg=$(/sbin/lvdisplay -c "$node" 2> /dev/null | awk -F":" ' { print $2 } ')
+ VGVOLUMES=$(echo $VGVOLUMES $vg | tr ' ' '\n' | sort -u)
+ local pv=$(/sbin/pvdisplay -c 2>/dev/null | awk -F":" -v vg="$vg" ' BEGIN { devices="" } { if ($2 == vg) { devices = devices " " $1 } } END { print devices } ')
+ PVDEVICES=$(echo $PVDEVICES $pv | tr ' ' '\n' | sort -u)
+
if [ -n "$PVDEVICES" ]; then
for device in $PVDEVICES; do
find_modules_for_devpath $device
@@ -992,14 +1001,25 @@
done
}
-initrd_gen_suspend() {
+find_modules_suspend() {
if [ ! -x /usr/${_lib}/suspend/resume -a ! -x /usr/sbin/resume ]; then
die "/usr/${_lib}/suspend/resume is missing!"
fi
resume_dev="$(awk '/^resume device =/ { print $4 } ' /etc/suspend.conf)"
+ find_modules_for_devpath $resume_dev
+
+ if [ "$VGVOLUMES" ]; then
+ SUSPENDVG=$VGVOLUMES
+ VGVOLUMES=
+ debug "suspend device is on LVM"
+ fi
+}
+
+initrd_gen_suspend() {
mknod $DESTDIR/dev/snapshot c 10 231
mkdir -p $DESTDIR${resume_dev%/*}
inst $resume_dev $resume_dev
+
inst /etc/suspend.conf /etc/suspend.conf
if [ -x /usr/${_lib}/suspend/resume ]; then
inst /usr/${_lib}/suspend/resume /bin/resume
@@ -1391,7 +1411,9 @@
if [ "$LVMTOOLSVERSION" = "1" ]; then
add_linuxrc <<-EOF
lvm vgscan -T
- lvm vgchange -T -a y $VGVOLUME
+ for vg in $VGVOLUMES; do
+ lvm vgchange -T -a y $vg
+ done
EOF
else
echo "cat /etc/lvm.conf > /tmp/lvm.conf" | add_linuxrc
@@ -1425,7 +1447,8 @@
add_linuxrc <<-EOF
export ROOTDEV=$rootdev
- export VGVOLUME=$VGVOLUME
+ export ROOTVG="$VGVOLUMES"
+ export SUSPENDVG=$SUSPENDVG
EOF
add_linuxrc <<-'EOF'
# parse rootdev from kernel commandline
@@ -1434,11 +1457,13 @@
echo "LVM: Using 'root=$ROOTDEV' from kernel commandline"
local tmp=${ROOTDEV#/dev/}
if [ "$tmp" != "$ROOTDEV" ]; then
- VGVOLUME=${tmp%/*}
- echo "LVM: Using Volume Group '$VGVOLUME'"
+ ROOTVG=${tmp%/*}
+ echo "LVM: Using Volume Group '$ROOTVG' for rootfs"
fi
fi
+ export VGVOLUMES="$SUSPENDVG $ROOTVG"
+
# disable noise from LVM accessing devices that aren't ready.
read printk < /proc/sys/kernel/printk
if [ ! "$DEBUGINITRD" ]; then
@@ -1450,7 +1475,9 @@
lvm.static vgscan --mknodes --ignorelockingfailure 2>/dev/null
: 'Activating Volume Groups'
- lvm.static vgchange --ignorelockingfailure -a y $VGVOLUME 2>/dev/null
+ for vol in $VGVOLUMES; do
+ lvm.static vgchange --ignorelockingfailure -a y $vol 2>/dev/null
+ done
echo "$printk" > /proc/sys/kernel/printk
@@ -1830,6 +1857,10 @@
find_modules_ide
fi
+if is_yes "$USE_SUSPEND"; then
+ find_modules_suspend
+fi
+
find_root "$fstab" || exit
debug "Using $rootdev as device for rootfs"
@@ -1948,10 +1979,6 @@
initrd_gen_udev
fi
-if is_yes "$USE_SUSPEND"; then
- initrd_gen_suspend
-fi
-
if is_yes "$USE_TUXONICE"; then
initrd_gen_tuxonice
fi
@@ -1983,6 +2010,10 @@
initrd_gen_setrootdev
fi
+if is_yes "$USE_SUSPEND"; then
+ initrd_gen_suspend
+fi
+
# additional devs always needed
[ ! -e "$DESTDIR/$rootdev_add" ] && inst $rootdev_add /dev
More information about the pld-cvs-commit
mailing list