“ZFS on Ubuntu 18.04 LTS Server Edition″

ZFS

What is ZFS?

The Z File System (ZFS) was originally designed at Sun Microsystem. It is an advanced file system and logical volume manager. It works on Solaris, FreeBSD, Linux and many other operating systems. The features of ZFS include protection against data corruption, compression, volume management, snapshots, data integrity, Software RAID, cache and much more.

1 STEP – INSTALL ZFS

Native OpenZFS management utilities for Linux are located in zfsutils-linux package. You can also use meta package called zfs. Simply type the following command:

$: sudo apt install zfs

Sample outputs:

Reading package lists... Done
Building dependency tree       
Reading state information... Done
Note, selecting 'zfsutils-linux' instead of 'zfs'
The following additional packages will be installed:
  libnvpair1linux libuutil1linux libzfs2linux libzpool2linux zfs-doc zfs-zed
Suggested packages:
  default-mta | mail-transport-agent samba-common-bin nfs-kernel-server zfs-initramfs
The following NEW packages will be installed:
  libnvpair1linux libuutil1linux libzfs2linux libzpool2linux zfs-doc zfs-zed zfsutils-linux
0 upgraded, 7 newly installed, 0 to remove and 19 not upgraded.
Need to get 884 kB of archives.
After this operation, 2,822 kB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://mirrors.service.networklayer.com/ubuntu xenial-updates/main amd64 zfs-doc all 0.6.5.6-0ubuntu10 [49.4 kB]
Get:2 http://mirrors.service.networklayer.com/ubuntu xenial-updates/main amd64 libuutil1linux amd64 0.6.5.6-0ubuntu10 [27.4 kB]
Get:3 http://mirrors.service.networklayer.com/ubuntu xenial-updates/main amd64 libnvpair1linux amd64 0.6.5.6-0ubuntu10 [23.5 kB]
Get:4 http://mirrors.service.networklayer.com/ubuntu xenial-updates/main amd64 libzpool2linux amd64 0.6.5.6-0ubuntu10 [385 kB]
Get:5 http://mirrors.service.networklayer.com/ubuntu xenial-updates/main amd64 libzfs2linux amd64 0.6.5.6-0ubuntu10 [106 kB]
Get:6 http://mirrors.service.networklayer.com/ubuntu xenial-updates/main amd64 zfsutils-linux amd64 0.6.5.6-0ubuntu10 [263 kB]
Get:7 http://mirrors.service.networklayer.com/ubuntu xenial-updates/main amd64 zfs-zed amd64 0.6.5.6-0ubuntu10 [29.8 kB]
Fetched 884 kB in 1s (651 kB/s)    
Selecting previously unselected package zfs-doc.
(Reading database ... 91925 files and directories currently installed.)
Preparing to unpack .../zfs-doc_0.6.5.6-0ubuntu10_all.deb ...
Unpacking zfs-doc (0.6.5.6-0ubuntu10) ...
Selecting previously unselected package libuutil1linux.
Preparing to unpack .../libuutil1linux_0.6.5.6-0ubuntu10_amd64.deb ...
Unpacking libuutil1linux (0.6.5.6-0ubuntu10) ...
Selecting previously unselected package libnvpair1linux.
Preparing to unpack .../libnvpair1linux_0.6.5.6-0ubuntu10_amd64.deb ...
Unpacking libnvpair1linux (0.6.5.6-0ubuntu10) ...
Selecting previously unselected package libzpool2linux.
Preparing to unpack .../libzpool2linux_0.6.5.6-0ubuntu10_amd64.deb ...
Unpacking libzpool2linux (0.6.5.6-0ubuntu10) ...
Selecting previously unselected package libzfs2linux.
Preparing to unpack .../libzfs2linux_0.6.5.6-0ubuntu10_amd64.deb ...
Unpacking libzfs2linux (0.6.5.6-0ubuntu10) ...
Selecting previously unselected package zfsutils-linux.
Preparing to unpack .../zfsutils-linux_0.6.5.6-0ubuntu10_amd64.deb ...
Unpacking zfsutils-linux (0.6.5.6-0ubuntu10) ...
Selecting previously unselected package zfs-zed.
Preparing to unpack .../zfs-zed_0.6.5.6-0ubuntu10_amd64.deb ...
Unpacking zfs-zed (0.6.5.6-0ubuntu10) ...
Processing triggers for libc-bin (2.23-0ubuntu3) ...
Processing triggers for initramfs-tools (0.122ubuntu8.1) ...
update-initramfs: Generating /boot/initrd.img-4.4.0-28-generic
Processing triggers for systemd (229-4ubuntu6) ...
Processing triggers for ureadahead (0.100.0-19) ...
Processing triggers for man-db (2.7.5-1) ...
Setting up zfs-doc (0.6.5.6-0ubuntu10) ...
Setting up libuutil1linux (0.6.5.6-0ubuntu10) ...
Setting up libnvpair1linux (0.6.5.6-0ubuntu10) ...
Setting up libzpool2linux (0.6.5.6-0ubuntu10) ...
Setting up libzfs2linux (0.6.5.6-0ubuntu10) ...
Setting up zfsutils-linux (0.6.5.6-0ubuntu10) ...
zfs-import-cache.service is a disabled or a static unit, not starting it.
zfs-import-scan.service is a disabled or a static unit, not starting it.
zfs-mount.service is a disabled or a static unit, not starting it.
Processing triggers for initramfs-tools (0.122ubuntu8.1) ...
update-initramfs: Generating /boot/initrd.img-4.4.0-28-generic
Setting up zfs-zed (0.6.5.6-0ubuntu10) ...
zed.service is a disabled or a static unit, not starting it.
Processing triggers for libc-bin (2.23-0ubuntu3) ...
Processing triggers for systemd (229-4ubuntu6) ...
Processing triggers for ureadahead (0.100.0-19) ...

1.2 STEP – WHAT IS A ZFS VIRTUAL DEVICES (ZFS VDEVs)?

A VDEV is nothing but a collection of a physical disk, file image, or ZFS software raid device, hot spare for ZFS raid. Examples are:

  1. /dev/sdb – a physical disk
  2. /images/200G.img – a file image
  3. /dev/sdc1 – A partition

1.3 STEP – WHAT IS A ZFS POOLSs (ZPOOL)?

A zpool is a storage made of VDEVS (a collect of VDEVS). We can combine two or more physical disks or files or combination of both.

2 STEP – CREATE A RAID1 MIRROR

Use the following syntax

$: zpoll create NAME mirror VDEV1 VDEV2

To create ZPool mirror group called RaidLab, enter:

$: sudo zpool create RaidLab mirror /dev/sdb /dev/sdc

Simply type the following command to see the current health status for ZPools:

$: zpool status

Type the following command to check the size and usage of ZPools:

$: zpool list
$: df

Type the following command to find out the I/O statistics:

$: zpool iostat
               capacity     operations    bandwidth
pool        alloc   free   read  write   read  write
----------  -----  -----  -----  -----  -----  -----
RaidLab     2.64M   888G      0      2      0  6.38K

You can now start copying data or store data in /nixcraft:
$: cd /RaidLab
$: ls
$: cd /foo/ . 

However, ZFS allows we to create file system. For example data or containers file systems in the pool called RaidLab:

$: sudo zfs create RaidLab/data
$: sudo zfs create RaidLab/containers
$: zfs list
NAME                  USED  AVAIL  REFER  MOUNTPOINT
RaidLab             2.67M   860G  2.59M  /RaidLab
RaidLab/containers    19K   860G    19K  /RaidLab/containers
RaidLab/data          19K   860G    19K  /RaidLab/data

2.1 – REMOVE ZPOOL

The command used is the following:

$: sudo zpool destroy zpoolNameHere
for our lab:
$: sudo zpool destroy nixcraft
$: zpool status

“cya to the next 1…. Njoy !”
bye dakj

Disclaimer: All the tutorials included on this site are performed in a lab environment to simulate a real world production scenario. As everything is done to provide the most accurate steps to date, we take no responsibility if you implement any of these steps in a production environment.

“We learn from our mistakes”

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.