I have a program which creates partitions and filesystems on a disk. To test it, I have created an image file:

dd if=/dev/zero of=disk.img bs=1M count=100

and mounted:

sudo losetup /dev/loop0 disk.img

The partitioning process seemingly works, I get an error from mkfs:

mkfs.vfat: unable to open /dev/loop0p2: No such file or directory

I can see the partitions with fdisk -l:

sudo fdisk -l /dev/loop0
Disk /dev/loop0: 1000 MiB, 1048576000 bytes, 2048000 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: B2CB131D-0091-4102-89E1-1D94EC49484A

Device         Start     End Sectors  Size Type
/dev/loop0p1    2048   10239    8192    4M BIOS boot
/dev/loop0p2   10240  272383  262144  128M EFI System
/dev/loop0p3  272384 1320959 1048576  512M Linux swap
/dev/loop0p4 1320960 2047966  727007  355M Linux filesystem

but not with lsblk:

sudo lsblk
loop0    7:0    0  1000M  0 loop 
sda      8:0    0 465,8G  0 disk 
├─sda1   8:1    0   512M  0 part /boot/efi
├─sda2   8:2    0 457,3G  0 part /
└─sda3   8:3    0     8G  0 part [SWAP]

What am I doing wrong?

  • 2
    Any luck with losetup --partscan? kernel / distro version? Feb 21, 2018 at 10:25

1 Answer 1


Try using partprobe(which is part of parted package) or kpartx so kernel will get info about partitions.

Mounting / partitioning loopback devices not always causes kernel to re-read partition table.

It is common situation when you've got info:

Re-reading the partition table failed.: Device or resource busy.
The kernel still uses old table [...]

You can also force kernel to re-read partition table of loopback device by using: losetup -P command

As stated in manual:

   -P, --partscan
          Force the kernel to scan the partition table on a newly created loop device.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.