1 |
Fernando Rodriguez <frodriguez.developer@×××××××.com> [15-08-08 05:42]: |
2 |
> On Friday, August 07, 2015 7:01:29 PM Mick wrote: |
3 |
> > On Friday 07 Aug 2015 04:27:15 Fernando Rodriguez wrote: |
4 |
> > > On Thursday, August 06, 2015 6:18:59 PM Meino.Cramer@×××.de wrote: |
5 |
> > > > Hi, |
6 |
> > > > |
7 |
> > > > for my tablet PC I used a used 32GB FAT32 formatted SDcard. The |
8 |
> > > > formatting was already done by the manufacturer. |
9 |
> > > > Then I screwed it up and had to do the partioning and formatting |
10 |
> > > > myself again. "No big deal", I thought -- and was wrong. |
11 |
> > > > Yes, the "thing" I got could be read and written. But it was |
12 |
> > > > DAMN slow in comparison to the original formatting. |
13 |
> > > > |
14 |
> > > > I googled and found a description, which described exactly, |
15 |
> > > > what I wanted: An optimal formatting for one big FAT32 partion. |
16 |
> > > > I did it again ;) and: TADA! The speed was back. |
17 |
> > > > LINK:http://zero1-st.blogspot.de/2012/05/formatting-fat32-volumes-larger-> > than.html |
18 |
> > > > |
19 |
> > > > Now I need the something identical but explained in a way |
20 |
> > > > that it can be successfully applied to any partion layout |
21 |
> > > > and any SDcard size. |
22 |
> > > > Currently the new SDcard has 64GB (yes, the tablet eats that size |
23 |
> > > > well :) and needs at least two partions: One FAT32 and one ext4. |
24 |
> > > > May be that I need a different layout later. |
25 |
> > > > |
26 |
> > > > To what aspect and "logic" do I have to keep my eyes on, when |
27 |
> > > > it comes partioning/formatting any SDcard size with any partion |
28 |
> > > > layout and any filesystem? |
29 |
> > > > |
30 |
> > > > Thank you very much in advance for any help! |
31 |
> > > > Best regards, |
32 |
> > > > Meino |
33 |
> > > |
34 |
> > > I wrote a long reply to this and it appears to have been swallowed by |
35 |
> > > /dev/null. |
36 |
> > > |
37 |
> > > SD cards don't have 128K blocks. Except for the very early ones (standard |
38 |
> > > capacity), they are divided in allocation units (AU) that are 1MB to 4MB |
39 |
> > > for SDHC and even larger for SDXC. The only way to get that value is by |
40 |
> > > reading a register in the card (so you can't do it in usermode on linux). |
41 |
> > > |
42 |
> > > The AUs are divided into Recording Units (RUs). The size of these can be |
43 |
> > > deduced from the card speed class (that's the number inside the C on the |
44 |
> > > label), and the card capacity. For class 2 and 4 if the card is less than |
45 |
> > > 1GB it's 16KB, otherwise it's 32KB. For class 6 it is 64KB, and for class |
46 |
> > > 10 it's 512KB. |
47 |
> > > |
48 |
> > > After an AU is erased you can write to any of the free RUs in any order in |
49 |
> > > blocks of 512 bytes sequentially (the block size is configurable by the |
50 |
> > > driver but 512 is the most common). But if you write to a nonfree RU then |
51 |
> > > all non- free RU get copied to a new AU. So the performance hit depends on |
52 |
> > > how many non-free RUs are in the AU when this happens. |
53 |
> > > |
54 |
> > > So to get the best performance you need to align the first FAT cluster on |
55 |
> > > an AU boundary and that the RUs used by the reserved sectors after the FAT |
56 |
> > > are free. This is not so easy from usermode because you can't get the AU |
57 |
> > > size and you can't erase the AU to make sure reserved sectors are free. |
58 |
> > > The Windows 7 and later format utility will do it if you don't partition |
59 |
> > > the card. The next best thing is to align it to an RU which should be |
60 |
> > > pretty easy. |
61 |
> > > |
62 |
> > > You could guess the AU size by writting blocks of RU size from the start |
63 |
> of |
64 |
> > > the card and timing it. Every time you hit the AU boundary there will be a |
65 |
> > > longer delay. |
66 |
> > > |
67 |
> > > For more details see the SD specification (chapter 4.13). |
68 |
> > > |
69 |
> > > https://www.sdcard.org/downloads/pls/ |
70 |
> > > |
71 |
> > > They also have formatter tools for Windows and OSX. I tried the Windows |
72 |
> > > version years ago but had problems with it (can't remember what). |
73 |
> > |
74 |
> > Excellent information Fernando, thank you! |
75 |
> > |
76 |
> > So there is no tool for me to use to read the AU/RU on the chip? |
77 |
> > |
78 |
> > |
79 |
> |
80 |
> The RU can be calculated from the card size and speed class, that's the number |
81 |
> printed on the card label inside the C. I don't know of any tools to get the |
82 |
> AU and it looks like it's not exported to userspace so any such tool would |
83 |
> have to guess it. However, if you want to hack your kernel all it takes is one |
84 |
> line on /usr/src/linux/drivers/mmc/core/debugfs.c. Add the following towards |
85 |
> the end of mmc_ios_show before the return statement: |
86 |
> |
87 |
> seq_printf(s, "au (sectors):\t%u\n", host->card->ssr.au); |
88 |
> |
89 |
> then you can do: |
90 |
> |
91 |
> cat /sys/kernel/debug/mmc0/ios |
92 |
> |
93 |
> Multiply the value by 512 to get the size in bytes. It can be up to 64MB. |
94 |
> |
95 |
> |
96 |
> |
97 |
> -- |
98 |
> Fernando Rodriguez |
99 |
> |
100 |
|
101 |
|
102 |
Hi Fernando, |
103 |
|
104 |
I looked into the kernel ... but ... hmmmm ... |
105 |
for me it seems this is only for onboard mmc flash... |
106 |
which is often found on embedded linux boards. |
107 |
Or am I wrong? |
108 |
I am using a micro sdcard in a sdcard-reader plugged |
109 |
into an USB port of my Linux PC. |
110 |
(Later it will be inserted into the sdcard slot of |
111 |
my tablet PC...) |
112 |
I am asking just to prevent to make things screwed up. |
113 |
|
114 |
Have a nice sunday! :) |
115 |
Best regards, |
116 |
Meino |