if is_yes "$USE_LVM" && [ -z "$LVMTOOLSVERSION" ]; then
LVMTOOLSVERSION=$(LC_ALL=C $lvm vgchange --version 2>/dev/null | awk '/LVM version:/{if ($3 >= 2) print "2"}')
if [ -z "$LVMTOOLSVERSION" ]; then
- die "Can't determine LVM tools version. Please set LVMTOOLSVERSION and rerun $PROGRAM."
+ die "Can't determine LVM tools version (is /sys mounted?). Please set LVMTOOLSVERSION and rerun $PROGRAM."
fi
fi
}
# generate initrd fragment for lvm
# @access public
initrd_gen_lvm() {
+ if ! is_yes "$have_lvm"; then
+ return
+ fi
+
debug "Adding LVM support to initrd"
inst_d /tmp /newroot
inst_exec $lvm /bin/lvm.static
export ROOTVG="$VGVOLUMES"
export SUSPENDVG=$SUSPENDVG
EOF
+
+ # need awk for "s/--/-/g" subst when parsing kernel root commandline
+ busybox_applet awk
add_linuxrc <<-'EOF'
# parse rootdev from kernel commandline if it begins with /
case "$ROOT" in
/*)
+
+ # rewrite:
+ # /dev/mapper/sys-rootfs -> /dev/sys/rootfs
+ # /dev/mapper/blodnatt-blah--bleh -> /dev/blodnatt/blah-bleh
+ # /dev/mapper/vg--meaw-root -> /dev/vg-meaw/root
+ case "$ROOT" in
+ /dev/mapper/*-*)
+ # change "--" to / (as "/" is impossible in LV name)
+ local dev=$(awk -vdev="${ROOT#/dev/mapper/}" 'BEGIN{gsub(/--/, "/", dev); print dev}')
+ local VG=$(awk -vdev="$dev" 'BEGIN{split(dev, v, "-"); gsub("/", "-", v[1]); print v[1]}')
+ local LV=$(awk -vdev="$dev" 'BEGIN{split(dev, v, "-"); gsub("/", "-", v[2]); print v[2]}')
+ ROOT=/dev/$VG/$LV
+ ;;
+ esac
+
if [ "$ROOT" != "$ROOTDEV" ]; then
ROOTDEV=$ROOT
+
echo "LVM: Using 'root=$ROOTDEV' from kernel commandline"
local tmp=${ROOTDEV#/dev/}
if [ "$tmp" != "$ROOTDEV" ]; then
if [ "$major" -a "$minor" ]; then
# Pass it to kernel
echo $((256 * $major + $minor)) > /proc/sys/kernel/real-root-dev
- else
- echo 2>&1 "Error figuring out real root device for $ROOTDEV!"
- echo 2>&1 "System will not most likely boot up! So dropping you to a shell!"
- echo 2>&1 ""
- sh
fi
EOF
fi