8

About to install Ubuntu 16.04 on a Samsung M.2 harddrive. (using a USB-drive)

Which file system should I use?

  • Fat32
  • ext4
  • ext3
  • ext2
  • NTFS
  • another one I haven't mentioned?

My harddrive is:

1TB SAMSUNG SM961 M.2, PCIe NVMe (up to 3200MB/R, 1800MB/W)

If they all work, which one is the fastest?

Any tips/pitfalls for a frightened noob :)

7
  • 2
    Why do you assume the filesystem matters in regard to speed? Oh and why do you list FAT and NTFS. Those are windows related and not Linux so can't be used to install Ubuntu.
    – Rinzwind
    Sep 1, 2017 at 7:07
  • 4
    Out of your candidates, FAT and NTFS can be eliminated as Ubuntu can not be installed on any of them, leaving only the ext* family. Out of those, ext4 is of course the newest and most advanced, which is also the default. Unless you're looking forward to trouble, better stick with ext4 than experimenting with some less well supported file systems for maybe a minimal performance gain. Related: superuser.com/q/274172/418736
    – Byte Commander
    Sep 1, 2017 at 7:13
  • 2
    Should I format the ubuntu installation-usb with ext4 (I'm using windows 10 to make it?)
    – Conor
    Sep 1, 2017 at 7:26
  • 2
    You format the installation-usb with fat32. Take a look here: tutorials.ubuntu.com/tutorial/…
    – mondjunge
    Sep 1, 2017 at 7:47
  • 1
    If you are a "noob" then follow the suggestions given by the installation program!. Only derivate from this when you know what you are doing. Sep 1, 2017 at 8:53

2 Answers 2

10

Quite simple. You use the filesystem which is best suited for your OS. For most Linux Distributions, Ubuntu included, this is:

ext4

NTFS and fat32 are not suited for Unix/Linux systems, since they are lacking features Linux needs. They might be a good choice for data partitions that need to be accessible from Windows systems. Be aware that fat32 cannot store files larger than 4GB, but it is the most compatible choice. Even old DOS can read/write fat32.

ext2 and ext3 are basically predecessors of ext4.

By the way, speed is not really a matter of filesystem. Harddrive and Bus (Connection, USB-Port) determine the speed of your file operations.

5
  • 5
    Only thing worth noting but was not part of the question: in case someone feels the need to create snapshots: btrfs is an option too.
    – Rinzwind
    Sep 1, 2017 at 8:24
  • 1
    Ext* can be accessed in Windows with additional drivers (example). Obviously not the best solution if you want to be able to plug your drive in anywhere and have it just work, but it might be fine for some users' needs (e.g. dual boot). Sep 1, 2017 at 15:15
  • 5
    Actually there are often very substantial differences in speed between filesystems for some workloads. Not so much for large streaming reads, but if you're creating/deleting/scanning large numbers of files, you can see more than a factor of 2 difference in performance. Similarly for DB workloads.
    – hobbs
    Sep 1, 2017 at 15:17
  • I would've suggested f2fs, as this is using flash storage Sep 2, 2017 at 15:28
  • @hobbs: True, but the question was searching for (Quote): "Any tips/pitfalls for a frightened noob" , I did not want to fright the noob off with the complex basics of filesystem architectures.
    – mondjunge
    Sep 4, 2017 at 9:20
4

Quite complex. There are significant differences between the filesystems you mention, and determining the impact of these differences on speed is, IMHO, non-trivial and depends on what operations will be done.

First, let's discard the possibility of installing your root filesystem on a FAT or NTFS partition. These filesystems aren't properly compatible with the Linux kernel and Linux filesystem permissions don't work properly on them, so you would have a lot of interesting problems.

Note: FAT32 is a good choice for USB installation media, and NTFS is a good choice in a dual boot (with Windows) scenario for partitions where you want to use to store personal stuff (like your media library for example) that should be accessible to both Ubuntu (or any other Linux system) and Windows. Linux systems can read (and write to) NTFS partitions as long as they have been mounted correctly, but ext* partitions aren't easily readable to Windows (as far as I know).

The ext* systems were designed to be used with the Linux kernel. Using ext2,3 or 4 for your Ubuntu installation would be perfectly sane. Probably the biggest differences between them are

  • ext2 is non-journalling
  • ext3 is journalling, but otherwise has similar data structures and features to ext2
  • ext4 is journalling and has some performance-enhancing features including a faster algorithm for block allocation compared to earlier ext* systems, although it has similar data structures.

It's important to note, I think, that speed isn't the only consideration when choosing a filesystem. Ext4 has fewer limitations than earlier versions, allowing a larger filesystem, unlimited subdirectories etc. Ext3 is regarded by some as more tried-and-tested, safer and slightly less likely to lose data. I'll try to focus on speed here, while mentioning only the most salient things besides performance.

Wait what? Journalling?1

A journalling filesystem, in short, keeps a log of changes that have not yet been written to the main part of the filesystem. This is done so that in the event of a crash, it's easy to check the consistency of the filesystem by comparing the journal to what has been written to the main filesystem area. This means the speed of checking the filesystem is much faster with ext3 and ext4. Also, because ext4 allows unallocated blocks to be marked, checking them can be skipped, making fsck even faster.

Ext4 also checksums the journal (allowing less I/O waits when writing) which gives a slight overall increase in speed compared to ext3.

Checking filesystem consistency might not be needed very often, and journalling comes at a price - more disk writes. Not only is this bad for a speedy SSD's lifespan, it can slow down performance (writing takes time). The general consensus seems to be that journalling is worth the cost, though.

Performance-enhancing features of ext4

Ext4 supports the fallocate() system call to pre-allocate space for a file. The kernel allocates some blocks and marks them as initialised without writing to them, which is much faster than writing zeroes to the space as was done in older filesystems.

It also uses delayed allocation (or allocate-on-flush) which batches allocations (rather than performing many small ones), thus tending to reduce CPU usage and avoid fragmentation.

Ext4 is backwards compatible with ext2 and ext3, meaning that ext2 and 3 filesystems can be mounted as ext4 and enjoy a modest performance benefit since some features like the new block allocation algorithm can be used.

Other filesystems

Ext* are not the only fully Linux-compatible filesystems, though they are the best-known and most tested. Other filesystems use alternatives to journalling and have innovative features that may impact performance. Btrfs, for example, uses a copy-on-write method of preserving filesystem integrity instead of a journal. It has different data structures to ext* systems. As far as I know, Btrfs is not known to provide faster general performance than ext4, but is regarded as particularly good for archival storage of photo video files, as they are less likely to suffer degradation. It allows filesystem consistency to be checked and cleaned while in use, which might save time depending on your use case. In future, Btrfs or another innovative filesystem may be developed further to outperform ext4 convincingly on general speed.

Conclusion

Most Ubuntu users looking for good performance will want to stick with ext4 for now...


1This and other Linux filesystem concepts are explained really well in Understanding the Linux Kernel.

2
  • 1
    fantastic answer, I have ordered a copy of "understanding the linux kernel", I think I will just use ext4 for now, but I'd like to experiment in the future
    – Conor
    Sep 3, 2017 at 10:06
  • 1
    @ConorCosnett that's awesome. I think the innovative filesystems like Btrfs and ZFS need more adventurous people to test them. Even the lead dev of ext4 has been quoted as saying that Btrfs is, in its theoretical framework at least, better (let's say potentially better) than ext4. It's just that ext* systems are well tested and lots of folks in the Linux world are familiar with them. We stick to what we know.
    – Zanna
    Sep 3, 2017 at 10:14

Not the answer you're looking for? Browse other questions tagged .