How to install ZFS on Raspberry Pi
井民全, Jing, mqjing@gmail.com
1. Quick
lsblk #check all your block storage devices
# umount all partitions sudo umount /dev/sda?; sudo wipefs --all --force /dev/sda?; sudo wipefs --all --force /dev/sda sudo umount /dev/sdb?; sudo wipefs --all --force /dev/sdb?; sudo wipefs --all --force /dev/sdb sudo umount /dev/sdc?; sudo wipefs --all --force /dev/sdc?; sudo wipefs --all --force /dev/sdc sudo umount /dev/sdd?; sudo wipefs --all --force /dev/sdd?; sudo wipefs --all --force /dev/sdd lsblk # check no mount points
# install zfs on your raspberry sudo apt install raspberrypi-kernel-headers sudo apt install zfs-dkms zfsutils-linux # it takes time dmesg | grep ZFS # check zfs module zfs --version # check the zfs version
# create a RAIDZ1 zpool sudo zpool create myzfspool raidz1 sda sdb sdc sdd -f lsblk # check the partitions for each devices zpool status # check the pool status
# adding compression to the pool sudo zfs set compression=on myzfspool
# setup mount point sudo zfs set mountpoint=/mnt/myzfspool myzfspool df -h #make sure linux can see it
# create dataset on the pool sudo zfs create myzfspool/mydataset
|
2. Prepare the disks
At least 3 disks for setup ZFS. Here, I prepared 4 devices.
(Edit)
2.1. Check the disks
Command
e.g.
2.2. Unmount and erase filesystem
sudo umount /dev/sda?; sudo wipefs --all --force /dev/sda?; sudo wipefs --all --force /dev/sda sudo umount /dev/sdb?; sudo wipefs --all --force /dev/sdb?; sudo wipefs --all --force /dev/sdb sudo umount /dev/sdc?; sudo wipefs --all --force /dev/sdc?; sudo wipefs --all --force /dev/sdc sudo umount /dev/sdd?; sudo wipefs --all --force /dev/sdd?; sudo wipefs --all --force /dev/sdd
|
Verification
Check, no disks were mounted.
3. Install ZFS on your Raspberry PI
3.1. Procedure
Command
sudo apt install raspberrypi-kernel-headers sudo apt install zfs-dkms zfsutils-linux # it takes time. (30 mins) |
3.2. Verification
Test module
dmesg | grep ZFS
Check zfs version
zfs --version
4. Create a RAIDZ1 zpool
4.1. Procedure
Command
sudo zpool create myzfspool raidz1 sda sdb sdc sdd -f |
Result
Check the partition. Zfs makes two partitions foreach on your devices, one is the ZFS pool which takes almost the entire space, in our case sda1, sdb1, sdc1 and sdd1. The second partition is for ZFS maintenance.
4.2. Check status
zpool status
5. Adding compression to the pool
sudo zfs set compression=on myzfspool
6. Setup mount point
6.1. Procedure
Comand
sudo zfs set mountpoint=/mnt/myzfspool myzfspool |
e.g.
The dataset will be mounted on /mnt/myzfspool/mydataset.
6.2. Make sure Linux can see the pool.
df -h
7. Create dataset
Command
sudo zfs create myzfspool/mydataset |
e.g.
8. Destroy pool
Command
sudo zpool destroy myzfspool |
9. References
https://www.jeffgeerling.com/blog/2021/htgwa-create-zfs-raidz1-zpool-on-raspberry-pi
http://jenpeterson.net/zfs-blog/