52

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.

derobert
  • 107,579
  • 20
  • 231
  • 279
  • As a workaround you could make a writeble shapshot of your readonly snapshot. (I do this if I don't have the Internet to look up this question) – matega Nov 03 '15 at 07:26

1 Answers1

64

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).

derobert
  • 107,579
  • 20
  • 231
  • 279
  • 3
    You'll also find that while the kernel APIs evolve and distributions ship with newer and newer kernels, the `btrfs-tools` found on some same distributions are not always aligned. So you sometimes found yourself having to compile the latest btrfs-tools form the upstreams git repository to be able to use the btrfs features of your kernel (at least that was very much the case a few years ago). – Stéphane Chazelas Aug 12 '14 at 19:00
  • @StéphaneChazelas Yes, definitely. Though in this case I'm on Debian testing, which has btrfs-tools 3.14, so not that insanely old. – derobert Aug 12 '14 at 20:30
  • 1
    @mikeserv Indeed, it appears 3.14.2 split them out. I have 3.14.1, which is only a few months older, according to [kernel.org git](https://git.kernel.org/cgit/linux/kernel/git/mason/btrfs-progs.git/refs/). But even the [current man page](https://git.kernel.org/cgit/linux/kernel/git/mason/btrfs-progs.git/plain/Documentation/btrfs.txt) doesn't mention properties. I checked (and linked to) the current one on the wiki, too. Turns out the is a [separate, not-linked manpage](https://btrfs.wiki.kernel.org/index.php/Manpage/btrfs-property) for it though. – derobert Aug 12 '14 at 21:20
  • this location of the wiki has changed: https://btrfs.readthedocs.io/en/latest/btrfs-property.html – vrms Jun 01 '22 at 10:44