udisks icon indicating copy to clipboard operation
udisks copied to clipboard

`udisksctl loop-delete -b /dev/loop0` does not print a warning

Open paulmenzel opened this issue 4 years ago • 3 comments

On Debian sid/unstable with udisks2 2.9.1-2, having a disk image with one partition, and doing

$ udisksctl loop-setup -f debian-f2fs.img
Mapped file debian-f2fs.img as /dev/loop0.

The device is loop mounted.

$ lsblk
NAME           MAJ:MIN RM   SIZE RO TYPE  MOUNTPOINT
loop0            7:0    0     2G  0 loop  
└─loop0p1      259:0    0     2G  0 part  /media/myuser/ee32e3bc-1201-47d6-be37
[…]

Trying to unmount the “parent device“ does not show an error though.

$ udisksctl loop-delete -b /dev/loop0
$ echo $?
0

and the device is still mounted, leading to confusion.

paulmenzel avatar Jan 02 '21 08:01 paulmenzel

Doing udisksctl loop-delete -b /dev/loop0p1, the partition is unmounted, and the loop device deleted.

paulmenzel avatar Jan 02 '21 09:01 paulmenzel

This is Debian sid/unstable with udisks2 2.9.1-2. (I updated the issues description.)

paulmenzel avatar Jan 02 '21 09:01 paulmenzel

The problem is kernel no longer returns EBUSY when we detach a "busy" loop device:

Note that since Linux v3.7 kernel uses "lazy device destruction". The detach operation does not return EBUSY error anymore if device is actively used by system, but it is marked by autoclear flag and destroyed later.

The same happens with losetup -- the loop device is automatically destroyed after unmounting the partition:

[vtrefny@localhost ~]$ lsblk /dev/loop0
NAME      MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
loop0       7:0    0  50M  0 loop 
└─loop0p1 259:1    0  49M  0 part /run/media/root/07d98cc6-1832-4236-8599-86f4fc198db0
[vtrefny@localhost ~]$ sudo losetup -d /dev/loop0
[vtrefny@localhost ~]$ lsblk /dev/loop0
NAME      MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
loop0       7:0    0  50M  0 loop 
└─loop0p1 259:1    0  49M  0 part /run/media/root/07d98cc6-1832-4236-8599-86f4fc198db0
[vtrefny@localhost ~]$ sudo umount /run/media/root/07d98cc6-1832-4236-8599-86f4fc198db0
[vtrefny@localhost ~]$ lsblk /dev/loop0
[vtrefny@localhost ~]$ 

vojtechtrefny avatar Jan 05 '21 08:01 vojtechtrefny