Install and Setup ZFS on Debian 11 Rumi, April 16, 2022January 24, 2024 The full form of ZFS is Zettabyte File System. The ZFS filesystem is a 128-bit filesystem. The ZFS supported filesystem size is 3×10(to the poer 24) TB. You may never encounter such a big filesystem in real life. The ZFS filesystem was designed to keep and access an insane amount of data. Enabling Debian contrib Package Repository: The ZFS filesystem packages are available in the official Debian 11 contrib package repository. The contrib package repository is not enabled on Debian 11 by default. But you can easily enable it from the command-line. To enable the contrib package repository, open a Terminal and run the following command: $ sudo apt-get install software-properties-common $ sudo apt-add-repository contrib The official Debian contrib repository should be enabled. $ sudo apt-get update Installing ZFS Filesystem Dependencies: You must install the libraries that the ZFS filesystem kernel module depends on before installing the ZFS filesystem on Debian 11. You can install all the libraries that the ZFS kernel module depends on with the following command: $ sudo apt install linux-headers-$(uname -r) linux-image-amd64 spl kmod To confirm the installation, press Y and then press <Enter>. All the required dependency libraries should be installed. Installing the ZFS Filesystem: Now, you can install the ZFS filesystem on Debian 11 with the following command: $ sudo apt install zfsutils-linux zfs-dkms zfs-zed To confirm the installation, press Y and then press <Enter>. The APT package manager will download all the required packages from the internet. It may take a while to complete. You will be asked to accept the OpenZFS license. To accept the OpenZFS license (used by the ZFS kernel module), select OK and press <Enter>. All the required packages will be installed one by one. It will take a while to complete. The ZFS kernel module is being installed and configured. It will take a few seconds to complete. All the ZFS systemd services are being started. It will take a few seconds to complete. At this point, the ZFS filesystem should be installed. Creating ZFS Pools: Once you’ve installed the ZFS filesystem on your computer, you can create a ZFS pool using one or more drives. You can list all the storage devices of your computer with the following command: $ sudo lsblk As you can see, all the storage devices of my computer are listed. In this article, I will use the drives sdb and sdc to create a ZFS pool. To create a new ZFS pool pool1 using the drives sdb and sdc, run the following command: $ sudo zpool create -f pool1 /dev/sdb /dev/sdc As you can see, a new ZFS pool pool1 has been created. $ sudo zpool list As you can see, the ZFS pool pool1 is ONLINE, and it uses the drives sdb and sdc. $ sudo zpool status After pool1 is created, the pool should be mounted in the /pool1/ (same directory name as the pool) directory, as shown in the screenshot below. $ df -h As you can see, a directory with the same name as the pool name pool1 is created in the root directory /. $ ls / Creating ZFS Datasets: ZFS datasets are like filesystem partitions. You can create a lot of ZFS datasets in a single ZFS pool. To create a new ZFS dataset ds1 in the pool pool1, run the following command: $ sudo zfs create pool1/ds1 To create another ZFS dataset, ds2 in the pool pool1, run the following command: $ sudo zfs create pool1/ds2 As you can see, 2 ZFS datasets, ds1 and ds2 are created in the pool pool1. $ sudo zfs list The ZFS datasets ds1 and ds2 should be mounted in their respective directories in the /pool1/ directory, as shown below. $ df -h As you can see, new directories for the datasets ds1 and ds2 are created in the /pool1/ directory. $ ls -l /pool1 Now, you can change the owner and the group of the pool1/ds1 dataset to your login username and primary group with the following command: $ sudo chown -Rfv $(whoami):$(whoami) /pool1/ds1 As you can see, I can copy files to the pool1/ds1 dataset. $ cp -v /etc/hosts /pool1/ds1 I have copied the /etc/hosts file to the pool1/ds1 dataset. As you can see in the screenshot below, the file is in the /pool1/ds1/ directory. $ tree /pool1 Setting ZFS Dataset Quotas: You can limit the amount of disk space that a ZFS dataset can use from a ZFS pool using quotas. For example, to allow the ZFS dataset ds1 to use only 10 GB of storage from the ZFS pool pool1, run the following command: $ sudo zfs set quota=10G pool1/ds1 As you can see, a quota of 10 GB is set for the pool1/ds1 dataset.$ sudo zfs get quota pool1/ds1 As you can see, once the 10 GB quota is set, the dataset ds1 can only use 10 GB of disk space out of 38.5 GB from the storage pool pool1. $ sudo zfs list Removing ZFS Datasets: If you don’t need a ZFS dataset, you can remove it. For example, let’s say you want to remove the dataset ds1 from the pool pool1. $ sudo zfs list You can remove the dataset ds1 from the pool pool1 with the following command: $ sudo zfs destroy pool1/ds1 As you can see, the dataset ds1 is removed from the pool pool1. $ sudo zfs list The ds1/ directory and all the files from the ds1/ directory should also be removed from the /pool1/ directory, as you can see in the screenshot below. Removing ZFS Pools: You can remove a ZFS pool as well. To remove the ZFS pool pool1, you can run the following command: $ sudo zpool destroy pool1 If the pool you want to remove has one or more datasets actively used by some users/programs, you may see an error while removing the pool. In that case, you will have to remove the pool with the -f option as follows: $ sudo zpool destroy -f pool1 As you can see, the pool pool1 is removed. $ sudo zpool list There’s another article on ZFS installation on CentOS 7 edition- the article link- https://tweenpath.net/install-zfs-centos-7/ Ref: https://linuxhint.com/install-zfs-debian/ Administrations Configurations (Linux) DebainDebain 10Debian 11ZFS
Will the installation portion of this work on the Raspberry Pi OS, as of 8/7/2023? For a Raspberry Pi under Linux kernel 5.15, you could install ZFS. Now, under kernel 6.X, you can’t. If the Raspberry Pi OS is downstream of Debian Bullseye, what’s going wrong?