1 |
On Thursday, August 06, 2015 6:18:59 PM Meino.Cramer@×××.de wrote: |
2 |
> Hi, |
3 |
> |
4 |
> for my tablet PC I used a used 32GB FAT32 formatted SDcard. The |
5 |
> formatting was already done by the manufacturer. |
6 |
> Then I screwed it up and had to do the partioning and formatting |
7 |
> myself again. "No big deal", I thought -- and was wrong. |
8 |
> Yes, the "thing" I got could be read and written. But it was |
9 |
> DAMN slow in comparison to the original formatting. |
10 |
> |
11 |
> I googled and found a description, which described exactly, |
12 |
> what I wanted: An optimal formatting for one big FAT32 partion. |
13 |
> I did it again ;) and: TADA! The speed was back. |
14 |
> LINK:http://zero1-st.blogspot.de/2012/05/formatting-fat32-volumes-larger-than.html |
15 |
> |
16 |
> Now I need the something identical but explained in a way |
17 |
> that it can be successfully applied to any partion layout |
18 |
> and any SDcard size. |
19 |
> Currently the new SDcard has 64GB (yes, the tablet eats that size |
20 |
> well :) and needs at least two partions: One FAT32 and one ext4. |
21 |
> May be that I need a different layout later. |
22 |
> |
23 |
> To what aspect and "logic" do I have to keep my eyes on, when |
24 |
> it comes partioning/formatting any SDcard size with any partion |
25 |
> layout and any filesystem? |
26 |
> |
27 |
> Thank you very much in advance for any help! |
28 |
> Best regards, |
29 |
> Meino |
30 |
|
31 |
I wrote a long reply to this and it appears to have been swallowed by |
32 |
/dev/null. |
33 |
|
34 |
SD cards don't have 128K blocks. Except for the very early ones (standard |
35 |
capacity), they are divided in allocation units (AU) that are 1MB to 4MB for |
36 |
SDHC and even larger for SDXC. The only way to get that value is by reading a |
37 |
register in the card (so you can't do it in usermode on linux). |
38 |
|
39 |
The AUs are divided into Recording Units (RUs). The size of these can be |
40 |
deduced from the card speed class (that's the number inside the C on the |
41 |
label), and the card capacity. For class 2 and 4 if the card is less than 1GB |
42 |
it's 16KB, otherwise it's 32KB. For class 6 it is 64KB, and for class 10 it's |
43 |
512KB. |
44 |
|
45 |
After an AU is erased you can write to any of the free RUs in any order in |
46 |
blocks of 512 bytes sequentially (the block size is configurable by the driver |
47 |
but 512 is the most common). But if you write to a nonfree RU then all non- |
48 |
free RU get copied to a new AU. So the performance hit depends on how many |
49 |
non-free RUs are in the AU when this happens. |
50 |
|
51 |
So to get the best performance you need to align the first FAT cluster on an AU |
52 |
boundary and that the RUs used by the reserved sectors after the FAT are free. |
53 |
This is not so easy from usermode because you can't get the AU size and you |
54 |
can't erase the AU to make sure reserved sectors are free. The Windows 7 and |
55 |
later format utility will do it if you don't partition the card. The next best |
56 |
thing is to align it to an RU which should be pretty easy. |
57 |
|
58 |
You could guess the AU size by writting blocks of RU size from the start of |
59 |
the card and timing it. Every time you hit the AU boundary there will be a |
60 |
longer delay. |
61 |
|
62 |
For more details see the SD specification (chapter 4.13). |
63 |
|
64 |
https://www.sdcard.org/downloads/pls/ |
65 |
|
66 |
They also have formatter tools for Windows and OSX. I tried the Windows |
67 |
version years ago but had problems with it (can't remember what). |
68 |
|
69 |
-- |
70 |
Fernando Rodriguez |