[readonly/geninitrd: 435/1068] - rootfs on lvm and dmraid hooks
draenog
draenog at pld-linux.org
Sat Nov 2 19:48:56 CET 2013
commit bc0d6f2d1d4dc17e3b9324e4e4eefe744baa57e8
Author: Elan Ruusamäe <glen at pld-linux.org>
Date: Thu Oct 11 15:16:19 2007 +0000
- rootfs on lvm and dmraid hooks
svn-id: @8807
functions | 12 +++++++++
geninitrd | 85 ++++++++++++++++++++++++++++++++++++++++++++++-----------------
2 files changed, 75 insertions(+), 22 deletions(-)
---
diff --git a/functions b/functions
index 22fbebc..fe259ba 100644
--- a/functions
+++ b/functions
@@ -97,3 +97,15 @@ dm_lvm2_name() {
fi
echo "$ret"
}
+
+# try to resolve /dev/dm-0 to item from /dev/mapper dir
+dm_longname() {
+ local node="$1"
+ local ret
+
+ ret=$(find /dev -type b | xargs ls -l | LC_ALL=C sort -k5,6 | grep -B1 $node | awk '{print $NF; exit}')
+ if [ -z "$ret" ]; then
+ ret=$node
+ fi
+ echo "$ret"
+}
diff --git a/geninitrd b/geninitrd
index 05d5819..1f1f98a 100755
--- a/geninitrd
+++ b/geninitrd
@@ -493,13 +493,23 @@ _check_lvm() {
return $rc
}
+# find modules for $devpath
find_modules_for() {
- if [ -z "$1" ]; then
- echo "ERROR: no argument passed to find_modules_for() - is your /etc/fstab correct?" >&2
- exit
+ local devpath="$1"
+ if [ -z "$devpath" ]; then
+ die "No argument passed to find_modules_for() - is your /etc/fstab correct?"
fi
- if is_yes "`echo "$1" | awk '/^([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+:|\/dev\/nfs)/ { print "yes"; }'`"; then
+ # /dev/dm-3 -> /dev/mapper/sil_ahbgadcbchfc3
+ case "$devpath" in
+ /dev/dm-*)
+ devpath=$(dm_longname "$devpath")
+ ;;
+ esac
+
+ echo "find modules for $devpath"
+
+ if is_yes "`echo "$devpath" | 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
die "root on NFS but /usr/bin/pcidev not found. Please install correct pci-database package and rerun $PROGRAM."
fi
@@ -512,19 +522,40 @@ find_modules_for() {
usenfs="yes"
echo "Remember to use \`root=/dev/ram0 init=/linuxrc' when starting kernel" >&2
echo "or you will have problems like init(xx) being child process of swapper(1)." >&2
- elif is_yes "`echo "$1" | awk '/^\/dev\/md/ { print "yes"; }'`"; then
- find_modules_softraid "$1"
- elif is_yes "$(echo "$1" | awk '/^\/dev\/(sd|scsi)/ { print "yes"; }')" ; then
+ elif is_yes "`echo "$devpath" | awk '/^\/dev\/md/ { print "yes"; }'`"; then
+ find_modules_softraid "$devpath"
+ elif is_yes "$(echo "$devpath" | awk '/^\/dev\/(sd|scsi)/ { print "yes"; }')" ; then
find_modules_scsi
- elif is_yes "`echo "$1" | awk '/^\/dev\/(hd|ide)/ { print "yes"; }'`" ; then
- find_modules_ide "$1"
- elif is_yes "`echo "$1" | awk '/\/dev\/rd\// { print "yes"; }'`" ; then
+ elif is_yes "`echo "$devpath" | awk '/^\/dev\/(hd|ide)/ { print "yes"; }'`" ; then
+ find_modules_ide "$devpath"
+ elif is_yes "`echo "$devpath" | awk '/^\/dev\/mapper\/(sil|hpt37x|hpt45x|isw|lsi|nvidia|pdc|sil|via|dos)_/ { print "yes"; }'`"; then
+ set -x
+ # dmraid nodes taken from: `dmraid -l` output
+ if [ ! -x /usr/sbin/dmraid ]; then
+ die "root on dmraid but /usr/sbin/dmraid not found."
+ fi
+
+ # XXX dmraid could say to us that /dev/dm-3 consists from /dev/sda, /dev/sdb
+
+ # get blockdev itself (without partition)
+ local node blockdev
+ blockdev=${devpath%%[0-9]*}
+ blockdev=${blockdev#/dev/mapper/}
+ for node in $(dmraid -r -cdevpath,raidname |awk -F, -vv="$blockdev" '{if ($2 == v) print $1}'); do
+ find_modules_for $node
+ done
+
+ # XXX probably should detect
+ findmodule "dm-mirror"
+
+ set +x
+ elif is_yes "`echo "$devpath" | awk '/\/dev\/rd\// { print "yes"; }'`" ; then
findmodule "DAC960"
- elif is_yes "`echo "$1" | awk '/\/dev\/ida\// { print "yes"; }'`" ; then
+ elif is_yes "`echo "$devpath" | awk '/\/dev\/ida\// { print "yes"; }'`" ; then
findmodule "cpqarray"
- elif is_yes "`echo "$1" | awk '/\/dev\/cciss\// { print "yes"; }'`" ; then
+ elif is_yes "`echo "$devpath" | awk '/\/dev\/cciss\// { print "yes"; }'`" ; then
findmodule "cciss"
- elif is_yes "`echo "$1" | awk '/\/dev\/ataraid\// { print "yes"; }'`"; then
+ elif is_yes "`echo "$devpath" | awk '/\/dev\/ataraid\// { print "yes"; }'`"; then
find_modules_ide
findmodule "ataraid"
ataraidmodules="`awk '/ataraid_hostadapter/ && ! /^[\t ]*#/ { print $3; }' $modulefile`"
@@ -536,15 +567,15 @@ find_modules_for() {
findmodule "$n"
done
# check to see if we need to set up a loopback filesystem
- elif is_yes "`echo "$1" | awk -F/ '{print($3);}' | awk '/loop/ { print "yes"; }'`" ; then
+ elif is_yes "`echo "$devpath" | awk -F/ '{print($3);}' | awk '/loop/ { print "yes"; }'`" ; then
die "Sorry, root on loop device isn't supported."
# TODO: rewrite for bsp and make nfs ready
if [ ! -x /sbin/losetup ]; then
die "losetup is missing"
fi
- key="^# $(echo $1 | awk -F/ '{print($3);}' | tr '[a-z]' '[A-Z]'):"
+ key="^# $(echo $devpath | awk -F/ '{print($3);}' | tr '[a-z]' '[A-Z]'):"
if ! is_yes "`awk '/'$key'/ { print( "yes"); }' $fstab`" ; then
- die "The root filesystem is on a $1, but there is no magic entry in $fstab for this device. Consult the $PROGRAM man page for more information"
+ die "The root filesystem is on a $devpath, but there is no magic entry in $fstab for this device. Consult the geninitrd man page for more information"
fi
line="`awk '/'$key'/ { print $0; }' $fstab`"
@@ -555,8 +586,8 @@ find_modules_for() {
BASICMODULES="$BASICMODULES -loop"
findmodule "-$loopFs"
BASICMODULES="$BASICMODULES -${loopFs}"
- elif _check_lvm "$1"; then
- node="$1"
+ elif _check_lvm "$devpath"; then
+ node="$devpath"
if [ ! -f /sbin/initrd-lvm -o ! -x /sbin/lvdisplay -o ! -x /sbin/pvdisplay ] ; then
die "root on LVM but /sbin/initrd-lvm, /sbin/lvdisplay and /sbin/pvdisplay not found. Please install lvm(2) and lvm(2)-initrd package and rerun $PROGRAM."
@@ -589,10 +620,6 @@ find_modules_for() {
debug "LVM $LVMTOOLSVERSION enabled"
uselvm="yes"
fi
-
- if is_yes "$USE_DMRAID"; then
- findmodule "dm-mirror"
- fi
}
firmware_install_module_pre() {
@@ -1341,10 +1368,21 @@ initrd_gen_lvm() {
fi
if is_yes "$USE_DMRAID"; then
echo ' types = [ "device-mapper", 254 ]' >> "$MNTIMAGE/etc/lvm.conf"
+ # ignore /dev/sd* devices that dmraid consists
+ local devs=$(dmraid -r | awk -F: '{print $1}')
+ if [ "$devs" ]; then
+ echo ' filter = [' >> "$MNTIMAGE/etc/lvm.conf"
+ for dev in $devs; do
+ printf ' "r|^%s.*|",\n' $dev
+ done >> "$MNTIMAGE/etc/lvm.conf"
+ echo ']' >> "$MNTIMAGE/etc/lvm.conf"
+ fi
fi
lvm dumpconfig | awk '/filter=/' >> "$MNTIMAGE/etc/lvm.conf"
echo "}" >> "$MNTIMAGE/etc/lvm.conf"
+ [ -n "$verbose2" ] && sed -e 's,^,lvm.conf: | ,' < "$MNTIMAGE/etc/lvm.conf"
+
initrd_gen_devices
cat <<-EOF >> "$s"
@@ -1508,6 +1546,9 @@ EOF
cp -a $MNTIMAGE/linuxrc $MNTIMAGE/init
fi
+# dump linuxrc
+[ -n "$verbose2" ] && sed -e 's,^, linuxrc: | ,' < "$s"
+
chmod +x "$RCFILE"
(cd "$MNTIMAGE"; tar cf - .) | (cd "$MNTPOINT"; tar xf -)
================================================================
---- gitweb:
http://git.pld-linux.org/gitweb.cgi/readonly/geninitrd.git/commitdiff/147754ca159d40ca5eb541074dc043d8cbd92090
More information about the pld-cvs-commit
mailing list