In this walkthrough we'll be using 4 brand new Seagate IronWolf Pro 10TB 7200rpm 256MB hard drives to setup a ZFS storage pool (RAIDZ 10).
If you don't have ZFS already installed go ahead and run
sudo apt install zfsutils-linux
Before we do anything with the drives we need the disk identifier and sector size for each drive for step 3.
sudo fdisk -l
Output
Disk /dev/sda: 9.1 TiB, 10000831348736 bytes, 19532873728 sectors
Disk model: ST10000NE0008-2P
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
As a short summory what badblocks is:
Badblock command in Linux is used to search for bad blocks (block of memory which has been corrupted
and can no longer be used reliably) in a device.
Set your disk sector size after -b and drive path after -sw. The drive is filled 4 times and verified 4 times before completion, keep in mind depending on your disk size the process time may differ.
sudo badblocks -b 4096 -sw /dev/sda
Output
Testing with pattern 0xaa: done
Reading and comparing: done
Testing with pattern 0x55: done
Reading and comparing: done
Testing with pattern 0xff: 37.29% done, 60:39:34 elapsed. (0/0/0 errors)
To bind your disks in a zfs pool it's a good idea to setup an alias for each drive Why?? If you replug your disks the Disk Identifier may change and problems may occur.
cd /dev/disk/by-id && ls
List disk that starts with ST1
ll ata-ST1* -ltr
Setup alias by serial number for each disk.
cd /etc/zfs/ && sudo nano vdev_id.conf
Example
alias 01 /dev/disk/by-id/ata-ST10000NE0008-2P****
alias 02 /dev/disk/by-id/ata-ST10000NE0008-2M****
After you save vdev_id.conf, reload udev.
sudo udevadm trigger
Check new disk aliases probably working.
cd /dev/disk/by-vdev && ll
Creating the RAID 10 pool, below the pool name is gitpool and disk 01 & 02 will be mirrored and same to 03 & 04 (if you run in to any issues add -f after create).
sudo zpool create gitpool mirror 01 02 mirror 03 04
Inspect your new pool
zpool status
or for more info do
zpool list -v
This will save a significant amount of disk space.
sudo zfs set compression=lz4 gitpool
To get the ratio on your pool
zfs get compressratio gitpool
I strongly recommend not dumping files in the root directory of your pool. Setup a nice folder structure.
sudo zfs create gitpool/data
Change directory ownership of you'r new pool (go to the root folder of your system).
sudo chown -R $USER:$USER gitpool/
If you run in to errors/health degraded without any data lost
sudo zpool list
See status of pool(s).
sudo zpool status
Test the integrity of all files in your pool (can take a day or two depending on pool size)
sudo zpool scrub gitpool
and then
zpool clear gitpool