ZFS Training Exercises
Table of Contents
In 2015 I ran a training session on BTRFS and ZFS. Here are the notes for ZFS updated for the latest versions of everything when running on KVM. You can do all the same exercises on a non virtual machine, but it’s safest not to do this on a machine with important data. For the KVM setup I use /dev/vdc, /dev/vdd, and /dev/vde are the devices for test data.
For running ZFS on Linux in serious use I recommend having more than 4G of RAM in the system or VM that’s doing it to prevent kernel OOM issues. You should be able to complete this training exercise on a 64bit VM with 2G of RAM. To do this on Debian/Buster just replace the references to “bullseye” with “buster” in the APT configuration.
- Installing zfsonlinux on Debian/Bullseye
- Note that /etc/apt/sources.list has the following lines (the “contrib” is very important):
deb http://mirror.internode.on.net/pub/debian/ bullseye-updates contrib main deb http://deb.debian.org/debian bullseye-backports contrib main
- Run the following commands:
apt install linux-headers-amd64
apt install -t bullseye-backports dkms spl-dkms zfs-dkms
apt install -t bullseye-backports zfsutils-linux
The apt command installing spl-dkms takes ages, 4 minutes real time and 9 minutes CPU time on my last test on a 4 core VM. It will take much longer if several people are doing it at the same time.
- Note that /etc/apt/sources.list has the following lines (the “contrib” is very important):
- Making the filesystem
- Create the pool:
zpool create -o ashift=12 nyancat raidz /dev/vdc /dev/vdd /dev/vde
NB You need to add a “-f” to overwrite the BTRFS filesystem - Make some default filesystem settings:
zfs set devices=off nyancat
zfs set atime=off nyancat
zfs set setuid=off nyancat
zfs set compression=on nyancat - Get information on the pool:
zfs get all nyancat|less
zpool list
zpool status - Make a filesystem:
zfs create nyancat/friday
df -h - See if there are any errors, shouldn’t be any (yet):
zpool scrub nyancat
zpool status - Copy some files to the filesystem:
cp -r /usr /nyancat/friday - Scrub the filesystem:
zpool scrub nyancat
zpool status
- Create the pool:
-
- Online corruption
- Corrupt the filesystem:
dd if=/dev/zero of=/dev/vdd bs=1024k count=2000 seek=50 - Scrub again, should give a warning about errors:
zpool scrub nyancat
zpool status - Verify that the data is intact:
diff -ru /usr /nyancat/friday/usr - Corrupt it again:
dd if=/dev/zero of=/dev/vdd bs=1024k count=2000 seek=50 - Unmount the ZFS filesystems and export (stop using) the zpool:
zfs umount -a
zpool export -a
zpool status - “Import” the pool, mount the filesystems, and note that the checksum error count is back to zero (it counts since the last mount not for all time – unlike BTRFS):
zpool import -a
zfs mount -a
zpool status - Check that the data is still intact and look for increases in the error count:
zpool status
diff -ru /usr /nyancat/friday/usr
zpool status
- Corrupt the filesystem:
-
- Offline corruption
- Umount the filesystem and corrupt the start of one device:
zfs umount -a
zpool export -a
dd if=/dev/zero of=/dev/vdd bs=1024k count=200 - Try mounting it again which will work even though one block device is unavailable:
zpool import -a
zpool status - Replace the missing device, look for the device name in the “zpool status” output to replace “123456789” in the following sample command:
zpool replace -f nyancat 123456789 /dev/vdd - Check that everything is ok:
zpool status
diff -ru /usr /nyancat/friday/usr
- Umount the filesystem and corrupt the start of one device:
You may also like
SE Linux Policy Writing Training
August 6, 2022
Postfix Training
February 28, 2022
BTRFS Training Exercises
January 31, 2022
Related posts:
Archives
- December 2025
- October 2025
- September 2025
- May 2024
- September 2023
- October 2022
- August 2022
- February 2022
- January 2022
- August 2021
- September 2020
- May 2020
- November 2019
- January 2019
- July 2017
- April 2016
- March 2015
- January 2015
- July 2014
- October 2012
- August 2012
- February 2012
- August 2011
- January 2011
- June 2010
- May 2010
- April 2010
- October 2009
- January 2009
- December 2008
- July 2008
- June 2008
- May 2008
- April 2008
- January 2008
- December 2007
- November 2007
Calendar
| M | T | W | T | F | S | S |
|---|---|---|---|---|---|---|
| 1 | ||||||
| 2 | 3 | 4 | 5 | 6 | 7 | 8 |
| 9 | 10 | 11 | 12 | 13 | 14 | 15 |
| 16 | 17 | 18 | 19 | 20 | 21 | 22 |
| 23 | 24 | 25 | 26 | 27 | 28 | 29 |
| 30 | 31 | |||||
Leave a Reply
You must be logged in to post a comment.