How to create a ZFS mirror pool

Jack Wallen guides you through the process of creating a RAID1 mirror on Ubuntu 19.10, using ZFS.

How to create a ZFS mirror pool
Jack Wallen guides you through the process of creating a RAID1 mirror on Ubuntu 19.10, using ZFS.

ZFS is an advanced file system that can manage data that extends across different devices. ZFS uses virtual storage pools, called zpools. A zpool can contain multiple folders and can make your data redundant.

That redundancy is crucial in data centers, where you may store customer information and more. The last thing you want is a disc with that data that goes bad. How do you avoid that? You can set up a backup system or use a standard RAID configuration. However, if you use Linux as the platform used to process and store that data, you can use ZFS pools.

I want to show you how to set up a ZFS mirror (RAID1) pool using two external disks. I will demonstrate on Ubuntu 19.10, via a VirtualBox virtual machine. I created two new disks via the VirtualBox GUI to use for the mirror. Read Adding New Disks to a VirtualBox Virtual Machine for more information about adding a new disk to a VirtualBox VM.

SEE: 10 things that companies store in their own data centers (TechRepublic download)

What you need

For this to work you need the following:

  • An active copy of Ubuntu (desktop or server) 19.10

  • Two non-formatted disks connected to the machine

  • A user with sudo rights

How to make the mirror

We must first find out the names of our two discs. Give that the command:

sudo fdisk -l

You should see your devices. In my case, these are / dev / sdb and / dev / sdc. With those names we can now make the mirror. We make a mirror with the name trtest. The command for this is:

sudo zpool create trtest / dev / sdb / dev / sdc

That command should complete fairly quickly. When it is finished, you will get your terminal back. Let’s make sure the mirror was created with the command:

sudo zpool status

You should see that both sdb and sdc are now listed under the trtest pool (Figure A).

Figure A

Our mirror is made.


The newly made mirror is mounted on / trtest (because we have named our pole). If you give the ls -l / command, you will see that the folder is owned by root (Figure B).

Figure B

Our new mirror is owned by root.

Because the mirror is owned by root, users and applications cannot change or save files in that folder. To remedy that, we must change the rights. How you do this depends on what you need the mirror for. For example, if you have a group named data that contains all users and apps that need access to that folder. You can change the group ownership and rights. Run the command to change the group to data:

sudo chgrp data / trtrest

Then we have to change the group rights to read, write and execute. This is done with the command:

sudo chmod g + rwx / trtest

At this point, any user or app that belongs to the data group has access to the ZFS mirror pool that is mounted on / trtest.

And that is all to create a RAID1 mirror using ZFS. Enjoy that improved data integrity.

Datacenter Trends Newsletter

DevOps, virtualization, the hybrid cloud, storage and operational efficiency are just a few of the topics of the data center that we will discuss.
Delivered on Monday and Wednesday

Register today

Also see

Image: Jack Wallen

Hitting the Books: How one of our first ‘creative’ weapons assisted stop the Nazis

Houghton Mifflin Harcourt Excerpted from 12 Seconds of Silence: How a Team of Inventors, Tinkerers, and Spies Took Down a Nazi Superweapon by Jamie Holmes. Used by permission of Houghton Mifflin Harcourt.From the deck of the USS Lexington, on May 8, 1942, a barrage of deafening shots flung dozens of five-inch rounds into the clear sky. They…

FBI, Homeland Security detail how Iranian hackers took United States voter information

They made at least some attempt to cover their tracks. Many of the linked IP addresses come from NordVPN’s service as well as other VPN providers.The attackers obtained voter registration info for “at least one” state, officials said, although they unsurprisingly weren’t specific about the nature of that breach or the volume of data taken.CISA…

How innovation and policy can alleviate climate impacts in an age of colliding crises

Today, the federal government spends less than $9 billion annually on energy innovation, which is less than a quarter of what it invests in health innovation and less than a tenth of what it invests in defense innovation. As we sit at a crossroads of an unprecedented confluence of challenges — from a public health…

Leave a Reply