1

On an btrfs volume, I have a folder snapshots/ in which I store a snapshot of the whole volume from time to time.

btrfs automatically mounts all subvolumes, eg. after mounting the top volume, snapshots/ is populated with all snapshots ever done.

Now I like to unmount the subvolumes in snapshots, leaving snapshots empty (without deleting the snapshots of course). This is very useful if I do backups, indexing or searching on the volume, which otherwise always needs to be limited in a tool-dependent fashion to exclude snapshots/, which is not always easy.

As the subvolumes are not mounted by kernel, I cannot unmount them with mount. How to unmount them?

0

You can organize your btrfs volumes in a different way to avoid this automatic mount (by not mounting btrfs / onto your system / but a btrfs subvolume like /rootfs onto your system / instead. Only btrfs subvolumes named /rootfs/foo/bar will be auto-mounted as /foo/bar in this case). But this is not a very easy task and you can have difficulties to reboot your computer if you fail one step.

As an umount workaround, the easier way in my opinion is to hide the content of you snapshot subvol my mounting a dumb mountpoint over it. You can automate this through your fstab like this:

none    /snapshot   tmpfs   defaults,size=1M,ro 0 0

To access your /snapshot subvol again, an easy way is to add a specific non-automatic mountpoint (read-only in this example because your rarely need to alter our snapshots):

/dev/sda2   /mnt/snapshots  btrfs   defaults,noauto,ro,subvol=/snapshot 0 2

Note: You can also simply not hide your snapshot subvol but set specific safe mount options for it:

/dev/sda2   /snapshots  btrfs   defaults,noexec,nodev,ro,subvol=/snapshot   0 2
1
  • Reboot is not an issue, as my btrfs volumes are not containing my root fs. – dronus Jun 12 '16 at 23:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.