diff options
author | maximilian attems <maks@debian.org> | 2007-08-08 01:02:16 +0200 |
---|---|---|
committer | maximilian attems <maks@debian.org> | 2007-08-08 01:02:16 +0200 |
commit | ccb150b16473ce974a0fbbb236c0dd95a022ec43 (patch) | |
tree | da4989f298df3f46b610b3976acf40dfd49626af /hook-functions | |
parent | f917408f4bb541f44973be3f7ef4a48ba6528e9a (diff) | |
download | initramfs-tools-ccb150b16473ce974a0fbbb236c0dd95a022ec43.tar.gz initramfs-tools-ccb150b16473ce974a0fbbb236c0dd95a022ec43.zip |
hook-functions: fix dep_add_modules() for lvm, md and luks root
a better shot and try for finding the underlying root devices
in the case of MODULES=dep and /sys walk.
dep_add_modules() should be splitted..
Diffstat (limited to 'hook-functions')
-rw-r--r-- | hook-functions | 26 |
1 files changed, 22 insertions, 4 deletions
diff --git a/hook-functions b/hook-functions index b371cbb..ef4a94e 100644 --- a/hook-functions +++ b/hook-functions @@ -185,16 +185,34 @@ copy_modules_dir() # only copy relevant modules dep_add_modules() { - local x + local root rootfs block minor device_path module x # findout root block device + fstype eval "$(mount | awk '/ \/ / {print "root=" $1 "\nrootfs=" $5; exit}')" - block=${root#/dev/} - block=${block%[0-9]*} + + # lvm luks root + if [ "${root#/dev/mapper/}" != "${root}" ]; then + minor=$((0x$(stat --format "%T" ${root}) % 256)) + block=$(ls -1 /sys/block/dm-${minor}/slaves | head -n 1) + if [ "${block#dm-}" != "${block}" ]; then + block=$(ls -1 /sys/block/${block}/slaves | head -n 1) + fi + block=${block%[0-9]*} + # md root + elif [ "${root#/dev/md}" != "${root}" ]; then + root=${root#/dev/} + block=$(awk "/^${root}/{print substr(\$5, 1, 3); exit}" \ + /proc/mdstat) + # classical root device + else + block=${root#/dev/} + block=${block%[0-9]*} + fi # Error out if /sys lack block dev if [ -z "${block}" ] || [ ! -e /sys/block/${block} ]; then - echo "Error: missing ${block} root ${root} /sys entry" + echo "mkinitramfs: missing ${block} root ${root} /sys entry" + echo "mkinitramfs: Error use MODULES=most" exit 1 fi |