哪个文件系统最适合你的 Linux 系统？
文件系统
![](/data/attachment/album/201601/19/010313rp6ppi9f9ruj6zpd.jpg)


文件系统: 它们不是世界上最激动人心的技术，但是仍然很重要。本文我们将细数那些流行的 Linux 文件系统 - 它们是什么，它们能够做什么，以及它们的目标用户。


### Ext4


![file-systems-ext4](/data/attachment/album/201601/19/010314c27i7timlwiw7bbf.jpg)


如果你曾经安装过 Linux，你可能在安装过程中看到过“Ext4”字样。用它有一个不错的理由: 它是当前每个可用的 Linux 发行版所选择的文件系统。当然，还有其他的一些选择，但是不可否认的是，Ext4（Extended 4）几乎是所有 Linux 用户都会选择的文件系统。


#### 它能做什么？


Ext4 拥有之前的文件系统（Ext2/Ext3）中你所期待的所有优点， 同时还带来了一些改进。还有很多内容可以发掘，这里列举出了 Ext4 为你带来的最好的部分：


* 日志型文件系统
* 日志校验
* 多重块文件分配
* 向后兼容 Ext2 && Ext3
* 持续的空闲空间预分配
* 改进的文件系统校验（相比于之前的版本）
* 当然，同时支持更大的文件


#### 目标用户


Ext4 针对那些寻找超级可靠的基础环境或者那些只需要能工作就行的用户。这个文件系统不会对你的系统做快照；它甚至没有最好的 SSD 支持，但是如果你不是太挑剔的话，你会觉得它也还不错。


### BtrFS


![file-systems-btrFS](/data/attachment/album/201601/19/010315el2qoddtqqo2lzme.png)


B 树（B-tree）文件系统 (也被当做是 butterFS，黄油文件系统) 是 Oracle 为 Linux 研发的一款文件系统。它是一个全新的文件系统，而且正处于主要开发阶段。Linux 社区认为其有时候使用上还有些不稳定。BtrFS 的核心原则是围绕着<ruby> 写时复制 <rp>  （ </rp> <rt>  copy-on-write </rt> <rp>  ） </rp></ruby>原则展开的。**写时复制**基本上意味着在写入数据完成前，这份数据的每一比特都有单独的一份副本。当数据写入完毕后，相当于它做了一份副本。


#### 它能做什么


除了支持写时复制之外，BtrFS 也能够胜任许多其他的事务 - 事实上，它可以不断列出各种特性。这里列举最值得一提的特性：支持只读快照、文件克隆、子卷、透明压缩、离线文件系统校验、从 ext3 & 4 原地转换到 BtrFS、在线碎片整理，还支持 RAID 0, RAID 1, RAID 5, RAID 6 和 RAID 10。


#### 目标用户


BtrFS 的开发者们许诺过，该文件系统是当前其他文件系统的新一代替代者。非常正确，虽然目前其处于开发中。它有很多面向高级用户的杀手级特性，对于基本用户也是这样（包括 SSD 上面的更佳性能）。这个文件系统针对那些想要从文件系统中获取更多(特性)，以及那些想尝试用写时复制机制做一些事情的用户。


### XFS


![file-systems-xfs](/data/attachment/album/201601/19/010316z2i7f3vxvne2y5en.jpg)


由 Silicon Graphics 公司创造开发，XFS 是一个高端文件系统，定位于速度和性能方面。处于对性能方面的专注，使得在并行 IO 方面，XFS 表现的尤其出色。XFS 文件系统能够处理数量庞大的数据，事实上某些 XFS 用户的数据接近300TB 以上。


#### 它能做什么


XFS 是一个经历良好测试的数据存储文件系统，它是为了高性能操作而诞生的。其特性包括：


* RAID 阵列的条带化分配
* 日志型文件系统
* 块大小可变
* 直接 I/O
* <ruby> 指定速率 <rp>  （ </rp> <rt>  guaranteed-rate </rt> <rp>  ） </rp></ruby> I/O
* 快照
* 在线碎片整理
* 在线调整文件系统大小


#### 目标用户


XFS 针对那些想要一个坚如磐石的文件系统方案的用户。它始于1993年，并且随着时间的变迁它变得越来越好。如果你有一台家庭服务器，而且你苦恼于如何部署存储环境，那么可以考虑下 XFS。它拥有的众多特性（比如快照）能够有助于你的文件存储系统。尽管如此，它不局限于服务器端。如果你是一个相对高级一点的用户或者你对 BtrFS 所承诺的很多特性感兴趣的话，尝试一下 XFS。它实现了很多与 BtrFS 相似的特性，并且没有稳定性方面的问题。


### Reiser4


![file-system-riser4](/data/attachment/album/201601/19/010318n474rqn7ghtfwf4l.gif)


Reiser4 是 ReiserFS 的继任者，由 Namesys 公司创造研发。它的诞生可以追溯到 Linspire 项目和 DARPA。它与众不同的地方在于众多的事务模式。并不止于单一的一种写入数据的方式；取而代之的是，有很多方式（来写入）。


#### 它能做什么


Reiser4 拥有着使用多种不同事务模式的独特能力。它能够使用写时复制模式 (像 BtrFS)，<ruby> 任意位置写入 <rp>  （ </rp> <rt>  write-anywhere </rt> <rp>  ） </rp></ruby>，日志，以及混合事务模式。它在 ReiserFS 的基础上做了许多的改进，包括更好的基于漫游日志的文件系统日志，对较小文件的支持更好，以及更快速的目录处理。Reiser4 提供了许多功能特性。还有更多的特性可以探讨，不过简单来讲，相比于 ReiserFS 它不但做了非常大的改进，而且增加了众多特性。


#### 目标用户


Resier4 适合那些想要将一个文件系统应用到多种场景下的用户。可能你想在一台机器上使用写时复制机制，在另一台机器上使用任意位置写入机制，还会在另一台机器上使用混合事务，而你又不希望使用多种不同类型的文件系统来完成这项任务。Reiser4 是适合这种情况的完美方案。


### 结论


Linux 上有许多可用的文件系统。每个文件系统都有其特定的用途，以便于特定用户解决不同的问题。本文的焦点集中在 Linux 平台上文件系统的主流选择。毫无疑问，其它的场景下还有一些别的选择。


你在 Linux 上最喜欢的文件系统是什么？在下面的评论区告诉我们吧！




---


 


via: <https://www.maketecheasier.com/best-file-system-linux/>


作者：[Derrik Diener](https://www.maketecheasier.com/author/derrikdiener/) 译者：[icecoobe](https://github.com/icecoobe) 校对：[wxy](https://github.com/wxy)


本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译，[Linux中国](https://linux.cn/) 荣誉推出


OK
![Best Linux Filesystems 2020 Featured V2](https://www.maketecheasier.com/assets/uploads/2020/04/best-linux-filesystems-2020-featured-v2.jpg)

When formatting a hard disk to install your Linux system, you have to decide on the best Linux filesystem to use. In 2021, the most popular option is EXT4. Is it the best one, though, and if you have alternatives, should you choose them? Let’s see the (possible) options.

**Also read:** [Check and Repair Your Filesystem With fsck [Linux]](https://www.maketecheasier.com/check-repair-filesystem-fsck-linux/)

## EXT4

The “Fourth Extended Filesystem” is fully backward-compatible with EXT2 and EXT3 and is considered the standard for most Linux distributions, remaining as popular as its predecessors.

![Best Linux Filesystems 2020 Ext4 Best Linux Filesystems 2020 Ext4](https://www.maketecheasier.com/assets/uploads/2020/04/best-linux-filesystems-2020-ext4.jpg)

It is one of the safest and most stable available options today since it supports [journaling](https://www.maketecheasier.com/journaling-in-file-system/), preventing (as much as possible) the loss of data after a system crash or loss of power.

Two of its most important features are “extents” and “delayed allocation,” which smartly manage how the data is written on the storage medium to improve performance and reduce fragmentation.

## BtrFS

The “b-tree file system” was initially designed by Oracle and has kept increasing in popularity, to the point many consider it the true successor to the EXT dynasty.

![Best Linux Filesystems 2020 Btrfs Best Linux Filesystems 2020 Btrfs](https://www.maketecheasier.com/assets/uploads/2020/04/best-linux-filesystems-2020-btrfs.jpg)

Btrfs comes with advanced features, such as automatic defragmentation and transparent compression. It follows a copy-on-write approach, saving new iterations of data and metadata instead of affecting the existing ones (“shadowing”). This also allows for snapshots of different states of the filesystem as well as easy replication, migration, and incremental backups. Online and offline filesystem checks further reduce the possibility of data loss.

BtrFS natively supports RAID, but it doesn’t follow the approach of typical software RAID striping or hardware block mirroring. Instead, it ensures that each block on one device has a copy on another and keeps CRCs for all data. Thus, in case of a failure, it can pull information from backups and checksums to reconstruct corrupted or missing data.

It’s worth noting that BtrFS is also “SSD-friendly” since it automatically disables its features that are useful for mechanical HDDs but could wear out SSDs.

## XFS

XFS was created by Silicon Graphics almost three decades ago for their graphics workstations specializing in rendering 3D graphics.

![Best Linux Filesystems 2020 Xfs Best Linux Filesystems 2020 Xfs](https://www.maketecheasier.com/assets/uploads/2020/04/best-linux-filesystems-2020-xfs.jpg)

That’s why XFS remains one of the best options for systems that are constantly reading and writing data. Thanks to the use of “allocation groups” – parts of the filesystem that contain their own [inodes](https://www.maketecheasier.com/how-do-linux-inodes-work/) and free space – it’s possible for multiple threads to read and write data at the same time in parallel. Support for delayed allocation, dynamically allocated inodes, and advanced read-ahead algorithms help it achieve excellent performance, especially on large-scale storage pools up to hundreds of TB in size.

Its support for journaling is restricted, though, compared to more modern alternatives, and it is arguably more prone to data loss. It also doesn’t scale down well for more typical day-to-day and mostly single-threaded scenarios, like when deleting a bunch of photos from your “Pictures” folder. In other words, it’s great if you’re setting up your own datacenter but maybe not for typical personal use.

## F2FS

One of the (relatively) newer filesystems, “Flash-Friendly File System” is one of the best options for use with flash-based storage.

![Best Linux Filesystems 2020 F2fs Best Linux Filesystems 2020 F2fs](https://www.maketecheasier.com/assets/uploads/2020/04/best-linux-filesystems-2020-f2fs.jpg)

Initially created for that purpose by Samsung, F2FS splits the storage medium into smaller parts that contain zones that also include smaller parts, and so on, and tries to use many of them instead of reusing the same ones. Combined with its support for TRIM/FITRIM, this makes it friendlier to flash-based media that comes with a finite number of writes.

There’s no point in deep-diving into F2FS’s features since it doesn’t excel in anything compared to all alternatives as far as speed or data security goes, nor in using it with typical media, where every other filesystem would come with a better feature-set. The story changes if talking about flash-based storage, though, for which it was explicitly created.

## OpenZFS/ZFS

OpenZFS is a fork of the Zettabyte File System (ZFS) that initially appeared on Sun’s Solaris. Up to 2010, ZFS could be used on Linux primarily through FUSE, due to licensing issues. It was after 2010 that its development started opening up, and in 2016 Ubuntu supported, by default, its open-source version. Since then, when people refer to “ZFS,” they’re usually talking about its open variant instead of Solaris ZFS – that also keeps evolving but on a parallel path.

![Best Linux Filesystems 2020 Openzfs Best Linux Filesystems 2020 Openzfs](https://www.maketecheasier.com/assets/uploads/2020/04/best-linux-filesystems-2020-openzfs.jpg)

ZFS differs from all alternatives in that it combines the filesystem with a volume manager. Because of that, it doesn’t just manage files and directories but also the physical media on which they reside. Thanks to this, every storage device can be assigned to a pool that is treated as a single resource. If you’re ever out of space, you can add new storage to this pool to expand it, letting ZFS take care of the details.

By managing the media itself, ZFS also excels in its support for RAID. You can set up RAID arrays of most types (RAID 0, 2, 5, etc.) but also use its approach of “RAIDZ.” Unlike typical RAID arrays, RAIDZ uses variable width stripes between the drives it includes, increasing its tolerance on data loss after a power failure.

ZFS also follows a copy-on-write approach, where instead of modifying existing data, it only saves the changes (“deltas”) between the old and new versions. This allows for transparent, smart storage of multiple copies of data, without taking up a lot of space, that can work as backups or snapshots. The user can return to previous states of the filesystem, reverting changes, or do the opposite: pull all changes into clones of existing data.

Those are some of the features that help it nearly eliminate any possibility of data loss – at least, in theory.

## JFS

The Journaling File System by IBM was one of the first filesystems that supported journaling, leading to reduced chances of data loss. It uses extents like many other modern alternatives and allocation groups like XFS, aiming to offer high read/write performance.

![Best Linux Filesystems 2020 Jfs Best Linux Filesystems 2020 Jfs](https://www.maketecheasier.com/assets/uploads/2020/04/best-linux-filesystems-2020-jfs.jpg)

By not prioritizing a single feature, it’s a great all-arounder under different workloads for different needs. Unfortunately, this also means that it doesn’t excel in anything. Plus, it has some problems that many people would consider a negative when choosing a filesystem for their storage. For example, it can delay updating its journal indefinitely, increasing the chances of data loss and almost nullifying the fact that it’s a journaling file system. It’s better at parallel writes that are of most use to servers and large databases but performs worse than EXT4 in more popular desktop usage scenarios.

Those are probably the reasons why it’s not as popular as other filesystems, which can either perform faster or be better shielded against data loss.

## Which Should You Use?

There’s a reason EXT4 is the default choice for most Linux distributions. It’s tried, tested, stable, performs great, and is widely supported. If you are looking for stability, EXT4 is the best Linux filesystem for you.

If you aren’t afraid of having to deal with a somewhat less mature ecosystem, though, BtrFS may be the better option for you.

For server use where you want to eliminate almost entirely any possibility of data loss and stability is the name of the game, you may want to look into ZFS. To really take advantage of it, though, prepare for a lot of reading. Thankfully, [we can help with its initial setup](https://www.maketecheasier.com/use-zfs-filesystem-ubuntu-linux/).

For flash media, F2FS is the best option by default.

Whichever file system you choose, remember to [fully erase your HDD beforehand](https://www.maketecheasier.com/low-level-format-zero-fill-hard-disk/) if you want to render its existing content almost unrecoverable.

Our latest tutorials delivered straight to your inbox