ZFS Snapshot Test

When the new Ubuntu 22.04 system was released at the end of April, curiosity led me to choose the ZFS file system. I had heard of ZFS a long time ago. Later, when I installed the updated Linux kernel DEB package myself, I found that the system would not boot. I was a little panicked at the time because the ZFS file system was not recognized. I had no choice but to search online for information. It turned out that due to open source license issues, the kernel does not include the corresponding ZFS processing module like ext4. If there is a dispute, Oracle's lawyers will send a letter.

Without further ado, since Ubuntu officially provides the corresponding file system options, and BSD and other systems also use the ZFS file system, it must have its unique features. For the average person, ZFS's snapshot feature is definitely practical. The testing process is as follows.

1. Let's take a look at the basics first

 1➜ mephisto.cc git:(main) zpool list
 2NAME SIZE ALLOC FREE CKPOINT EXPANDSZ FRAG CAP DEDUP HEALTH ALTROOT
 3bpool 1.88G 244M 1.64G - - 1% 12% 1.00x ONLINE -
 4rpool 472G 23.1G 449G - - 3% 4% 1.00x ONLINE -
 5➜ mephisto.cc git:(main) zpool status
 6pool: bpool
 7state: ONLINE
 8config: 
 9
10NAME STATE READ WRITE CKSUM 
11bpool ONLINE 0 0 0 
125caca429-191c-f046-b1dc-3167ba2d43fa ONLINE 0 0 0 
13
14errors: No known data errors 
15
16pool: rpool 
17state: ONLINE 
18config: 
19
20NAME STATE READ WRITE CKSUM 
21rpool ONLINE 0 0 0 
221c85b674-1367-5d40-8553-2ba3439be776 ONLINE 0 0 0 
23
24errors: No known data errors 
25➜ mephisto.cc git:(main) zfs --version 
26zfs-2.1.2-1ubuntu3 
27zfs-kmod-2.1.2-1ubuntu3 
28➜ mephisto.cc git:(main) zfs list NAME USED AVAIL REFER MOUNTPOINT 
29bpool 244M 1.51G 96K /boot 
30bpool/BOOT 243M 1.51G 96K none 
31bpool/BOOT/ubuntu_o54gp2 243M 1.51G 243M /boot 
32rpool 23.1G 434G 96K / 
33rpool/ROOT 7.42G 434G 96K none 
34rpool/ROOT/ubuntu_o54gp2 7.42G 434G 5.74G / 
35rpool/ROOT/ubuntu_o54gp2/srv 96K 434G 96K /srv 
36rpool/ROOT/ubuntu_o54gp2/usr 140M 434G 96K /usr rpool/ROOT/ubuntu_o54gp2/usr/local 139M 434G 139M /usr/local 
37rpool/ROOT/ubuntu_o54gp2/var 1.55G 434G 96K /var 
38rpool/ROOT/ubuntu_o54gp2/var/games 96K 434G 96K /var/games 
39rpool/ROOT/ubuntu_o54gp2/var/lib 1.51G 434G 1.38G /var/lib 
40rpool/ROOT/ubuntu_o54gp2/var/lib/AccountsService 112K 434G 112K /var/lib/AccountsService 
41rpool/ROOT/ubuntu_o54gp2/var/lib/NetworkManager 144K 434G 144K /var/lib/NetworkManager 
42rpool/ROOT/ubuntu_o54gp2/var/lib/apt 84.4M 434G 84.4M /var/lib/apt 
43rpool/ROOT/ubuntu_o54gp2/var/lib/dpkg 46.3M 434G 46.3M /var/lib/dpkg 
44rpool/ROOT/ubuntu_o54gp2/var/log 41.3M 434G 41.3M /var/log 
45rpool/ROOT/ubuntu_o54gp2/var/mail 96K 434G 96K /var/mail 
46rpool/ROOT/ubuntu_o54gp2/var/snap 1M 434G 1M /var/snap rpool/ROOT/ubuntu_o54gp2/var/spool 116K 434G 116K /var/spool 
47rpool/ROOT/ubuntu_o54gp2/var/www 96K 434G 96K /var/www 
48rpool/USERDATA 15.7G 434G 96K / 
49rpool/USERDATA/mephisto_fmrvh5 15.7G 434G 15.7G /home/mephisto 
50rpool/USERDATA/root_fmrvh5 1.03M 434G 1.03M /root

2. Confirm that the test file 404.jpg exists

1➜ mephisto.cc git:(main) ls -al ~/Pictures/iPhone 
2total 47 drwxrwxrwx 2 mephisto mephisto 3 May 29 12:53 .
3drwxrwxrwx 4 mephisto mephisto 7 May 26 14:49 ..
4-rw-rw-r-- 1 mephisto mephisto 43408 May 29 12:53 404.jpg

3. Create a snapshot, then delete the file. Creating a snapshot is very fast, in seconds.

1➜ mephisto.cc git:(main) sudo zfs snapshot rpool/USERDATA/mephisto_fmrvh5@9527
2[sudo] password for mephisto:
3➜ mephisto.cc git:(main) rm ~/Pictures/iPhone/404.jpg
4➜ mephisto.cc git:(main) ls ~/Pictures/iPhone/404.jpg
5ls: cannot access '/home/mephisto/Pictures/iPhone/404.jpg': No such file or directory

4. Roll back the snapshot to salvage the deleted 404.jpg. The rollback was actually quite fast, given the small number of changes.

1➜ mephisto.cc git:(main) sudo zfs rollback rpool/USERDATA/mephisto_fmrvh5@9527
2➜ mephisto.cc git:(main) ls ~/Pictures/iPhone/404.jpg
3/home/mephisto/Pictures/iPhone/404.jpg
4➜ mephisto.cc git:(main) echo "nubility"
5nubility

5. Check the current snapshots. 9527 is the one we just created.

1➜ mephisto.cc git:(main) zfs list -t snapshot
2NAME USED AVAIL REFER MOUNTPOINT
3rpool/USERDATA/mephisto_fmrvh5@9527 3.17M - 15.7G -

6. Create another snapshot, 9528. We won't repeat the test here; the file system is still reliable.

1➜ mephisto.cc git:(main) sudo zfs snapshot rpool/USERDATA/mephisto_fmrvh5@9528
2[sudo] password for mephisto:
3➜ mephisto.cc git:(main) ✗ zfs list -t snapshot
4NAME USED AVAIL REFER MOUNTPOINT
5rpool/USERDATA/mephisto_fmrvh5@9527 3.98M - 15.7G -
6rpool/USERDATA/mephisto_fmrvh5@9528 0B - 15.7G -

Also, ZFS storage pools (zpools) are easy to use. They don't require a separate volume management system to manage multiple devices. They can be used when creating a NAS. Since there are no additional disks for testing, users with the necessary resources can refer to the relevant OpenZFS or Oracle documentation for instructions.

Lastmod: Wednesday, July 30, 2025

See Also:

Translations: