Hi Karel Thanks for your detailed explanation. Good to hear I did hit a real (although already known) issue. Too bad there is no easy fix. Anyway, one last minor comment: Ubuntu 13.04 64bit does not yet support option -P for losetup. So this must be an older version of util-linux. But then: how do I determine the version of util-linux installed? The binaries have no --version option and 'strings /sbin/losetup | egrep '[0-9]' does not reveal anything useful either. Maybe there is a general version for util-linux available in another binary? The man page does not tell. I failed to identify the version number! Regards BB. On 07.10.2013 13:38, Karel Zak wrote: > On Tue, Sep 24, 2013 at 06:22:11PM +0200, butter@xxxxxxxxxx wrote: >> get deleted when you call "losetup -d DEVICE". This causes other programs >> (like lvmdiskscan -l) to report Input/output errors. >> >> Here is how to reproduce the problem: >> >> LOOPDEV=/dev/loop3 >> IMAGEFILE=`pwd`/mydisk.img >> MOUNTPOINT=`pwd`/mnt >> >> # 1. Create and mount an ext4 partition from a file-based disk image >> dd if=/dev/zero of=$IMAGEFILE bs=1M count=80 >> sudo losetup $LOOPDEV $IMAGEFILE > > kernel uses partitions on loop devices conditionally, and here you said > "I don't care about partitions...". You have to use > > sudo losetup -P $LOOPDEV $IMAGEFILE > > if you want to force kernel loopdev driver to use partitions. > >> sudo parted $LOOPDEV mklabel msdos >> sudo parted $LOOPDEV mkpart primary 2048s 43007s >> sudo mkfs -t ext4 ${LOOPDEV}p1 >> mkdir $MOUNTPOINT >> sudo mount ${LOOPDEV}p1 $MOUNTPOINT >> >> # 2. Unmount again => ERROR: the partition device files are not deleted >> sudo umount $MOUNTPOINT > > mount/umount is completely irrelevant for this issue. The simple way > to reproduce the problem is: > > dd if=/dev/zero of=img bs=1M count=80 > losetup -f img --show > parted /dev/loop0 mklabel msdos > parted /dev/loop0 mklabel msdos > losetup -d /dev/loop0 > > cat /sys/block/loop0/size > cat /sys/block/loop0/loop0p1/size > > Anyway, the problem is that parted uses BLKPG_ADD_PARTITION ioctl to create > /dev/loop0p1, but the loop0 device has been created without PARTSCAN flag > (see /sys/block/loop0/loop/partscan). It means that loopdev kernel driver > does not call BLKRRPART during loop0 cleanup (loop_clr_fd() in kernel code). > > You can remove the partition manually by BLKPG_DEL_PARTITION ioctl: > > # partx -d /dev/loop0p1 > > > ... but this all is known issue, Phillip Susi tried to fix this > disadvantage, but his solution has been reverted (see kernel commit > c2fccc1c9f7c81700cbac2120a4ad5441dd37004). > > > Karel > -- To unsubscribe from this list: send the line "unsubscribe util-linux" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html