Now we will configure the ZFS pool and its datasets. If you have 3 to 4 disks, raidz is recommended. If you have 5 to 6 disks, raidz2 is recommended. Less than 3 disks is not recommended since the only possible redundancy would be with 2 disks in mirror mode with only one redundancy disk and only 50% capacity. For more than 6 discs it is recommended that you make 2 or more pools. Directories will also be prepared for the configuration of the containers in the OS partition, that is, on the SSD. This provides better performance in their execution. The container configuration will be backed up to the hard drives once a day.
- After logging in, assume
rootby runningsudo -i. - Run:
./scripts/generate_zfs_key.sh. A hex key will be generated in/keys/Tank.dat. It is recommended that you back up this key in a safe place because if the SSD fails and the key is lost, the data in the pool will be lost forever. - Run:
./scripts/create_zfs_pool.sh raidz2 /dev/disk/by-id/disk1 /dev/disk/by-id/disk2 /dev/disk/by-id/disk3 /dev/disk/by-id/disk4 /dev/disk/by-id/disk5 /dev/disk/by-id/disk6. Adjust the parameters to choose the appropriate type ofraidz. It is advisable to use disk names by id, uuid or label. Do not use the disk name (for example /dev/sda) as these can change after a reboot and the pool will not work. - Execute:
./scripts/create_zfs_datasets.sh. Enter the names of the users you wish to create Samba shares for one by one. Datasets will be created with the username in capital letters, for exampleTank/USER1. Additionally, it will create aTank/Appsdataset to back up the container configuration, aTank/MediaCenterdataset to store the media files and aTank/NextClouddataset to store backup files. The datasets that will be used as Samba shares will be configured so that SELinux allows access to them by Samba. - Run:
./scripts/create_app_folders.shto generate the container directories on the SSD. - Run:
./scripts/generate_dataset_mount_units.sh. This will generate Systemd units that will mount the datasets inTankautomatically after loading the key upon rebooting the server. Run this commandcat /etc/zfs/zfs-list.cache/Tankto verify that the cache file is not empty. If it is empty, try running the script again as it means the cache and units were not generated.
Tip
To adjust the max size of ZFS ARC, use the command echo {size_in_bytes} > /sys/module/zfs/parameters/zfs_arc_max replacing {size_in_bytes} with the size in bytes you wish to set. To make the change permanent, execute the command echo "options zfs zfs_arc_max={size_in_bytes}" > /etc/modprobe.d/zfs.conf && dracut --force.
Caution
Assigning a very high value can cause instability in the system, only change it if you know what you are doing.