On Thursday, August 06, 2015 6:18:59 PM meino.cra...@gmx.de wrote: > Hi, > > for my tablet PC I used a used 32GB FAT32 formatted SDcard. The > formatting was already done by the manufacturer. > Then I screwed it up and had to do the partioning and formatting > myself again. "No big deal", I thought -- and was wrong. > Yes, the "thing" I got could be read and written. But it was > DAMN slow in comparison to the original formatting. > > I googled and found a description, which described exactly, > what I wanted: An optimal formatting for one big FAT32 partion. > I did it again ;) and: TADA! The speed was back. > LINK:http://zero1-st.blogspot.de/2012/05/formatting-fat32-volumes-larger-than.html > > Now I need the something identical but explained in a way > that it can be successfully applied to any partion layout > and any SDcard size. > Currently the new SDcard has 64GB (yes, the tablet eats that size > well :) and needs at least two partions: One FAT32 and one ext4. > May be that I need a different layout later. > > To what aspect and "logic" do I have to keep my eyes on, when > it comes partioning/formatting any SDcard size with any partion > layout and any filesystem? > > Thank you very much in advance for any help! > Best regards, > Meino
I had to research this a few years back when writing a FAT32/SD driver[1] for an embedded project because all the available choices where too slow at writing for my requirements. It's been a while so excuse me if I got some details wrong. Most of the information you'll find around is wrong (it may still give you good results as in your case) but the only reliable source I found is the specification[2]. 128KB is not the magic number, SD cards (except for the very early ones or standard SD) are divided into Allocation Units (AU) that are between 1-4 MB for SDHC and even greater for SDHC. To get the actual value you need to read a register on the card (Linux may expose it on /sys, not sure), I did this work on Windows and I had to write a program (now lost) to guess it by writting at different boundaries and benchmarking. The Windows 7 and later formatting utility will align it properly though. The AUs are further divided into Recording Units (RU). These are determined by the speed class of the card (the number inside the C on the label) and the capacity. For class 2 and 4 it is 16kb if the card is under 1GB or 32K otherwise. For class 6 it is 64KB, and for class 10 it is 512KB. After an AU is erased you can write to all the RUs within it in any order but if you modify an RU all the used RUs on that AU need to be copied to a new AU. So to get the best performance you need to make sure that the first cluster is aligned to an AU boundary and erase the padding sectors before writing the FAT (I'm not sure if mkdosfs can do that last bit from userspace), otherwise everytime the FAT is updated all the padding sectors are copied needlessly. The next best thing is aligning it to an RU boundary which is easier to determine. 1. https://github.com/fernando-rodriguez/fat32lib/ 2. https://www.sdcard.org/downloads/pls/ -- Fernando Rodriguez