btrfs-progs icon indicating copy to clipboard operation
btrfs-progs copied to clipboard

`btrfs send` errors when used on a ro-mounted fs but the subvol isn't ro

Open 25pwn opened this issue 2 years ago • 1 comments

btrfs send gives ERROR: subvolume ${subvol} is not read-only when the fs is mounted as ro but ${subvol} is a non-ro subvol.

25pwn avatar Jul 09 '22 16:07 25pwn

btrfs send gives ERROR: subvolume ${subvol} is not read-only when the fs is mounted as ro but ${subvol} is a non-ro subvol.

@25pwn It means that the subvol itself has to be ro, not that the filesystem should be ro.

You can make a ro snapshot that can be used with send with btrfs subvolume snapshot -r.

Forza-tng avatar Jul 09 '22 17:07 Forza-tng

Send requires that the subvolume is immutable during the operation, it's not even possible to flip the ro flag when it's running. The read-only mount does not guarantee that, there can be another writable mount of the same subvolume, this would break send.

kdave avatar Aug 16 '22 14:08 kdave

Sorry, I never got the notifications for these

@25pwn It means that the subvol itself has to be ro, not that the filesystem should be ro.

You can make a ro snapshot that can be used with send with btrfs subvolume snapshot -r.

@Forza-tng What I (wrongly) believed was that ro-mounted subvols are immutable, therefore they should be sendable.

Send requires that the subvolume is immutable during the operation, it's not even possible to flip the ro flag when it's running. The read-only mount does not guarantee that, there can be another writable mount of the same subvolume, this would break send.

@kdave I see. Though this would be a niche feature, could you see this(send when subvol is rw but immutable due to only being mounted ro etc.) being implemented? If I were to make these changes myself, would you accept the pull request?

25pwn avatar Aug 17 '22 17:08 25pwn

Though this would be a niche feature, could you see this(send when subvol is rw but immutable due to only being mounted ro etc.) being implemented? If I were to make these changes myself, would you accept the pull request?

The problem is that it's not possible to implement. There's no way to prevent changing any file from the rw subvolume during the send from another mount. In a very limited case "I know what am I doning" yes, but any accidental change would lead to corruption of the send stream and this would lack safety for general case.

kdave avatar Aug 18 '22 15:08 kdave

Understood, thank you for answering

25pwn avatar Sep 11 '22 06:09 25pwn

I've added a note about that to send manual page.

kdave avatar Sep 21 '22 08:09 kdave