HDD-Housing e.U.

Create a ZFS pool: mirror, RAIDZ or single disk

Note: Replace poolname in all commands with your customer ID.

Further reading: ZFS on Linux (Proxmox wiki)

Introduction

Build the pool with WWN or PARTUUID device names. This way the pool can be imported anywhere, even from a USB enclosure. For normal operation, the disk ID (/dev/disk/by-id/ata-…) would be sufficient as well.

Name the pool after your customer ID – this simplifies deployment. The pool name can be changed later.

Any pool layout is possible, the price is always per HDD.

Mirror with 2 HDDs

Find the WWN of each hard drive:

ls -l /dev/disk/by-id/
# Look for the first target HDD, in our example:
#   ata-WDC_WD40EFRX-68WT0N0_WD-WCC4E4DF9NJD -> ../../sdj
# So the first target HDD is sdj. Now look for the WWN that belongs to sdj:
#   wwn-0x50014ee20c6324e6 -> ../../sdj
# Same for the second target HDD:
#   ata-WDC_WD40EFRX-68WT0N0_WD-WCC4E6FN513C -> ../../sdk
#   wwn-0x50014ee20c629629 -> ../../sdk

Create the pool with these WWNs:

zpool create -o ashift=12 -O compression=zstd poolname mirror /dev/disk/by-id/wwn-0x50014ee20c6324e6 /dev/disk/by-id/wwn-0x50014ee20c629629

RAIDZ1

Find the WWN of each hard drive as shown above, then:

zpool create -o ashift=12 -O compression=lz4 poolname raidz1 /dev/disk/by-id/wwn-1 /dev/disk/by-id/wwn-2 /dev/disk/by-id/wwn-3

Single disk without redundancy

zpool create -o ashift=12 -O compression=lz4 poolname /dev/disk/by-id/wwn-0x50014ee20c6324e6

Single disk with 5 partitions for redundancy

Warning: This layout is very slow. It protects against individual bad sectors, but not against failure of the whole drive.

Create 5 partitions:

apt install parted
parted /dev/disk/by-id/ata-WDC_WD40EFRX-68WT0N0_WD-WCC4E4DF9NJD mklabel gpt
parted /dev/disk/by-id/ata-WDC_WD40EFRX-68WT0N0_WD-WCC4E4DF9NJD mkpart zfs 0% 20%
parted /dev/disk/by-id/ata-WDC_WD40EFRX-68WT0N0_WD-WCC4E4DF9NJD mkpart zfs 20% 40%
parted /dev/disk/by-id/ata-WDC_WD40EFRX-68WT0N0_WD-WCC4E4DF9NJD mkpart zfs 40% 60%
parted /dev/disk/by-id/ata-WDC_WD40EFRX-68WT0N0_WD-WCC4E4DF9NJD mkpart zfs 60% 80%
parted /dev/disk/by-id/ata-WDC_WD40EFRX-68WT0N0_WD-WCC4E4DF9NJD mkpart zfs 80% 100%

Find the device letter of the drive:

ls -l /dev/disk/by-id/ata-WDC_WD40EFRX-68WT0N0_WD-WCC4E4DF9NJD
# /dev/disk/by-id/ata-WDC_WD40EFRX-68WT0N0_WD-WCC4E4DF9NJD -> ../../sdh

List the PARTUUIDs of all partitions on sdh:

ls -l /dev/disk/by-partuuid/ | grep sdh
# 2c49c49f-4221-324e-afca-23bedbb06677 -> ../../sdh1   (= partuuid1, and so on)

Create the pool with all 5 PARTUUIDs:

zpool create -o ashift=12 -O compression=lz4 poolname raidz1 /dev/disk/by-partuuid/partuuid1 /dev/disk/by-partuuid/partuuid2 /dev/disk/by-partuuid/partuuid3 /dev/disk/by-partuuid/partuuid4 /dev/disk/by-partuuid/partuuid5