good.
moo.
Like directories, but can be manipulated like file systems, have snapshots and such. This stuff is kinda like bind mounts,
findmnt
- display info about mounts.btrfs subvolume create <path>
- create a subvol.
path
should be non existent.btrfs subvolume list <path>
- show subvols in the
fs containing path
.
-o
- show subvols below path
.btrfs subvolume show <path>
- show comprehensive
information about subvol at path
.rm -r <vol>
or
doas btrfs subvolume delete <vol>
- delete
subvol.umount <subvol>
- unmount subvol after it has
been mounted to a different path.mount -o subvol=<path>,<opts> <drive> <path>
- mount subvol. subvol
is how fstab
knows
where to mount what.subvol
- subvol path.subvolid
- subvol id.compression
- subvol compression. See Compression.There are several basic schemas to layout subvolumes (and snapshots).
$ Flat All subvols are children of root and later mounted into
appropriate directories. E.g. you can create all your subvolumes in
/subvolumes
- a directory, with parent root
,
and use /snapshots
- directory, - for snapshots.
$ Nested Subvols are located anywhere in file hierarchy - typically in their desired locations.
Comparison:
Displayed by doas btrfs subvolume list <path>
.
Start at 256 and increase by 1 for every new subvol. FS root always has
subvol name /
and id 5. When a btrfs partition is mounted
without an explicit subvolume, subvolid=5
is assumed.
list
shows top level id, most often it's 5 - root.
Snapshots are a diff vcs on a fs level. $ Snapshot is a subvolume
with added content: it holds references to current and/or past versions
of files (inodes). See COW for how this is possible.
Subvol snapshot won't contain children - so with subvols /
and /home
snapshoting /
won't copy
/home
. Snapshots are created with
btrfs subvolume snapshot <opts> <from> <to>
.
Benefit of snapshots over simple copying is COW - small changes to files
will cause small changes to disk usage. This can be verified with
compsize
.
Storing snapshots on a single fs is convenient but not really secure - fs failure will cascade to snapshots. Remedying this requires efficiently exchanging information about snapshots between btrfs (or between btrfs and non-btrfs) file systems.
To back up a subvolume
btrfs subvolume snapshot -r <subvol> <snapshot>
.btrfs send <snapshot> | btrfs receive <dest>
btrfs send -f <snapshot>.btrfs <snapshot>
.To utilize shared nodes between sent snapshots
btrfs send -p <parent> <snapshot>
.To restore a subvolume from a snapshot
btrfs send <snapshot> | btrfs receive <dest>
,btrfs subvolume snapshot <snapshot> <subvol>
.Can only be applied on a filesystem-wide level. blah blah.