Do you want to know about Btrfs vs Ext4? If you are consider how to choose between them, you can read this post, in which MiniTool Partition Wizard tells you the advantages of each of them.
Introduction to Ext4 and Btrfs
Ext4, developed by team led by Theodore Ts'o, is a journaling file system under Linux. It is a successor to Ext3 file system. In 2008, the stable version of Ext4 was officially announced and became the official recommended default file system for Linux.
- Journaling file system: When changes are made in file system, relevant information will be written into an area called a log, and then the changes will be written to the main file system later. The advantage is that this file system can recover data easily after file system failure (such as a kernel crash or a sudden power failure).
Btrfs (B-tree file system, usually pronounced Butter FS, Better FS or B-tree FS), is a Linux file system that supports copy-on-write (COW). The stable version was released in 2014 and its goal is to replace Linux's current Ext3 file system.
- Copy-on-write: If multiple callers request the same data at the same time, they will obtain the same pointer to the same resource. If a caller wants to modify the content of the resource, the system will make a private copy to the caller. But the original resources seen by other callers remain unchanged.
This post introduces Linux file system and Linux directory structure. It can help you understand Linux better.
Btrfs vs Ext4
Both Btrfs and Ext4 have their own advantages. The Ext4 file system is a very old file system and it has been used on the Linux operating system for a long, long time. Because of that, the Ext4 file system is very stable.
However, we also must admit that Btrfs has many advantages that Ext4 doesn't have, for example:
- Partition Size: Ext4 supports partition size up to 1 EiB, while Btrfs supports partition size up to 16 EiB.
- File Size: Ext4 supports file size up to 16 TiB, while Btrfs supports file size up to 16 EiB.
- Checksum: Ext4 does not keep checksum of the data while Btrfs keeps crc32c checksum of the data. So, in case of any data corruption, the Btrfs file system can detect it and recover the corrupted file.
- Snapshots: The Btrfs can take snapshots of the file system. If you take a snapshot before trying out anything risky, when things do not go as planned, you can go back to an early state where everything worked.
- Deduplication: Btrfs supports deduplication on the file system-level. With this technology, you can save disk spaces by eliminating/removing duplicate copies of data from the file system and keeping only one copy of data (unique data) on the file system.
- Multi-Device Support: Btrfs supports multiple devices and has built-in logical volume manager (LVM) and RAID support. Therefore, a single Btrfs file system can span over multiple disks and partitions.
- File System Compression: Btrfs has built-in file system-level compression support. It can compress a single directory or a single file or the entire file system to save disk space.
- Block Sub-Allocation: When a file system stores a file, the file is broken into blocks for storing. However, the last block (called tail block) of the file does not occupy the entire block. To save space, block sub-allocation is used, to make the file system store parts of another file block to the tail block. Btrfs supports this technology.
Of course, Btrfs also has some disadvantages like:
- File System Encryption: Ext4 has experimental support for file system-level encryption, while Btrfs does not have any support for file system-level encryption.
- Space Usage: Btrfs allows you to take snapshots, but these snapshots take space. Initially, the snapshot takes little space. But as files are updated, the amount of space used begins to grow.
Btrfs is better than Ext4 indeed in some aspects, but if you are not familiar with this file system, Ext4 is recommended.