How to make a btrfs snapshot writable?

According to the btrfs Readonly snapshots patch it’s possible to “set a snapshot readonly/writable on the fly.” So I should be able to turn my readonly snapshot (created with btrfs snapshot -r) writable, somehow.

But neither the btrfs subvolume manpage nor any other part of that manpage seems to give a way to do that.

Answers:

Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

The btrfs manpage fails to document the property subcommand, which I found by grep’ing the source. It’s also in btrfs --help.

To set a snapshot to read-write, you do something like this:

btrfs property set -ts /path/to/snapshot ro false

Change that to true to set it to read-only.

You can also use list to see the available properties:

btrfs property list -ts /path/to/snapshot
ro                  Set/get read-only flag of subvolume.

-t specifies the type of object to work on, s means subvolume. Other options are f (filesystem), i (inode), and d (device). If you don’t specify, it’ll show all applicable ones (for list) or try to guess for get/set.

Edit: in the newest btrfs tools, there is a btrfs-property manpage documenting that subcommand, although it’s not mentioned in the main manpage at all. It’s also available as the btrfs-property page on the wiki.

(Note: This requires a new-enough btrfs-tools. Apparently on Debian Wheezy, you’ll have to install the updated one from wheezy-backports; thanks artfulrobot).


All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments