Install ZFS File System on Ubuntu 18.04 LTS

28/12/2020
In this article, I will show you how to install and setup ZFS Filesystem on Ubuntu 18.04 LTS. Let’s get started.

Installing ZFS Filesystem

First you have to make sure that main, restricted, universe and multiverse software sources of the official Ubuntu package repository are enabled.

To do that, run the following command:

$ sudo apt edit-sources

Press <Enter> to continue.

As you can see from the marked section of the screenshot below, I have all of these software sources enabled.

If you don’t have these enabled, run the following commands to add them one by one:

$ sudo apt-add-repository main
$ sudo apt-add-repository restricted
$ sudo apt-add-repository universe
$ sudo apt-add-repository multiverse

Now run the following command to update the apt package repository cache:

$ sudo apt-get update

The package repository cache should be updated.

Now you can run the following command to install ZFS Filesystem on Ubuntu 18.04 LTS:

$ sudo apt-get install zfsutils-linux

Now press y and then press <Enter> to continue.

ZFS Filesystem should be installed.

Setting Up ZFS RAID 0 Pool

In this section I will show you how to set up a ZFS RAID 0 Pool.

In RAID 0, you add some hard drives, and they are added together to make a single large virtual drive.

For example, if you setup 3 units of 1 TB hard drives in RAID 0 pool, it will be a single 3 TB virtual hard drive. All the data you write to it will be divided into the 3 drives equally. It will make the write speed 3 times faster than it is for 1 drive. The same goes for the read speed. That’s the advantages of RAID 0 setup.

But there is a disadvantage of RAID 0. If one of these 3 drives fail, all your data will be lost.

You can check the status of the ZFS pools you have configured with the following command:

$ sudo zpool status

As you can see, I have no pools available yet.

I will show you how to configure your first ZFS pool now. But before that, make sure you have at least 2 hard drives installed on your computer. It is required for RAID 0.

I installed 3 virtual hard drives (8 GB of size) on my Ubuntu 18.04 LTS VMware virtual machine as you can see in the screenshot below. I can access them as /dev/sdb, /dev/sdc, /dev/sdd

Now let’s create our first ZFS pool. I am going to call it files. Of course you can call it something else if you want.

Run the following command to create a ZFS pool files in RAID 0 setup:

$ sudo zpool create -f files/dev/sdb /dev/sdc /dev/sdd

ZFS pool files should be created.

Now you can run the following command to list your ZFS pool:

$ sudo zpool list

As you can see from the marked section of the screenshot below, the NAME of the pool is files and the SIZE is 23.8 GB (8 GB x 3 = 24 GB)

Your newly created files ZFS pool should be mounted on /files automatically as you can see from the output of the df command.

By default, /files mount point is only writeable by the user root. If you want to make /files writable by your own user and group, you can do so by running the following command:

$ sudo chown -Rfv USERNAME:GROUPNAME/files

NOTE: Here USERNAME and GROUPNAME are your login USERNAME and GROUPNAME. Usually they are the same.

As you can see from the screenshot below, the ownership of /files directory changed.

As you can see from the screenshot below, I can now copy and paste files into the /files directory as an ordinary user.

Changing the Mount Point of Existing ZFS Pool

By default, a ZFS pool is mounted on /ZFSPoolName.

For example, if the pool name is files, then it will be mounted on /files.

If you want, you can mount it somewhere else on your filesystem.

For example, if you want to mount files ZFS pool to /var/www, you can do so with the following command:

$ sudo zfs set mountpoint=/var/wwwfiles

NOTE: Make sure the directory where you want to mount the ZFS pool exists before you run this command.

As you can see from the output of the df command, the mount point is changed to /var/www

Removing a ZFS Pool

In this section I will show you how to remove the files ZFS pool you just created.

You can run the following command to remove the files ZFS pool:

$ sudo zpool destroy files

As you can see from the screenshot below, the files ZFS pool was removed.

That’s how you install and setup ZFS Filesystem on Ubuntu 18.04 LTS. Thanks for reading this article.

ONET IDC thành lập vào năm 2012, là công ty chuyên nghiệp tại Việt Nam trong lĩnh vực cung cấp dịch vụ Hosting, VPS, máy chủ vật lý, dịch vụ Firewall Anti DDoS, SSL… Với 10 năm xây dựng và phát triển, ứng dụng nhiều công nghệ hiện đại, ONET IDC đã giúp hàng ngàn khách hàng tin tưởng lựa chọn, mang lại sự ổn định tuyệt đối cho website của khách hàng để thúc đẩy việc kinh doanh đạt được hiệu quả và thành công.
Bài viết liên quan

How to install Desktop Dimmer on Ubuntu 17.04 and below

Desktop Dimmer is one of my favorite apps. It allows me to dimm or turn of my desktop light when its too bright. This app...
28/12/2020

Ubuntu Enable Universe

Have you ever installed new software or updates on Ubuntu and wondered what the four options it prompts are? Well, by default,...
29/12/2020

Install Clipgrab on Ubuntu

How to Install and Use ClipGrab on Ubuntu 17.10 ClipGrab is a software that is used to download videos from popular video...
12/02/2020
Bài Viết

Bài Viết Mới Cập Nhật

Mua proxy v4 chạy socks5 để chơi game an toàn, tốc độ cao
18/05/2024

Thuê mua proxy Telegram trọn gói, tốc độ cao, giá siêu hời
18/05/2024

Thuê mua proxy Viettel ở đâu uy tín, chất lượng và giá tốt? 
14/05/2024

Dịch vụ thuê mua proxy US UK uy tín, chất lượng số #1
13/05/2024

Thuê mua proxy Việt Nam: Báo giá & các thông tin MỚI NHẤT
13/05/2024