Sometimes you really need a do over

This is the 2nd blog in a 4-part series highlighting many of the Cumulus Linux features in our 3.2 release. In this post, we’ll be detailing a feature exclusive to Cumulus Networks  —  Snapshots.

You know the feeling — you just ran your favorite Linux command with the –force option and typed “yes” to the question “Are you sure?”.

The command generates WAY more output than you were expecting. The back of your neck starts to tingle.  And it’s late Friday afternoon no less.  This can’t be good.  You really need a do over.

We hear you. In order to help you undo, fix and mitigate command errors, we created snapshots and rollbacks — the newest Cumulus Linux features, now available in our 3.2 release.

With Cumulus Networks, web-scale networking is easier and more powerful than ever. We incorporate the best technology from the Linux desktop and server ecosystems. When we come across a desktop application that works well, we bring it to network switches.

In the latest version of Cumulus Linux, we deploy the Btree File System (BTRFS) for the root file system. BTRFS brings a number of powerful capabilities to your operating system, most notably snapshots and rollback.

Intro to BTRFS: Subvolumes and Snapshots

Without diving too deep into BTRFS internals (see the references for more details), BTRFS uses the concept of subvolumes to organize the data blocks of the disk. Think of a subvolume as a collection of references to currently used disk blocks. A single BTRFS partition can contain multiple subvolumes, one of which is declared to be the “default subvolume” and is mounted automatically.

Cumulus-Linux-Features-Snapshots-Intro-to-BTRFS

BTRFS maintains a reference count for each disk block in order to track how many subvolumes are using that block. When no subvolumes are using a disk block and the reference count drops to zero, BTRFS returns the data block to the pool of free data blocks.

A snapshot is a special type of subvolume, where the collection of disk block references is copied from another subvolume’s collection at a point in time.

Cumulus-Linux-Features-Snapshots-Intro-to-BTRFS2

The important point is the snapshot is a copy of disk block references, not a copy of the actual disk blocks themselves. This property makes snapshots fairly lightweight.

When a disk block in the original subvolume changes, BTRFS uses its “Copy on Write” (CoW) technology to first copy the original block to a fresh disk block and then update the fresh block with the new data.

Cumulus-Linux-Features-Snapshots-Intro-to-BTRFS3

The snapshot is still referring to the original unmodified data block, while the current subvolume has moved on, pointing to the new, updated block.

What is Rollback?

When disaster strikes you want to roll back everything, going back in time to a known good state.

To roll back to an earlier snapshot simply update the “default subvolume” to use the desired snapshot and reboot.

During the next boot the snapshot subvolume is mounted and the state of the file system now reflects the earlier point in time.

Yeah! Everything is back to how it was.

OK Great. So what can I do with it?

The fundamental primitives of “snapshot” and “rollback” provide the foundation for several exciting and useful operational workflows.

Automatic Hourly, Daily, Monthly Snapshots

Cumulus Linux includes the snapper utility, making time-based snapshots super easy to manage. Snapper allows you to keep a historical record of your file system. For example, you can keep online snapshots handy for the last 6 hours, the last 7 days and
the last 6 months.

The hourly snapshots could be used for fast, easy recovery from a fat-finger catastrophe. What a life saver!

You might use a monthly snapshot to jog your memory about a VLAN configuration on port 23 that was working 4 months ago. You changed it last week when installing a new PoE wireless access point… What was that network configuration syntax again?

Snapper also enables you to inspect the differences between two snapshots. You can easily see the differences between the file system of today and the file system of last week. This is very powerful!

Automatic pre- and post- Software Upgrade Snapshots

We have all upgraded our cell phone OS, only to discover our favorite feature or app no longer works like it used to. You mutter to yourself, “The new one may be better is some ways, but I really liked the old one. I wish I could go back.”

With Cumulus Linux and snapshots, you can.

When upgrading the system software via apt-get, Cumulus Linux takes a snapshot of the system before the upgrade and after the upgrade. If for whatever reason you want to go back, you can.

The rollback includes the Linux kernel, device drivers, network configuration, applications —  all the critical bits of the operating system.

Try the newest Cumulus Linux features risk-free

At Cumulus Networks we are all about making networks better, easier and faster.

Accelerate your experience with Cumulus Linux and snapshots on the Cumulus VX virtual machine.