Mounting a Snapshot as the Root File System

To roll back changes to the system, you can mount a snapshot as the root file system by specifying its ID as the default subvolume.

  1. Find the subvolume ID for the snapshot that you want to use to replace the root file system.
    For example, to get a listing of subvolumes and snapshots with their IDs, run:
    sudo btrfs subvolume list /
  2. Use the btrfs subvolume set-default command to change the default subvolume ID to use for the / mount point.
    sudo btrfs subvolume set-default 264 /
  3. Update the system GRUB configuration to ensure that the subvolume default isn't overwritten by a kernel boot argument.

    For example, run:

    default_kernel=$(sudo grubby --default-kernel);
    sudo grubby --remove-args="rootflags=subvol=root" --update-kernel $default_kernel
  4. Reboot the system for the changes to take effect.
    sudo reboot
  5. After the system has booted, validate that the snapshot subvolume is mounted on the root file system at /.

    You can review the information returned by the mount command:

    sudo mount|grep 'on / '

    The command might return output similar to the following:

    /dev/sda2 on / type btrfs (rw,relatime,seclabel,space_cache,subvolid=264,subvol=/.snapshots/root-snapshot1)

    Or run btrfs inspect-internal rootid to return the subvolume ID for the subvolume mounted at the / mount point.

    sudo btrfs inspect-internal rootid /