Last active
May 6, 2020 14:08
-
-
Save pvalkone/8942370 to your computer and use it in GitHub Desktop.
Create a ZFS pool on FreeBSD 10.0-RELEASE with Advanced Format (4K sector) drives
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Create 4K sector gnop(8) devices for the first disk of each of the three vdevs | |
$ sudo gnop create -S 4096 /dev/label/disk1 /dev/label/disk5 /dev/label/disk8 | |
# Create the backup pool using three RAID-Z1 vdevs | |
$ sudo zpool create backup raidz /dev/label/disk1.nop /dev/label/disk2 /dev/label/disk3 /dev/label/disk4 | |
$ sudo zpool add backup raidz /dev/label/disk5.nop /dev/label/disk6 /dev/label/disk7 /dev/label/disk12 | |
$ sudo zpool add backup raidz /dev/label/disk8.nop /dev/label/disk9 /dev/label/disk10 /dev/label/disk11 | |
$ zpool list | |
NAME SIZE ALLOC FREE CAP DEDUP HEALTH ALTROOT | |
backup 21.8T 1.29M 21.7T 0% 1.00x ONLINE - | |
$ zpool status | |
pool: backup | |
state: ONLINE | |
scan: none requested | |
config: | |
NAME STATE READ WRITE CKSUM | |
backup ONLINE 0 0 0 | |
raidz1-0 ONLINE 0 0 0 | |
label/disk1.nop ONLINE 0 0 0 | |
label/disk2.nop ONLINE 0 0 0 | |
label/disk3.nop ONLINE 0 0 0 | |
label/disk4.nop ONLINE 0 0 0 | |
raidz1-1 ONLINE 0 0 0 | |
label/disk5.nop ONLINE 0 0 0 | |
label/disk6.nop ONLINE 0 0 0 | |
label/disk7.nop ONLINE 0 0 0 | |
label/disk12.nop ONLINE 0 0 0 | |
raidz1-2 ONLINE 0 0 0 | |
label/disk8.nop ONLINE 0 0 0 | |
label/disk9.nop ONLINE 0 0 0 | |
label/disk10.nop ONLINE 0 0 0 | |
label/disk11.nop ONLINE 0 0 0 | |
errors: No known data errors | |
# Check that the vdevs are 4K-aligned (ashift = 12) | |
$ zdb | grep ashift | |
ashift: 12 | |
ashift: 12 | |
ashift: 12 | |
# Export the pool | |
$ sudo zpool export backup | |
# Destroy the gnop(8) devices | |
$ sudo gnop destroy /dev/label/disk1.nop /dev/label/disk5.nop /dev/label/disk8.nop | |
# Import the pool | |
$ sudo zpool import backup | |
$ zpool status | |
pool: backup | |
state: ONLINE | |
scan: none requested | |
config: | |
NAME STATE READ WRITE CKSUM | |
backup ONLINE 0 0 0 | |
raidz1-0 ONLINE 0 0 0 | |
label/disk1 ONLINE 0 0 0 | |
label/disk2 ONLINE 0 0 0 | |
label/disk3 ONLINE 0 0 0 | |
label/disk4 ONLINE 0 0 0 | |
raidz1-1 ONLINE 0 0 0 | |
label/disk5 ONLINE 0 0 0 | |
label/disk6 ONLINE 0 0 0 | |
label/disk7 ONLINE 0 0 0 | |
label/disk12 ONLINE 0 0 0 | |
raidz1-2 ONLINE 0 0 0 | |
label/disk8 ONLINE 0 0 0 | |
label/disk9 ONLINE 0 0 0 | |
label/disk10 ONLINE 0 0 0 | |
label/disk11 ONLINE 0 0 0 | |
errors: No known data errors | |
# Add a hot spare | |
$ sudo zpool add backup spare /dev/label/disk13 | |
$ zpool status | |
pool: backup | |
state: ONLINE | |
scan: none requested | |
config: | |
NAME STATE READ WRITE CKSUM | |
backup ONLINE 0 0 0 | |
raidz1-0 ONLINE 0 0 0 | |
label/disk1 ONLINE 0 0 0 | |
label/disk2 ONLINE 0 0 0 | |
label/disk3 ONLINE 0 0 0 | |
label/disk4 ONLINE 0 0 0 | |
raidz1-1 ONLINE 0 0 0 | |
label/disk5 ONLINE 0 0 0 | |
label/disk6 ONLINE 0 0 0 | |
label/disk7 ONLINE 0 0 0 | |
label/disk12 ONLINE 0 0 0 | |
raidz1-2 ONLINE 0 0 0 | |
label/disk8 ONLINE 0 0 0 | |
label/disk9 ONLINE 0 0 0 | |
label/disk10 ONLINE 0 0 0 | |
label/disk11 ONLINE 0 0 0 | |
spares | |
label/disk13 AVAIL | |
errors: No known data errors | |
# Enable lz4 compression | |
$ sudo zfs set compression=lz4 backup | |
# Create media and scratch filesets | |
$ sudo zfs create backup/media | |
$ sudo zfs create backup/scratch | |
# Check that compression is enabled | |
$ zfs get compression | |
NAME PROPERTY VALUE SOURCE | |
backup compression lz4 local | |
backup/media compression lz4 inherited from backup | |
backup/scratch compression lz4 inherited from backup | |
# Set 500G quota for backup/scratch | |
$ sudo zfs set quota=500G backup/scratch | |
# Check that the quota was set | |
$ zfs get quota backup/scratch | |
NAME PROPERTY VALUE SOURCE | |
backup/scratch quota 500G local | |
# Allow the pool size to be expanded without having to export and import it or reboot the system | |
$ sudo zpool set autoexpand=on backup | |
# Disable access time updates | |
$ sudo zfs set atime=off backup | |
$ zfs get atime | |
NAME PROPERTY VALUE SOURCE | |
backup atime off local | |
backup/media atime off inherited from backup | |
backup/scratch atime off inherited from backup | |
# Set ACL mode and inheritance to passthrough for Samba | |
$ sudo zfs set aclmode=passthrough backup/media | |
$ sudo zfs set aclinherit=passthrough backup/media | |
$ sudo zfs set aclmode=passthrough backup/scratch | |
$ sudo zfs set aclinherit=passthrough backup/scratch | |
# Share media and scratch file systems via NFS | |
$ sudo zfs sharenfs="-alldirs" backup/media | |
$ sudo zfs sharenfs="on" backup/scratch |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment