ZFS on Linux

Aug 11, 2019

I’ve known about ZFS for quite a while now, but it has seemed either too complicated or just not the right fit.

After Jim Salter talked about ZFS on techSNAP and Alex Kretzschmar wrote a great blog post on ZFS, I was conviced me to give it a shot at home.

What really hit home for me was the lack of redundancy on my current setup at home. Yes I have backups in place in case of catastrophic failure, but I had nothing to prevent data degredation over time. ZFS finally clicked for me when I made the comparison between checksums and DNA repair. It suddently all made sense, if DNA requires repair mechanisms, why not data storage? What this really boils down to is maintaining important data over time, knowing my data will remain bit for bit identical today and ten years from now.

I think one of the barriers to entry for ZFS is that it has its own lingo. Here’s a simple breakdown.

  • pool - Basic building block of ZFS. A pool is made up of one or more vdevs.
  • vdev - Most often a disk, but can also be a partition or file.

Installation

I have a fairly low spec home server. It has a Intel Kaby Lake Pentium G4600 two core four thread CPU with 8 GB of DDR4 RAM. Currently Ubuntu is the only Linux distribution to include the ZFS kernel module and user-level ZFS tools. ZFS on Linux can be installed on other distributions, but requires either installation by DKMS or compiling from source. The following instructions assume a LTS installed of Ubuntu. Go ahead and install ZFS on an updated system.

1
 pete@home:~$ sudo apt install zfsutils-linux

As a side note the ARC (adaptive replacement cache) by default will grow to half of the maximum RAM. This default can be changed, but has not been an issue even with my system’s modest amount of RAM.

Finding your Drives

  • mirror - Consists of two or more devices. Only holds as much data as its smallest member. Can withstand the failure of all but one of its members without losing data.
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
pete@home:~$ ls -l /dev/disk/by-id
total 0
lrwxrwxrwx 1 root root  9 Aug  9 16:10 ata-WDC_WD20EFRX-68EUZN0_WD-WCC4M1SAV1ZD -> ../../sda
lrwxrwxrwx 1 root root 10 Aug  9 16:10 ata-WDC_WD20EFRX-68EUZN0_WD-WCC4M1SAV1ZD-part1 -> ../../sda1
lrwxrwxrwx 1 root root 10 Aug  9 16:10 ata-WDC_WD20EFRX-68EUZN0_WD-WCC4M1SAV1ZD-part9 -> ../../sda9
lrwxrwxrwx 1 root root  9 Aug  9 16:10 ata-WDC_WD20EFRX-68EUZN0_WD-WCC4M7KKJ4YL -> ../../sdb
lrwxrwxrwx 1 root root 10 Aug  9 16:10 ata-WDC_WD20EFRX-68EUZN0_WD-WCC4M7KKJ4YL-part1 -> ../../sdb1
lrwxrwxrwx 1 root root 10 Aug  9 16:10 ata-WDC_WD20EFRX-68EUZN0_WD-WCC4M7KKJ4YL-part9 -> ../../sdb9
lrwxrwxrwx 1 root root 13 Aug  9 16:10 nvme-eui.0100000000000000 -> ../../nvme0n1
lrwxrwxrwx 1 root root 15 Aug  9 16:10 nvme-eui.0100000000000000-part1 -> ../../nvme0n1p1
lrwxrwxrwx 1 root root 15 Aug  9 16:10 nvme-eui.0100000000000000-part2 -> ../../nvme0n1p2
lrwxrwxrwx 1 root root 13 Aug  9 16:10 nvme-HP_SSD_EX900_120GB_HBSE19111700355 -> ../../nvme0n1
lrwxrwxrwx 1 root root 15 Aug  9 16:10 nvme-HP_SSD_EX900_120GB_HBSE19111700355-part1 -> ../../nvme0n1p1
lrwxrwxrwx 1 root root 15 Aug  9 16:10 nvme-HP_SSD_EX900_120GB_HBSE19111700355-part2 -> ../../nvme0n1p2
lrwxrwxrwx 1 root root  9 Aug  9 16:10 wwn-0x50014ee210d6f2d1 -> ../../sdb
lrwxrwxrwx 1 root root 10 Aug  9 16:10 wwn-0x50014ee210d6f2d1-part1 -> ../../sdb1
lrwxrwxrwx 1 root root 10 Aug  9 16:10 wwn-0x50014ee210d6f2d1-part9 -> ../../sdb9
lrwxrwxrwx 1 root root  9 Aug  9 16:10 wwn-0x50014ee2649ad2e6 -> ../../sda
lrwxrwxrwx 1 root root 10 Aug  9 16:10 wwn-0x50014ee2649ad2e6-part1 -> ../../sda1
lrwxrwxrwx 1 root root 10 Aug  9 16:10 wwn-0x50014ee2649ad2e6-part9 -> ../../sda9

#identify drives by wwn ID ls -l /dev/disk/by-id

#create zpool #ashift=12 parameter will use 4k blocksizes, standard on most drives #atime=off system has to update “Accessed” attribute of every file every time you look at it #compression=lz4 lz4 compression is faster than storage zpool create -o ashift=12 tank mirror /dev/disk/by-id/wwn-0x50014ee2649ad2e6 /dev/disk/by-id/wwn-0x50014ee210d6f2d1

#set parameters zfs set atime=off tank zfs set compression=lz4 tank

#create datasets sudo zfs create tank/documents

zpool status

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
pete@home:~$ sudo zpool status
  pool: tank
 state: ONLINE
  scan: scrub repaired 0B in 1h57m with 0 errors on Sun Aug 11 02:21:48 2019
config:

	NAME                        STATE     READ WRITE CKSUM
	tank                        ONLINE       0     0     0
	  mirror-0                  ONLINE       0     0     0
	    wwn-0x50014ee2649ad2e6  ONLINE       0     0     0
	    wwn-0x50014ee210d6f2d1  ONLINE       0     0     0

errors: No known data errors

RAM

I have a fairly low spec home server. It has a Intel Kaby Lake Pentium G4600 two core four thread CPU with 8 GB of DDR4 RAM. I was under the impression ZFS required a huge amount of RAM to run.

On an updated system with the drives you want to use installed, go ahead and install ZFS.

1
 pete@home:~$ sudo apt install zfsutils-linux

Finding your Drives

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
pete@home:~$ ls -l /dev/disk/by-id
total 0
lrwxrwxrwx 1 root root  9 Aug  9 16:10 ata-WDC_WD20EFRX-68EUZN0_WD-WCC4M1SAV1ZD -> ../../sda
lrwxrwxrwx 1 root root 10 Aug  9 16:10 ata-WDC_WD20EFRX-68EUZN0_WD-WCC4M1SAV1ZD-part1 -> ../../sda1
lrwxrwxrwx 1 root root 10 Aug  9 16:10 ata-WDC_WD20EFRX-68EUZN0_WD-WCC4M1SAV1ZD-part9 -> ../../sda9
lrwxrwxrwx 1 root root  9 Aug  9 16:10 ata-WDC_WD20EFRX-68EUZN0_WD-WCC4M7KKJ4YL -> ../../sdb
lrwxrwxrwx 1 root root 10 Aug  9 16:10 ata-WDC_WD20EFRX-68EUZN0_WD-WCC4M7KKJ4YL-part1 -> ../../sdb1
lrwxrwxrwx 1 root root 10 Aug  9 16:10 ata-WDC_WD20EFRX-68EUZN0_WD-WCC4M7KKJ4YL-part9 -> ../../sdb9
lrwxrwxrwx 1 root root 13 Aug  9 16:10 nvme-eui.0100000000000000 -> ../../nvme0n1
lrwxrwxrwx 1 root root 15 Aug  9 16:10 nvme-eui.0100000000000000-part1 -> ../../nvme0n1p1
lrwxrwxrwx 1 root root 15 Aug  9 16:10 nvme-eui.0100000000000000-part2 -> ../../nvme0n1p2
lrwxrwxrwx 1 root root 13 Aug  9 16:10 nvme-HP_SSD_EX900_120GB_HBSE19111700355 -> ../../nvme0n1
lrwxrwxrwx 1 root root 15 Aug  9 16:10 nvme-HP_SSD_EX900_120GB_HBSE19111700355-part1 -> ../../nvme0n1p1
lrwxrwxrwx 1 root root 15 Aug  9 16:10 nvme-HP_SSD_EX900_120GB_HBSE19111700355-part2 -> ../../nvme0n1p2
lrwxrwxrwx 1 root root  9 Aug  9 16:10 wwn-0x50014ee210d6f2d1 -> ../../sdb
lrwxrwxrwx 1 root root 10 Aug  9 16:10 wwn-0x50014ee210d6f2d1-part1 -> ../../sdb1
lrwxrwxrwx 1 root root 10 Aug  9 16:10 wwn-0x50014ee210d6f2d1-part9 -> ../../sdb9
lrwxrwxrwx 1 root root  9 Aug  9 16:10 wwn-0x50014ee2649ad2e6 -> ../../sda
lrwxrwxrwx 1 root root 10 Aug  9 16:10 wwn-0x50014ee2649ad2e6-part1 -> ../../sda1
lrwxrwxrwx 1 root root 10 Aug  9 16:10 wwn-0x50014ee2649ad2e6-part9 -> ../../sda9

zpool status

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
pete@home:~$ sudo zpool status
  pool: tank
 state: ONLINE
  scan: scrub repaired 0B in 1h57m with 0 errors on Sun Aug 11 02:21:48 2019
config:

	NAME                        STATE     READ WRITE CKSUM
	tank                        ONLINE       0     0     0
	  mirror-0                  ONLINE       0     0     0
	    wwn-0x50014ee2649ad2e6  ONLINE       0     0     0
	    wwn-0x50014ee210d6f2d1  ONLINE       0     0     0

errors: No known data errors