Btrfs, also known as Butter FS, Better FS, or B-tree FS, is a modern file system that Oracle began designing and developing in 2007, and it was merged into the Linux 2.6.29 kernel in 2009. Btrfs is licensed under the GPL and is not very stable, although many Linux distributions are integrated, but are not used as default file systems. Btrfs is widely integrated because of its support for disk snapshots, support for recursive snapshots, RAID support, child volumes (subvolumes), and enabling online sizing of file system sizes. Although most Linux distributions are currently using EXT4 as the primary file system, they are likely to be replaced by Btrfs at any time in the future.
Btrfs is mainly designed to solve the current Linux file system various "weaknesses" of the COW (copy-on-write) file system, is expected to provide better scalability and reliability, its main development focus is on fault tolerance, repair and ease of management.
Next I'll show you how to use apt-btrfs-snapshot to roll back the Btrfs file system snapshot in Linux to the previous system state. Using Apt-btrfs-snapshot to create and manage file system snapshots is as simple as other apt operations, and we can easily recover the state of the Btrfs file system using it.
In order to create and use Btrfs to restore your Linux file system, of course, you need to use the Btrfs file system, you need not use the Ext file system separate/boot partition, or you can not play.
Install Btrfs Package
After the condition is met, install the Apt-btrfs-snapshot package using the following command:
Apt-get Install Apt-btrfs-snapshot
After the installation is complete, use the following Apt-btrfs-snapshot command to check that the creation of the Btrfs snapshot is supported:
If the prerequisites for the Btrfs file system are met, the supported is output, or the output is:
Sorry, your system lacks support for the snapshot feature
You can check the default layout for Btrfs on Ubuntu by using the following command:
Btrfs Subvolume List
To create a snapshot using the ATP operation
To test the rollback operation, we first perform some apt operations in the current system, such as Apt-get.
Apt-get Update && Apt-get upgrade
Press Y to continue with the system upgrade, and you will see that Apt-btrfs-snapshot has automatically created a snapshot of the system state prior to the upgrade.
You can also use the following command to view the list of snapshots in the current system:
Btrfs Subvolume List/
Restore Btrfs Snapshots
For example, in the system upgrade process encountered problems, we need to restore the system before the upgrade state, you can mount the Btrfs file system to a separate location, such as/mnt under operation.
Viewing the/MNT directory outputs the child volumes:
The @apt-snapshot-2016-05-24_02:18:31 is the root file system snapshot of the previous apt operation. Rename the current child volume to the beginning of @, and then rename the @apt-snapshot-2016-05-24_02:18:31 to reboot the system after the current child volume, which restores the snapshot.
Delete Btrfs Snapshots
When a snapshot is restored, or if you need to free up some disk space, you can use the following command to delete the snapshot:
Btrfs Subvolume delete/mnt/@_latest-root/
To be blunt, a Btrfs snapshot is actually a child volume that is data-shared with other child volumes, sharing data and modifying the snapshot using Btrfs's copy-on-write capabilities, and the original child volumes are not visible. Once the snapshot is created, it is considered an alternate version of the original file system.