SYSTEM NOTICE

Auto translation by AI. Be sure, accuracy, nuances and authorial intent may not be fully reflected.

Let's use ZFS on Ubuntu!

Previously, in this article, I wrote

"There is no benefit to using ZFS on a desktop,"

but after looking into it again, I realized I had a major misunderstanding. It was an inappropriate statement that disregarded the efforts of the OpenZFS team developers who are pouring immense effort into ZFS development for Linux.

I am very sorry.

In this article, I would like to clearly correct that point.


Common Misconception 1: "ZFS cannot be integrated into the kernel"

Articles introducing the use of ZFS on Linux almost always contain the following statement:

"Because ZFS is under the CDDL license rather than GPL, it cannot be integrated into the kernel itself."

The Internet

This is a misunderstanding, or at least an expression that is likely to induce one. So many people have written this on the web that even AIs answer in that way.

However, this is not accurate.

In the first place, OpenZFS is designed on the premise that it runs independently as an external kernel module. Thanks to that, ZFS can be used on various OSs. Even in FreeBSD, it is implemented as a kmod (kernel module).

The difference from btrfs and others is merely whether it is included in the kernel's own source tarball. And being separated from the kernel actually has its own advantages.

That is, it serves as "the strongest breakwater to protect ZFS's robust codebase from the storm of intense internal changes in the Linux kernel." Following the kernel might actually be more disadvantageous for btrfs, which is integrated into the kernel.

The superiority of ARC (Adaptive Replacement Cache)

ZFS has a very excellent cache system called ARC (Adaptive Replacement Cache) built into the module. The CoW (Copy on Write) method has weaknesses such as

  • being prone to fragmentation

  • being weak at random access for small files

but ARC compensates for these weaknesses with its excellent algorithm and mechanism.

On the other hand, since btrfs reuses the kernel-specific Page Cache optimized for traditional systems like ext4, it has not been able to overcome the weaknesses of CoW. I was able to clearly confirm this in my previous experimental article.

It is the distribution (OS) side, not the kernel side, that supports ZFS. Unfortunately, there doesn't seem to be any distribution that adopts ZFS as the default file system at this moment, but Ubuntu and Debian allow you to select ZFS during installation. If you use these distributions, you won't face the commonly cited issue of 'difficulty in managing kernel and OpenZFS versions,' and since the distribution side takes proper care of it, I believe you can use it with peace of mind.

There are almost no cases where you keep the distribution as is but build and use the latest kernel yourself (though that used to be the norm in the past). If that is the case, the version consistency between the kernel and OpenZFS will rarely be an issue. Even if there is a consistency issue, it is only to the extent that recompilation is required due to kernel ABI changes.


Common Misconception ②: 'On Linux, the coordination between ARC and the kernel memory is weak'

Another misconception is,

'Because it is integrated with the OS on FreeBSD, ARC and the kernel can work together to use memory effectively, but on Linux, that coordination is weak'

The Internet

is what people say. For a long time, I also believed this, but this was also a big mistake.

This 'coordination' refers to the behavior where ARC secures as much free memory as possible as a cache, and if main memory runs low, it releases the secured memory to resolve the shortage. I was convinced that FreeBSD was superior, but I actually learned that
Linux can be adjusted more finely.

On Linux, by making full use of internal APIs such as shrinker and mmu_notifier, it is said to be a mechanism that 'accurately grasps the free memory situation even better than Page Cache, despite being an external module.' Quite a few Linux kernel developers participate in OpenZFS, and they have successfully incorporated these features into the kernel side as well.

The mainstream of OpenZFS is Linux, and ZFS is Linux-native. It is by no means an outsider.


Summary

The short-sighted idea of 'I won't use ZFS because it's not incorporated into the kernel' is far too wasteful. ZFS is a very attractive file system. There are people who say harsh things like 'If you want to use ZFS, go to another OS,' but I would like them to reconsider.

Knowing this, I wanted to use ZFS in a production environment. My current super-sub machine has Ubuntu 24.04 LTS installed, and it has a 2x SSD configuration for the system disk and data disk. Among these, I changed only the data disk to ZFS.

Next time, I would like to write an article about the actual process of changing the data disk from ext4 to ZFS. Stay tuned!


いいなと思ったら応援しよう!