Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

loop-delete doesn't delete loop #1236

Open
tazihad opened this issue Jan 2, 2024 · 8 comments
Open

loop-delete doesn't delete loop #1236

tazihad opened this issue Jan 2, 2024 · 8 comments

Comments

@tazihad
Copy link

tazihad commented Jan 2, 2024

OS: Fedora Kinoite 39
udisks2 ver: udisks2-2.10.1-1.fc39.x86_64

Trying to delete loop device using loop-delete but it doesn't work.

❯ losetup -l
NAME       SIZELIMIT OFFSET AUTOCLEAR RO BACK-FILE                                           DIO LOG-SEC
/dev/loop0         0      0         1  1 /var/home/user/Downloads/lmde-5-cinnamon-64bit.iso   0     512
❯ udisksctl loop-delete --block-device /dev/loop0

No output. Disk still exist.

lsblk shows this:

❯ lsblk
NAME      MAJ:MIN RM   SIZE RO TYPE MOUNTPOINTS
loop0       7:0    0   1.9G  1 loop 
├─loop0p1 259:0    0   1.9G  1 part /run/media/user/LMDE 5 Cinnamon 64-bit
└─loop0p2 259:1    0   2.6M  1 part 
loop1       7:1    0     4G  0 loop 
├─loop1p1 259:5    0     4G  0 part /run/media/user/Kubuntu 22.04.3 LTS amd64
├─loop1p2 259:6    0   4.9M  0 part 
└─loop1p3 259:7    0   300K  0 part 
❯ udevadm info /dev/loop0
P: /devices/virtual/block/loop0
M: loop0
R: 0
U: block
T: disk
D: b 7:0
N: loop0
L: 0
S: disk/by-diskseq/111
S: disk/by-label/LMDE\x205\x20Cinnamon\x2064-bit
S: disk/by-uuid/2022-03-11-20-53-07-00
Q: 111
E: DEVPATH=/devices/virtual/block/loop0
E: DEVNAME=/dev/loop0
E: DEVTYPE=disk
E: DISKSEQ=111
E: MAJOR=7
E: MINOR=0
E: SUBSYSTEM=block
E: USEC_INITIALIZED=20894432514
E: ID_FS_BLOCKSIZE=2048
E: ID_FS_SIZE=2061582336
E: ID_FS_PUBLISHER_ID=Linux\x20Mint
E: ID_FS_DATA_PREPARER_ID=live-build\x203.0\x7ea57-1
E: ID_FS_UUID=2022-03-11-20-53-07-00
E: ID_FS_UUID_ENC=2022-03-11-20-53-07-00
E: ID_FS_BOOT_SYSTEM_ID=EL\x20TORITO\x20SPECIFICATION
E: ID_FS_VERSION=Joliet Extension
E: ID_FS_LABEL=LMDE_5_Cinnamon_64-bit
E: ID_FS_LABEL_ENC=LMDE\x205\x20Cinnamon\x2064-bit
E: ID_FS_TYPE=iso9660
E: ID_FS_USAGE=filesystem
E: ID_PART_TABLE_UUID=6ce364a3
E: ID_PART_TABLE_TYPE=dos
E: ID_LOOP_BACKING_DEVICE=0:44
E: ID_LOOP_BACKING_INODE=4476856
E: DEVLINKS=/dev/disk/by-diskseq/111 /dev/disk/by-label/LMDE\x205\x20Cinnamon\x2064-bit /dev/disk/by-uuid/2022-03-11-20-53-07-00
E: TAGS=:systemd:
E: CURRENT_TAGS=:systemd:


@tbzatek
Copy link
Member

tbzatek commented Jan 2, 2024

Does losetup -d work for you? I see it's set as autoclear=1, perhaps it's still used by the system. E.g. /run/media/user/LMDE 5 Cinnamon 64-bit. Try unmounting that before calling loop detach.

@tazihad
Copy link
Author

tazihad commented Jan 4, 2024

@tbzatek sudo losetup -d /dev/loop0 doesn't do anything with no output.

@tbzatek
Copy link
Member

tbzatek commented Jan 4, 2024

@tbzatek sudo losetup -d /dev/loop0 doesn't do anything with no output.

Then I think it works as expected. See the losetup(8) manpage:

       -d, --detach loopdev...
           Detach the file or device associated with the specified loop device(s). 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.

When you unmount partitions from the loop device, does it disappear?

@tazihad
Copy link
Author

tazihad commented Jan 4, 2024

@tbzatek using losetup -d does give Autoclear=1. But how do I delete the loop device without sudo?

❯ losetup -l

NAME       SIZELIMIT OFFSET AUTOCLEAR RO BACK-FILE                                           DIO LOG-SEC
/dev/loop0         0      0         0  1 /var/home/user/Downloads/lmde-5-cinnamon-64bit.iso   0     512
❯ sudo losetup -d /dev/loop0
[sudo] password for user: 
❯ losetup -l

NAME       SIZELIMIT OFFSET AUTOCLEAR RO BACK-FILE                                           DIO LOG-SEC
/dev/loop0         0      0         1  1 /var/home/user/Downloads/lmde-5-cinnamon-64bit.iso   0     512

@tbzatek
Copy link
Member

tbzatek commented Jan 4, 2024

Check your previous lsblk output:

├─loop0p1 259:0    0   1.9G  1 part /run/media/user/LMDE 5 Cinnamon 64-bit

You need to unmount this first.

@tbzatek
Copy link
Member

tbzatek commented Feb 1, 2024

Any luck?

@tazihad
Copy link
Author

tazihad commented Feb 2, 2024

@tbzatek no. I tried to create a Plasma widget. But I wanted remove disk without using sudo. Unfortunately I can't. Maybe you can close the issue with close as not planned.

@tbzatek
Copy link
Member

tbzatek commented Feb 6, 2024

Well as I said, you need to unmount everything that comes out of the loop block device first. I.e. if any partitions are detected as part of a loop setup, you need to iterate through these object and unmount those first.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants