* losetup -d does not move partition devices
@ 2013-09-24 16:22 butter
2013-10-07 11:38 ` Karel Zak
0 siblings, 1 reply; 6+ messages in thread
From: butter @ 2013-09-24 16:22 UTC (permalink / raw)
To: util-linux
Hi all
On Ubuntu Desktop 13.04 64bit the loop device partitions do not automatically
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
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
sudo losetup -d $LOOPDEV
rmdir $MOUNTPOINT
rm $IMAGEFILE
ls -l ${LOOPDEV}*
The last command shows:
/tmp/test[10:18]% ls -l ${LOOPDEV}*
brw-rw---- 1 root disk 7, 3 Sep 24 18:18 /dev/loop3
brw-rw---- 1 root disk 259, 0 Sep 24 18:17 /dev/loop3p1
As no device is connected there is no partition 1! Isn't this a bug?
Regards
BB.
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: losetup -d does not move partition devices
2013-09-24 16:22 losetup -d does not move partition devices butter
@ 2013-10-07 11:38 ` Karel Zak
2013-10-07 14:24 ` Phillip Susi
2013-10-08 23:22 ` butter
0 siblings, 2 replies; 6+ messages in thread
From: Karel Zak @ 2013-10-07 11:38 UTC (permalink / raw)
To: butter; +Cc: util-linux, Phillip Susi
On Tue, Sep 24, 2013 at 06:22:11PM +0200, butter@breezl.com 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@redhat.com>
http://karelzak.blogspot.com
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: losetup -d does not move partition devices
2013-10-07 11:38 ` Karel Zak
@ 2013-10-07 14:24 ` Phillip Susi
2013-10-08 23:22 ` butter
1 sibling, 0 replies; 6+ messages in thread
From: Phillip Susi @ 2013-10-07 14:24 UTC (permalink / raw)
To: Karel Zak; +Cc: butter, util-linux, Jens Axboe
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On 10/7/2013 7:38 AM, Karel Zak wrote:
> ... but this all is known issue, Phillip Susi tried to fix this
> disadvantage, but his solution has been reverted (see kernel
> commit c2fccc1c9f7c81700cbac2120a4ad5441dd37004).
Jens, I had assumed from your commit message that you intended to
reintroduce a fixed version of that patch in the following cycle. Did
I misunderstand or did this get lost in the shuffle?
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.17 (MingW32)
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/
iQEcBAEBAgAGBQJSUsQlAAoJEJrBOlT6nu75HpMH/RuVqo79Wlwr793RR2b9QSgU
58QHTcjcGb7pwOSnqHC68Ys5v3r1nqbp7VoRh8nc2V3XvMitGmwLbdDXafDTVOdt
2N3gl518w+XaIUMwUHYGnbGsaqba0OHr5u95/REUI1tW3hfgX+rQJBx7eJ5gC28x
oeHK7gu1jAHlaKeA6OUIiVxGYCp2kwZGj0goJy7uP9mWvscVjy/skZBjIv5iCFnN
gizrKxkD4++GjNul5TtfeI9SAW0coetrjXz11lJQ3o1JWu6X0shmp4KpR223ry3+
hdFdegaNXM3IDumHvdjkdxwUGg6M1VzojXJLguHs5NwYQTI6qzinvsxZJXkYPoQ=
=2EWu
-----END PGP SIGNATURE-----
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: losetup -d does not move partition devices
2013-10-07 11:38 ` Karel Zak
2013-10-07 14:24 ` Phillip Susi
@ 2013-10-08 23:22 ` butter
2013-10-09 7:53 ` Karel Zak
1 sibling, 1 reply; 6+ messages in thread
From: butter @ 2013-10-08 23:22 UTC (permalink / raw)
To: Karel Zak; +Cc: util-linux, Phillip Susi
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@breezl.com 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
>
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: losetup -d does not move partition devices
2013-10-08 23:22 ` butter
@ 2013-10-09 7:53 ` Karel Zak
2013-10-09 10:16 ` Matthias Schniedermeyer
0 siblings, 1 reply; 6+ messages in thread
From: Karel Zak @ 2013-10-09 7:53 UTC (permalink / raw)
To: butter; +Cc: util-linux, Phillip Susi
On Wed, Oct 09, 2013 at 01:22:50AM +0200, butter@breezl.com wrote:
> 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!
The option --version for losetup is supported since v2.21.
Karel
--
Karel Zak <kzak@redhat.com>
http://karelzak.blogspot.com
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: losetup -d does not move partition devices
2013-10-09 7:53 ` Karel Zak
@ 2013-10-09 10:16 ` Matthias Schniedermeyer
0 siblings, 0 replies; 6+ messages in thread
From: Matthias Schniedermeyer @ 2013-10-09 10:16 UTC (permalink / raw)
To: Karel Zak; +Cc: butter, util-linux, Phillip Susi
On 09.10.2013 09:53, Karel Zak wrote:
> On Wed, Oct 09, 2013 at 01:22:50AM +0200, butter@breezl.com wrote:
> > 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!
>
> The option --version for losetup is supported since v2.21.
As Debian (even SID/unstable) only has an ancient version of util-linux
i'm not surprised.
$ dpkg -l | grep util-linux
ii util-linux 2.20.1-5.5 i386 Miscellaneous system utilities
$ losetup --version
losetup: unrecognized option '--version'
...
If Ubuntu doesn't roll it's own util-linux, there is the explantion.
--
Matthias
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2013-10-09 10:23 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-09-24 16:22 losetup -d does not move partition devices butter
2013-10-07 11:38 ` Karel Zak
2013-10-07 14:24 ` Phillip Susi
2013-10-08 23:22 ` butter
2013-10-09 7:53 ` Karel Zak
2013-10-09 10:16 ` Matthias Schniedermeyer
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox