I am trying to create some block devices with losetup and kpartx as follow:

#losetup --show -f disk.img
#kpartx -avs /dev/loop0

so nothing happend, and kpartx -l gives nothing as well:

#kpartx -l /dev/loop0

the mapper directory is empty:

#ll /dev/mapper/
total 0
drwxr-xr-x  2 root root      60 Apr 14 18:43 ./
drwxr-xr-x 20 root root    4340 Apr 14 18:43 ../
crw-------  1 root root 10, 236 Apr 14 18:43 control

I am running ubuntu 16.04.2

#uname -a
Linux ganeti 4.4.0-72-generic #93-Ubuntu SMP Fri Mar 31 14:07:41 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
#dpkg -l | grep kpartx
ii  kpartx                             0.5.0+git1.656f8865-5ubuntu2.4             amd64        create device mappings for partitions
#lsmod | grep ^dm*
drbd                  348160  0
drm_kms_helper        155648  1 ast
dca                    16384  3 igb,ixgbe,ioatdma
drm                   364544  4 ast,ttm,drm_kms_helper

I don't see dm_mod module, so I tried:

#modprobe dm_mod

so I tried the following steps:

  1. purged kpartx and reinstalled it
  2. reinstalled the kernel

problem still there!

Any idea? Thanks a lot!

  • 1
    Are you sure there is a partition table on /dev/loop0 which is disk.img? Can you run fdisk on it (of gdisk or something else if it's GPT) to show? – Celada Apr 14 '17 at 17:59
  • Thanks a lot @Celada , there wasn't a partition table on /dev/loop0/. Now I can go on. Thank you very much. – Max Apr 14 '17 at 18:35
  • Hi, i'm having the same problem even though there is an image on the loop device, kpartx does not create a mapper for that loop device. how was the problem resolved ? – Mheni Nov 19 '18 at 17:01
  • @Mheni you might have got this to work, any way you need to create a partition table on /dev/loop0/ – Max Mar 29 at 16:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.