How to create a ZFS storage pool on Ubuntu Server 18.04

If you need to expand your cloud solution storage options, a ZFS storage pool might be ideal.

How to create a ZFS storage pool on Ubuntu server

ZFS is a combined file system and logical volume manager that is scalable and includes features such as protection against data corruption. It also offers high storage capacity, allows for snapshots and copy-on-write clones, and much more. Because of its ability to deal with large amounts of data, a ZFS storage pool makes for a great way to extend your on-premises cloud solution.

Let's walk through the process of creating a ZFS storage pool. I'll demonstrate on Ubuntu Server 18.04.

SEE: Serverless computing: A guide for IT leaders (Tech Pro Research)

What you need

In order to successfully create the ZFS storage pool, you'll need:

  • A running instance of Ubuntu Server.
  • A user account with sudo privileges.

Installing ZFS

The first thing to do is to install the ZFS package. As this is found within the standard repository, it can be installed with the single command:

sudo apt-get install zfsutils-linux -y

Once that installation completes, you're ready to create the pool.

Creating a ZFS pool

The first step in creating your ZFS pool is knowing what type of pool to create and which drives to pool. There are two types of simple pools to create:

  • Striped pool, where a copy of data is stored across all drives.
  • Mirrored pool, where a single, complete copy of data is stored on all drives.

Next, you need to know which drives are available to pool. To find out what drives you have available, issue the command:

sudo fdisk -l

You should see all of your available drives (Figure A).

Figure A

Figure A: Our available drives for pooling.

I created two virtual drives for the purpose of using them in a ZFS pool:

  • /dev/vda
  • /dev/vdb

To create a striped pool, the command would be:

sudo zpool create pool1 /dev/vda /dev/vdb

To create a mirrored pool, the command would be:

sudo zpool create pool1 mirror /dev/vda /dev/vdb

In both of the above examples, the newly created pool would be called pool1.

Our new pool would then be mounted at /pool1 (Figure B).

Figure B

Figure B: Our pool is now ready to use.

You can check the status of your pool with the command:

sudo zpool status

The above command will list out the state and other information of the newly created pool (Figure C).

Figure C

Figure C: The status of our new zpool.

You can now associate the newly created pool with your cloud storage solution, giving you plenty of room for expansion.

Removing the pool

If you need to remove the pool, it can be done with the command:

sudo zpool destroy pool1

Remember to substitute pool1 with whatever you named your pool.

And that's all there is to creating either a striped or mirrored ZFS pool on Ubuntu Server. With this tool at the ready, you don't have to worry about your cloud solution running out of storage room.

Also see

Image: Jack Wallen

By Jack Wallen

Jack Wallen is an award-winning writer for TechRepublic, The New Stack, and Linux New Media. He's covered a variety of topics for over twenty years and is an avid promoter of open source. For more news about Jack Wallen, visit his website jackwallen....