Logo

Thin Clients: Compact Flash Cards 

This article is a mirror of the original that at one point was on the LinuxPlanet website (now Linux Today?).

Note: The article dates from 2010, file systems and file system code/efficiency will have moved on from then.


What's The Fastest Filesystem On Cheap Flash Media?

What's The Fastest Filesystem On Cheap Flash Drives?

October 26, 2010
By David North

Compact Flash and SD storage cards are everywhere; gigabytes for cheap in a tiny form factor. Most come formatted with VFAT. So what is the fastest Linux filesystem for these little devices?

Flash drives and SD Cards are getting bigger, faster and cheaper. They're not just for sucking down snaps from your pocket camera any more: they're backup storage, portable homedirs, netbook expansion ... you name it.

Most arrive with a VFAT filesystem, and usually stay that way. But for a lot of applications, this is not ideal. Curious if the filesystem made any difference, we did what Feynman would have done: tested some.

For once, testing gave a pretty clear answer. So what is the fastest filesystem linux folks can use on their flash media?

Ext4.

In some situations, more than four times as fast as ext3. Surprised? So was Ted Ts'o, a lead designer and maintainer of the ext4 filesystem. "You're seeing a 4x improvement in speed between ext3 and ext4?" Ted asked. "That is impressive, and quite surprising to me." He added: "I've been primarily focused on speeding up ext4 on HDDs, and on my laptop hard drive (an Intel X25-M SSD), and not really on thumb drives."

Let's take a look at some of the numbers that provoked Ted's curiosity. The times are seconds it took to write the complete, uncompressed linux 2.6.34 kernel directory to a newish Class 10 SD card, then read it back (after flushing the caches). Smaller is better:

         Ext2     Ext3     Ext4  Reiser3     VFat     NTFS
Write    368      501      125      582      518      174
Read      53       60       53       72       98      118

Almost exactly four times as fast as ext3, almost three times as fast as ext2, and clearly best overall for writing. NTFS put up a good show until reading, where it came in dead last. Be warned about Reiser, it's always slow on flash.

So is it always like this? Well, no. One thing you learn testing flash drives: they make no sense. Results are often paradoxical. For example, here's exactly the same test run on an ultra-cheap 2GB no-name USB thumb drive:

         Ext2     Ext3     Ext4  Reiser3     VFat     NTFS
Write    434      361      156      750      564      165
Read      50       64       48       87       51      125

Your first clue that something is strange? Ext2 and Ext3 change places for write speed! And on this cheap unit, some read speeds go down while write speed go generally up. But Ext4 still clobbers everyone.

Admittedly, this is unfair. All these tests are on a very large set of small files. What happens if you're just copying one large file? Here's the bzipped kernel (one huge file) written to the SD card. Fractions of seconds are shown.

         Ext2     Ext3     Ext4  Reiser3     VFat     NTFS
Write    14.45    11.21     8.67    18.31     8.36    16.08
Read      4.72     4.55     4.66     4.74     4.44     4.48

Good news! Since many cameras, phones and other toys must use VFAT it's a relief to see excellent performance when transferring just a few largish lumps. It will lag behind Ext4 when you get up to 20 files or so, but it's still close enough. No need to try to hack your point'n'shoot to read Ext4.

Another extreme example: old systems that only have USB 1.1. Filesystem is irrelevant because the limit is USB bandwidth.

If you're only using your flashtoy on one linux computer or only trading among linuxboxen, no problem. Use Ext4.

For Apple, Linux can read and write HFS+ just fine, but on two Snow Leopard installs it was extremely slow writing the kernel directory (one test took over two hours!) The same run on VFAT took a bit over seven minutes. Stick with VFAT.

Windows? There's a good argument for experimenting with NTFS, but most of the time VFAT will suffice.

Why Those Filesystems?

Simple. They're the logical choices from Gnome's Disk Utility. The idea was to test filesystems normal folks might actually use on their flash drive. But it's impossible not to be curious at least about XFS and Btrfs, even though they're unlikely candidates. XFS was easy to analyse, since it took so long we only ran one test to the end (19 minutes on tasks that took six on other systems.) Stay away.

Btrfs, on the other hand, was very competitive with Ext4. It didn't win, but it came close. Considering its raw state, it doesn't offer any advantage right now, but it's certainly the one to watch.

Ted wanted it very clear that the results you see here do not reflect how these filesystems will work on hard drives or SSDs. They really don't. Remember: flash is weird!

Test Methodology

Well over 200 tests were run using eight computers running 12 operating systems. Ten flash units were used, some USB drives and others in one of five card readers. Small, medium and large workloads were tested. The results were consistently weird, but almost always favoured Ext4.

Tests were run from hard disk to flash, from flash to flash, and to get as clean a result as possible, from ramdisk to flash and back. The variances were interesting, but usually not far from the numbers you've already seen. Your results will vary! So running your own tests is highly recommended.

To duplicate these tests, download the linux 2.6.34 beezyball and run

time rsync -rv from -> to && time sync && time umount flash

Best to live on the edge and run as root.

 


Any comments? email me. Added September 2021