8

As far as I understand, the snapshots made by btrfs subvolume snapshot are writable by default and are visible at a certain path under the mountpoint of your btrfs volume.

How to setup the system so that there is a gurantee during the normal operation of the system that nothing is written to the snapshot? But without making it invisible to the users (i.e., it should remain accessible for reading by any users with respect to their permissions).

(For now, I've just chmod og-rwx /.snapshots where my snapshots are mapped to. But that doesn't fulfill the second of my wishes, and also the guarantee is not strong enough: a process with root's rights could spoil something there.)

Does one need to do some tricks with mount to achieve this goal?

3
  • In LVM, there is AFAIU a dedicated lvchange --permission r for this purpose. Commented Aug 17, 2011 at 15:25
  • Comparing the default situation in btrfs (i.e., writable snapshots) to LVM: Can LVM snapshots be writable?. Commented Aug 22, 2011 at 23:57
  • 1
    What distro are you using? Ubuntu ships with an old version of btrfs-tools, and thus does not provide read-only snapshots. Commented May 16, 2012 at 23:04

3 Answers 3

7
  • Create a read-only subvolume (as root):
    btrfs subvolume snapshot -r /path/to/mounted/subvolume /path/to/snapshot
    
  • Change an already existing subvolume/snapshot to read-only:
    btrfs property set /path/to/snapshot ro true
    
  • Check current status for an existing subvolume:
    btrfs property get /path/to/snapshot ro
    

(Note that this did not work on older versions of Ubuntu.)

3
  • 1
    Doesn't work for me either on Ubuntu 11.10. Commented Feb 1, 2012 at 2:21
  • It works on Ubuntu 16.04 Commented Jul 21, 2016 at 17:26
  • 1
    @AleksandrDubinsky Can we at least try to generalise this away from Ubuntu. I expect the version of btrfs, or at least its user-space tools is more relevant. We know at least that v0.19 of the command line tool didn't work. Can we get a version number for that does work? Commented Jul 22, 2016 at 19:50
2

Are you using Ubuntu?

Ubuntu ships with an old version of btrfs-tools (aka "btrfs-progs"), and thus the userland tools do not support read-only snapshots.

See this bug (and it's parent bug):

https://bugs.launchpad.net/ubuntu/+source/btrfs-tools/+bug/924621

1

According to Btrfs wiki, read-only snapshots are available since Linux 2.6.38. So make sure you have a recent kernel. Apart from that, you should be just able to do it using ro mount option (mount -o [other-options],ro ...).

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .