[lxc-users] how to mount btrfs subvolume to /home lxd centos7 container

siranee.ja at tpc.co.th siranee.ja at tpc.co.th
Wed Sep 6 14:45:30 UTC 2017


Hi All,

I tested btrfs subvolume snapshot with lxd container.
I tested on lxd version 2.0.10
I don't know how can I mount the btrfs subvolume as flat layout as describe on
https://btrfs.wiki.kernel.org/index.php/SysadminGuide

I would like to make snapshot the whole /home to be /home_yyyymmddhhmm.


=====================
 Layout

There are several basic schemas to layout subvolumes (including snapshots) as well
as mixtures thereof.
Flat

Subvolumes are children of the top level subvolume (ID 5), typically directly below
in the hierarchy or below some directories belonging to the top level subvolume, but
especially not nested below other subvolumes, for example:

toplevel         (volume root directory, not to be mounted by default)
  +-- root       (subvolume root directory, to be mounted at /)
  +-- home       (subvolume root directory, to be mounted at /home)
  +-- var        (directory)
  |   \-- www    (subvolume root directory, to be mounted at /var/www)
  \-- postgres   (subvolume root directory, to be mounted at /var/lib/postgresql)

Here, the toplevel mountable root directory should not normally be visible to the
system. Of course, the www<tt> subvolume could have also been placed directly below
the top level subvolume (without an intermediate directory) and the <tt>postgres<tt>
subvolume could have also been placed at a directory <tt>var/lib/postgresql; these
are just examples and the actual layout depends largely on personal taste. All
subvolumes are however direct children of the top level subvolume in this scheme.

This has several implications (advantages and disadvantages):

    Management of snapshots (especially rolling them) may be considered easier as
the effective layout is more directly visible.
    All subvolumes need to be mounted manually (e.g. via fstab) to their desired
locations, e.g. in the above example this would look like:

LABEL=the-btrfs-fs-device   /                    subvol=/root,defaults,noatime  0  0
LABEL=the-btrfs-fs-device   /home                subvol=/home,defaults,noatime  0  0
LABEL=the-btrfs-fs-device   /var/www             subvol=/var/www,noatime        0  0
LABEL=the-btrfs-fs-device   /var/lib/postgresql  subvol=/postgres,noatime       0  0

    Each of these subvolumes/mountpoints can be mounted with some options being
different.

    This means however as well, that any typically useful mount options (for example
noatime) need to be specified again for each mountpoint.

    Everything in the volume that's not beneath a subvolume that has been mounted,
is not accessible or even visible. This may be beneficial for security,
especially when being used with snapshots, see below.
===============

Best Regards,

Siranee Jaraswachirakul.




More information about the lxc-users mailing list