dmsetup's snapshot target to try out changes to a disk images before committing them (the primary use case is when doing data recovery - repairing the image filesystem without risking any data).
The image is loop'd read-only, (and I also loop a backing file for the snapshot backing file) and create a snapshot like so:
$ echo 0 <size> snapshot <image-loop-device> <backing-loop-device> P 1 | \ dmsetup create <name>
It works fine: changes to
<name> are saved in
<image-loop-device> is untouched.
However, if the
<image-loop-device> is mounted, then
dmsetup fails, with a
Device or resource busy error. Why should
dmestup should need an exclusive lock on the
image device and is there a way around it (other than using a separate loop device for the mount)?