![]() |
VOOZH | about |
We’re so glad you’re here. You can expect all the best TNS content to arrive Monday through Friday to keep you on top of the news and at the top of your game.
Check your inbox for a confirmation email where you can adjust your preferences and even join additional groups.
Follow TNS on your favorite social media networks.
Become a TNS follower on LinkedIn.
Check out the latest featured and trending stories while you wait for your first TNS newsletter.
As we noted last week, Ubuntu 19.10 has officially arrived and it brings along with it a number of really exciting features. Although the majority of those new options target desktop users, there is one particularly exciting feature that will benefit both desktop and server users. That feature is ZFS support.
First developed by Sun Microsystems for its Solaris Unix distro, ZFS is a combination 128-bit file system and logical volume manager that offers the following features:
Ask any admin and they’ll agree that the addition of ZFS is a big deal for Ubuntu. Why? The snapshots and rollback features alone are worth the price of entry (which, by the way, is free). With this feature, admins can roll back their systems to a working state (or a state that included accidentally deleted data). That’s quite a big deal.
Of course snapshots and rollbacks aren’t a new thing. In fact, many platforms have included this tool for years. So maybe Ubuntu is a bit behind the curve on this. But for anyone who uses Ubuntu this is a case of “better late than never.”
But how does ZFS work on Ubuntu? I’m glad you asked. Let me show you.
Before you dive into this, know that ZFS support in Ubuntu 19.10 is experimental. Although I’ve found it to be incredibly stable, you might think twice about using it in a production environment (until it is no longer listed as “experimental”).
Also, note that ZFS support is currently only offered during the desktop version installation. That doesn’t mean you cannot add support for the filesystem on the server version, but it’s not quite as simple. Because of this, I’ll be demonstrating on the desktop version of Ubuntu 19.10.
The first step is to enable ZFS at the install time of Ubuntu 19.10. During the installation, you will find a new option in the Installation type phase (Figure 1).
Once the installation completes, reboot and log in.
If you’re using the server version of Ubuntu 19.10, you can always install ZFS support with the command:
sudo apt-get install zfsutils-linux
Of course, should you go that route, you’ll have to take a few extra steps (such as creating datasets). With the desktop installation, you’ll find your entire directory hierarchy is made up of ZFS datasets, so there’s much less work to do.
Once you’ve logged into the desktop, you’ll want to open a terminal window and get a listing of your datasets. With Ubuntu installations that don’t use ZFS, you’d typically work with directory paths like /home/jack or /usr/local/. That’s not the case with ZFS-enabled systems. Instead, they work with datasets. A dataset is a type of filesystem that shares a storage pool (the most basic building block of ZFS).
To find your datasets, issue the command:
zfs list
As you can see (in Figure 2), every directory is either found in the bpool (boot) or rpool (root) pool.
Let’s work with a user’s home directory. In this case, the dataset rpool/USERDATA/jack_bwcn4u.
The first thing we’re going to do is create a new snapshot of the /home/jack directory (which, remember, is the rpool/USERDATA/jack_bwcn4u dataset). Let’s say we want to create a snapshot tagged with today’s date. The command for this would be:
sudo zfs snapshot rpool/USERDATA/jack_bwcn4u@FRIDAY10-18-19
Of you could include the date command like so:
sudo zfs rollback rpool/USERDATA/jack_bwcn4u@`date +%F`
To verify that your snapshot was taken, issue the command:
zfs list -t snapshot
You should see all current snapshots listed (Figure 3).
Let’s say, for whatever reason, a directory was accidentally deleted out of that home directory. What do you do? Fortunately, you’ve taken a snapshot and can roll that snapshot back, such that the deleted directory returns.
First, let’s delete the ~/Documents directory with the command:
rm -rf /home/jack/Documents
Issue the ls command and you can see the Documents directory is gone (Figure 4).
Now we’ll roll back the Friday snapshot to recover that directory. To do this, issue the command:
sudo zfs rollback rpool/USERDATA/jack_bwcn4u@FRIDAY10-18-19
After the command completes, issue ls again to see that Documents has returned (Figure 5).
Let’s say you’ve created a number of snapshots, or a particular snapshot has either corrupt or missing data. You might want to delete that snapshot. Let’s say we want to delete the rpool/USERDATA/jack_bwcn4u@FRIDAY10-18-19 snapshot. To do that, the command would be:
sudo zfs destroy rpool/USERDATA/jack_bwcn4u@FRIDAY10-18-19
Once you’ve destroyed a snapshot it cannot be retrieved, so use that command with care. If you happen to have a particularly important snapshot that you don’t want destroyed, you can place a hold on it. To place a hold on our rpool/USERDATA/jack_bwcn4u@FRIDAY10-18-19 snapshot, you would issue the command:
sudo zfs hold keep rpool/USERDATA/jack_bwcn4u@FRIDAY10-18-19
Now if you try to destroy that snapshot, you’ll see an error (Figure 6).
To destroy a held snapshot, you have to add the -d option like so:
sudo zfs destroy -d rpool/USERDATA/jack_bwcn4u@FRIDAY10-18-19
That’s it, the held snapshot is gone.
And that’s the basics of creating and destroying snapshots with the newly added ZFS feature in Ubuntu 19.10. Give this a try on a testing environment and see how well it works. So far I’ve only discovered one issue that, when trying to roll back a snapshot, I had to reboot the machine before the rollback command would successfully run. Outside of that one issue, it’s been smooth sailing with ZFS and Ubuntu 19.10.