Try to load dm-mod kernel module if kpartx fails
authorMichael Prokop <mika@grml.org>
Mon, 30 Jan 2012 10:29:40 +0000 (11:29 +0100)
committerMichael Prokop <mika@grml.org>
Mon, 30 Jan 2012 10:29:41 +0000 (11:29 +0100)
dm-mod isn't loaded OOTB on plain Debian/squeeze installations,
don't annoy the user...

grml-debootstrap

index 2fa035a..7a3728f 100755 (executable)
@@ -954,6 +954,13 @@ prepare_vm() {
   dd if=/dev/zero bs=1 conv=notrunc count=64 seek=446 of="$TARGET"
   parted -s "${TARGET}" 'mkpart primary ext3 2M -1'
 
+  # if dm-mod isn't available then kpartx will fail with
+  # "Is device-mapper driver missing from kernel? [...]"
+  if ! kpartx -av $TARGET >/dev/null 2>&1 ; then
+    einfo "Device-mapper not ready yet, trying to load dm-mod module."
+    modprobe dm-mod ; eend $?
+  fi
+
   DEVINFO=$(kpartx -av $TARGET) # 'add map loop1p1 (253:0): 0 6289408 linear /dev/loop1 2048'
   if [ -z "${DEVINFO}" ] ; then
     eerror "Error setting up loopback device." ; eend 1