kdave / btrfs-progs

Development of userspace BTRFS tools
GNU General Public License v2.0
550 stars 241 forks source link

mkfs.btrfs refuses to make filesystem if another filesystem on the same device is mounted #640

Open DaanDeMeyer opened 1 year ago

DaanDeMeyer commented 1 year ago

If I try to run mkfs.btrfs on a loop device that represents a specific offset + size of another loop device, and that other loop device has existing partitions that are mounted, mkfs.btrfs will fail with "ERROR: /dev/loopxxx is mounted". Given that it's a completely different filesystem that is actually mounted, mkfs.btrfs should not fail in this case or at least provide an option to override the check.

DaanDeMeyer commented 1 year ago

This basically comes down to is_same_loop_file() being too strict. Having one loop device use another loop device can be perfectly safe as long as the loop device does not refer to any part of the other loop device that is actually in use.