Creating Btrfs Subvolumes and Snapshots

Subvolumes and snapshots are key features within Btrfs. Subvolumes can be mounted anywhere within the file system. Snapshots are types of subvolumes that create Copy-On-Write (COW) copies of the data within a subvolume at a moment in time, thereby providing incremental backup and rollback functionality within the file system.

  1. Use the btrfs subvolume create command to create a subvolume.

    To create a subvolume, specify the path to the subvolume that you want to create on the mounted Btrfs file system:

    btrfs subvolume create /mnt/subvolume1

    The subvolume is created and appears as an empty subdirectory within the directory on the mounted Btrfs file system where you created it.

  2. Use the btrfs subvolume snapshot command to create a snapshot of a subvolume.

    To create a snapshot of a subvolume, specify the path to the subvolume that you want to create a snapshot of and the path on the Btrfs file system where you want to store snapshots. For example, you might run:

    btrfs subvolume snapshot /mnt/subvolume1 /mnt/subvolume1_$(date -I)

    A snapshot of subvolume1 is created using the current date as part of its name. The snapshot operation is nearly instant because of the COW nature of the file system. The snapshot contains all the data from the subvolume that it was created from at the moment in time that it was created. The snapshot also doesn't use a significant amount of extra disk space.

    Important:

    Taking snapshots of a subvolume isn't a recursive process. If you create a snapshot of a subvolume, every subvolume or snapshot that the subvolume contains is mapped to an empty directory of the same name inside that snapshot.

    You can automate snapshots of the file system by using the Snapper utility. See Automating File System Snapshots With the Snapper Utility for more information.

  3. Use the btrfs subvolume list command to list all the subvolumes within a btrfs file system.

    List the subvolumes within a Btrfs file system at a mount point, for example:

    btrfs subvolume list /mnt

    All the subvolumes from the top-level subvolume in the file system at the specified path are listed, regardless of whether the path is mounted onto a subvolume deeper into the tree of subvolumes. Snapshots are also listed, because snapshots are also subvolumes.

    Note:

    You can use this command to find the ID values of the available subvolumes or snapshots. The subvolume ID value can be useful when mounting an alternative subvolume or snapshot for a rollback.

  4. Use the btrfs subvolume delete command to delete a subvolume when you no longer need it.

    For example, to delete a snapshot or subvolume, you can run:

    btrfs subvolume delete /mnt/snapshots/subvol_2025-01-24