Re: `losetup --remove` is confusing, and misuse silently fails

Karel Zak <[email protected]> Thu, 16 Oct 2025 12:28:52 +0200
Newsgroups org.kernel.vger.util-linux
Message-ID <wog3s3sk34ewa6ulgspplk6fhb4hwd3nd55wse3gk2dsl6avyl@yqoq3miwfx5n>
On Fri, Oct 10, 2025 at 11:41:08AM +0200, Benno Schulenberg wrote:
> After setting up a loop device with:
> 
>   # ./losetup loop4 some.img
> 
> I wanted to see what happens when trying to "remove" it
> (since the man page says it is "not recommended"):

https://github.com/util-linux/util-linux/pull/3803

A new PR, summary:

 - losetup: add error feedback for --remove command - Improves error
   reporting in the remove_loop() function so users see meaningful
   error messages when removal fails.

 - losetup: make --remove a long-only option with mutual exclusivity -
   Removes the -R short option (keeping only --remove) and adds mutual
   exclusivity with other major operations like -d, -D, -a, -c, -f,
   -j, -l, and -O. Updates man page, bash completion, and usage text.

 - losetup: improve --remove documentation - Rewrites the --remove
   description and adds a new "LOOP DEVICE LIFECYCLE" section
   explaining the difference between creation, detachment, and removal
   operations.

 Karel

-- 
 Karel Zak  <[email protected]>
 http://karelzak.blogspot.com