XFS or ext4 on external hard drive

I have an external hard drive on which i want to make a backup of my files.

Which file system between XFS and ext4 will be the fastest to write data on the hard drive?


Solution 1:

Let me throw my practical answer into the ring: Go with ext4. You will see no read/write differences vs. XFS except in extreme edge cases (mass deletions of hundreds of thousands of small files, for example).

You will also find more community support for ext4 at places like AskUbuntu, simply because it is so widely used.

One notable disadvantage of XFS is that it cannot be shrunk (decrease partition size), so you would have to backup, repartition/reformat, restore if you ever wanted to decrease your XFS partition size.

Solution 2:

ext4

That was my recommendation in 2012 and it is the recommended FS in 2017. This file system is very mature with support for encryption (recent Kernel needed as of 2017) and is fast enough for most workload on an external hard drive (and even external SSDs), it is also a very safe choice with respect to data safety. That's an important factor especially when you have an external hard disk, it is not as protected as an internal one.

On a laptop for instance, even if the electricity is plugged out, you still have a battery, so the internal had drive is rather safe. However, an external plugged hard disk can be prone to disconnection, e.g.: you get up with your laptop while forgeting about the attached drive.

XFS

Provides good performance for many enterprise work load, and probably some desktop ones too. Probably those edge cases are not visible on an external USB hard drive, could be visible with external SSDs on a USB3.1 interface. There was a higher risk than upon disconnection or loss of power than some of the files are truncated to 0 with XFS, for many years this should not be an issue. XFS is now a robust and fast file system even in the event of power-loss.

You can implement encryption with XFS if you use LUKS for example. But I'm not aware of a native support within XFS for encryption.

BTRFS

In 2012 I stated "In 1 or 2 years I would recommend that file system as it supports checksum for data and journal". In 2017 I can say that this file system is pretty robust unless you want to use its RAID 5-6 support (for it you would need a very recent Kernel, so better wait for Ubuntu 18.04 LTS). On an external hard disk, which is more exposed than an internal one, BTRFS would be a very strong solution with its native checksuming of data and metadata. However if you only have one external hard drive, it will be only able to detect corrupted data but won't be able to repair them unless you set it up to store 2 copies of each data or metadata on the drive. In case of disk loss, you lose of course everything, so it is not RAID1. But if you have a corrupted sector, BTRFS could recover it if it has a copy. BTRFS supports snapshots, which could be a nice addition for a backup system.

It is not my recommended file system because it has a few peculiarities like understanding properly the disk usage and free space problems (especially if you use the compression option). In my use of BTRFS, I've also encountered a few times error with no space left on device which requires some balancing, etc. So it is not yet usable by a novice users.

Solution 3:

The answer depends on your precise requirements.

ext4 has become the default filesystem for several of the popular Linux distributions including Ubuntu, Fedora and openSUSE. ext4 features several improvements over its predecessor, amongst which include support for files upto 16 tebibytes ( 1 tebibytes equals 1,024 gibibyes , with 1gibibyte equal to 1.074 gigabytes) and a maximum volume size of upto 1 Exbibyte. It is backward compatible with ext3 and ext2, making it possible to mount ext3 and ext2 as ext4. This will slightly improve performance, because certain new features of ext4 can also be used with ext3 and ext2, such as the new block allocation algorithm.

XFS is a highly scalable, high-performance file system which was originally designed at Silicon Graphics, Inc. It was created to support extremely large filesystems. XFS supports a maximum file system size of 8 exbibytes minus one (i.e. 263-1 bytes), though this is subject to block limits imposed by the host operating system. 32-bit Linux systems limit both file and file system size to 16 tebibytes.

There is a lot of information out there on this subject, but I would Start Here and try to explore if you want to take this further.

I hope this helps.

Sources:

- http://techie-buzz.com/foss/google-implements-ext4.html

- http://docs.redhat.com/docs/en-US/Red_Hat_Enterprise_Linux/6/html/6.0_Release_Notes/filesystems.html