Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Goal: microSD card formatted...

  • for best write performance
  • for use only with embedded Linux
  • for better reliability (random power failures may occur)
  • using an 64kB cluster size

I'm using an 8GB microSD card for data storage inside an embedded Linux/ARM device. The SD card is not removable. I've been using ext3 instead of the pre-installed FAT32 because it seems to better handle random power failures during writes. However, I kept noticing that my write performance is always best with the pre-installed FAT32 from Kingston. If I reformat the card with FAT32, the performance still suffers. After browsing wikipedia, I stumbled upon the following comment saying that some cards are optimized for specific cluster sizes. In my case, the Kingston comes pre-formatted for an 64kB cluster size.

Risks of reformatting

Reformatting an SD card with a different file system, or even with the same one, may make the card slower, or shorten its lifespan. Some cards use wear leveling, in which frequently modified blocks are mapped to different portions of memory at different times, and some wear-leveling algorithms are designed for the access patterns typical of the file allocation table on a FAT16 or FAT32 device.[60] In addition, the preformatted file system may use a cluster size that matches the erase region of the physical memory on the card; reformatting may change the cluster size and make writes less efficient.

share|improve this question
    
If ext2 or ext3 allows setting cluster size (I don't know enough to know whether this is possible), this would be my suggestion. –  user3463 Jan 22 '12 at 21:54
1  
@Randolph: It allows you to set a block size of 1, 2, or 4kB. I ended up just trying them all and 1kB is significantly faster than the others. –  Harvey Jan 23 '12 at 0:47
    
Please post your solution as an answer so that we can close the question. –  user3463 Jan 23 '12 at 5:37
    
ext2 is a better choice for flash devices IMHO. No journalling to wear out the flash. I guess the journal is self defeating on flash memory. –  Matt H May 13 '13 at 21:16
    
64KB block size on flash would give bad write performance. –  Matt H May 13 '13 at 21:19

2 Answers 2

Most SD cards (as well as USB drives) out there are optimised for use with FAT32. Using them with any other FS will cause your performance to suffer.

More info at LWN.

share|improve this answer
    
That's not what I've found in practice. But don't use a journalled file system on them or your performance will seem to suffer. –  Matt H May 13 '13 at 21:20
    
And my experience is the same as Arnd Bergmann and I was using top of the line SanDisk SD and CF cards as well as Kingston's USB drives. btrfs in SSD mode, ext2, ext4 without journal... they all did deliver sub 100KiB/s performance after partially filling up the device. –  Hubert Kario May 15 '13 at 8:20

Note: The SD Card Association formatting tool does the following for you.

I don't have the full answer yet for all devices. However, here's the answer for 8GiB cards using FAT32.

Partition the card such that the FAT32 partition starts at sector 8,192 which is 4MiB from the start of the disk. Next, format the FAT32 partition with 32kiB clusters and set the number of "reserved sectors" such that the data area, cluster 2, of the FAT32 partition starts at logical sector 8,192 (or 8MiB from the start of the disk (4MiB from the start of the partition).

Use 32kiB clusters
| 4MiB      | 4MiB                                | remainder of disk    |  
| -------   | ---------------------------------   | ------------------   |  
| MBR       | First Partition Header + FAT tables | First Partition Data |  

Summary reasoning: the SD Card Association has recommended these 4MiB boundaries as optimized zones and recommends FAT32 as the file system for these sized cards. The controller chip in the card is optimized for small reads/writes in that second 4MiB area.

There's a lot more to it than that, but that's the quick and dirty answer. The above method only works for disks < 16GiB for 32kiB clusters and < 32GiB for 64kiB clusters. I suspect that at larger disk sizes, the data area is pushed out to logical 8MiB, but I don't have a disk larger than 8GiB to use.

share|improve this answer
1  
Would be interesting to find some "official" documentation on this, or a procedure how to investigate this. –  Hanzaplastique Jun 27 at 13:39
    
@Hanzaplastique: I'll try to track it down. The 4MB boundaries are in active use on most cards and I remember finding the recommendation for this in the SD Card specifications buried somewhere on their site. –  Harvey Jul 31 at 4:02

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.