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 -- Karel Zak <kzak@xxxxxxxxxx> http://karelzak.blogspot.com -- 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