Let us have a look together at the various file systems commonly used with Linux installations.
Although file systems are a very crucial component of an operating system most users don’t spend any thought on it. This is because it is usually configured automatically during installation. On Windows or Mac OS the user doesn’t even have a choice but with Linux, as we all know, there is always choice.
File systems are responsible on how data is stored and retrieved, so what qualities do we look for in a file system?
- Extra functionality
Reliability is obviously the most important point. You do not want your system to become unbootable when data gets corrupted. This is where file systems have improved a lot over the years. Modern file systems offer some type of journaling where writing operations are logged separately before they are executed. This technique protects the file system in case of data loss when a writing process is interrupted for any reason. After a reboot, the file systems checks the logs and purges any corrupted data. This way, even if the file being written is lost, the file system as a whole would not lose its integrity.
Different file systems have different journaling techniques which will affect the speed of disk operations. Ideally you want a file system that is both safe and fast at the same time.
Modern file systems can also provide additional functionality like data compression and snapshot creation. We will look at those in more detail further below.
Now that the basic principles are understood, let’s compare the available file systems for Linux today:
Current Generation File Systems
Ext4 is the most common file system in use for Linux distributions and for good reason. It is a robust and stable file system that matured out of the earlier Ext3. It was adopted by the Linux kernel in 2008 and has been in wide spread deployment ever since. Ext4 scores pretty high on both reliability and speed but as a pure file system it does not provide any of the additional functionality next generation file systems provide.
XFS is in the same generational league as Ext4. It is Red Hat Enterprise Linux’s default file system and as such intended for use in servers that handle huge amounts of data. Although fully supported by the Linux kernel there is no real advantage to recommend it over Ext4 for a Linux desktop user.
Next Generation File Systems
Btrfs is a next generation advanced file system that also combines logical volume management. This means it can span multiple devices. It is fully supported by the Linux kernel. OpenSUSE was the first to adopt it for desktop use and since release 33 last year, Fedora uses it by default as well.
In safety and reliability, Btrfs goes a step further than Ext4 because it constantly checksums all data on disk for errors. Remember that data can silently corrupt over time and Btrfs is able to detect that. If you had a RAID set-up for example, the corrupted data could be automatically repaired.
Btrfs uses the Copy-on-Write principle. This means that it doesn’t actually duplicate a file until it has been modified. This gives it the power to offer instant snapshots without taxing the system. So, if for example you take a system snapshot before performing a critical update Btrfs will only create copies of files affected during the update and not the whole system.
Btrfs also has a transparent compression capability that can be enabled on specific files or directories. This reduces disk space without a big impact on performance.
All The above qualities result in lower disk space usage and longer SSD live spans.
The snapshot feature is really an important one and allows the user to roll back the system or parts of it to a previous state of choice. This is not to be confused with a back-up solution as there is no second copy of any data.
The checksumming and compression operations do have some impact on performance. It is probably not very noticeable by a user though, and the advantages do outweigh the penalty.
ZFS is another next generation advanced file system that was originally developed by Sun Microsystems. Now part of Oracle, ZFS is made available under CDDL, a free and open-source software license that unfortunately is not compatible with GPL used by Linux. This means it cannot be included in the Linux kernel. However, Support can be added with third party modules. Today, ZFS support is available in Ubuntu and is fully supported by FreeBSD.
ZFS is also both a file system and a logical volume manager. It has full control over both physical drives and volumes. It can also detect data corruption as well as do snapshots. It uses the same Copy-on-Write principle as Btrfs.
I mention ZFS here because it is considered more mature and reliable than Btrfs. However, since it is not part of the Linux kernel, it is not wise to use it for a root installation. This is because future kernel updates might cause issues. The current most common way to take advantage of ZFS would be to keep the root installation in a Ext4 partition while setting up everything else with ZFS.
Phoronix did a file systems performance test last year that included Ext4 and Btrfs. On the whole, both file systems were comparable in speed so that should not really be a concern anymore. Reading through countless forums and blogs, I gathered Btrfs is still considered by many as less stable compared to Ext4 or ZFS. However, going forward Btrfs is probably the best modern option for Linux desktops and the default adoption by Fedora was a big step in that direction. If Oracle doesn’t change its mind on the ZFS license then Btrfs is probably the only way forward. Ext4 was originally only meant to be a stop-gap solution.
What is your experience with Btrfs and do you think it should become the default file system for Linux desktops? Shout out your thoughts in the comments below!
And Opportunity was supposed to work for 3 months. Ext4 does what it advertises to do, namely, reliably stores data. Why do IT people treat serious software as toys which, over time, lose their interest despite being perfectly fine in any regard?