New answers tagged loop-device
I made a small change to the test framework, and the problem went away. Specifically, rather than calling kpartx -u /dev/vda after I repartition the device, I call kpartx -d followed by kpartx -a. And now everything is fine. Weird...
The kernel first has to learn about the partitions. Once you partition a loop device (say /dev/loop0) you can't really mount it as such (the partition obviously doesn't begin at the beginning of the device). For physical drives you can instruct the kernel to re-read the partition table (at least fro (S)ATA drives) with hdparm -z. Another option is to use a ...
A stab in the dark, but maybe cfdisk updates the kernel partition table when it runs? Is your application logic compatible with loop devices? Format the disk image file, creating your desired partitions Setup the loopback device using the -P option to update the kernel's partition table: losetup -P /dev/loop0 <image file> Mount the partition: mount ...
libguestfs now has a command guestmount which spins up a virtual machine to allow you to mount arbitrary partitions in user space.
Top 50 recent answers are included