1 |
Fernando Rodriguez <frodriguez.developer@×××××××.com> [15-08-08 05:43]: |
2 |
> On Friday, August 07, 2015 9:44:50 PM Meino.Cramer@×××.de wrote: |
3 |
> > Mick <michaelkintzios@×××××.com> [15-08-07 20:04]: |
4 |
> > > On Friday 07 Aug 2015 04:27:15 Fernando Rodriguez wrote: |
5 |
> > > > On Thursday, August 06, 2015 6:18:59 PM Meino.Cramer@×××.de wrote: |
6 |
> > > > > Hi, |
7 |
> > > > > |
8 |
> > > > > for my tablet PC I used a used 32GB FAT32 formatted SDcard. The |
9 |
> > > > > formatting was already done by the manufacturer. |
10 |
> > > > > Then I screwed it up and had to do the partioning and formatting |
11 |
> > > > > myself again. "No big deal", I thought -- and was wrong. |
12 |
> > > > > Yes, the "thing" I got could be read and written. But it was |
13 |
> > > > > DAMN slow in comparison to the original formatting. |
14 |
> > > > > |
15 |
> > > > > I googled and found a description, which described exactly, |
16 |
> > > > > what I wanted: An optimal formatting for one big FAT32 partion. |
17 |
> > > > > I did it again ;) and: TADA! The speed was back. |
18 |
> > > > > LINK:http://zero1-st.blogspot.de/2012/05/formatting-fat32-volumes-larger-> > than.html |
19 |
> > > > > |
20 |
> > > > > Now I need the something identical but explained in a way |
21 |
> > > > > that it can be successfully applied to any partion layout |
22 |
> > > > > and any SDcard size. |
23 |
> > > > > Currently the new SDcard has 64GB (yes, the tablet eats that size |
24 |
> > > > > well :) and needs at least two partions: One FAT32 and one ext4. |
25 |
> > > > > May be that I need a different layout later. |
26 |
> > > > > |
27 |
> > > > > To what aspect and "logic" do I have to keep my eyes on, when |
28 |
> > > > > it comes partioning/formatting any SDcard size with any partion |
29 |
> > > > > layout and any filesystem? |
30 |
> > > > > |
31 |
> > > > > Thank you very much in advance for any help! |
32 |
> > > > > Best regards, |
33 |
> > > > > Meino |
34 |
> > > > |
35 |
> > > > I wrote a long reply to this and it appears to have been swallowed by |
36 |
> > > > /dev/null. |
37 |
> > > > |
38 |
> > > > SD cards don't have 128K blocks. Except for the very early ones |
39 |
> (standard |
40 |
> > > > capacity), they are divided in allocation units (AU) that are 1MB to 4MB |
41 |
> > > > for SDHC and even larger for SDXC. The only way to get that value is by |
42 |
> > > > reading a register in the card (so you can't do it in usermode on |
43 |
> linux). |
44 |
> > > > |
45 |
> > > > The AUs are divided into Recording Units (RUs). The size of these can be |
46 |
> > > > deduced from the card speed class (that's the number inside the C on the |
47 |
> > > > label), and the card capacity. For class 2 and 4 if the card is less |
48 |
> than |
49 |
> > > > 1GB it's 16KB, otherwise it's 32KB. For class 6 it is 64KB, and for |
50 |
> class |
51 |
> > > > 10 it's 512KB. |
52 |
> > > > |
53 |
> > > > After an AU is erased you can write to any of the free RUs in any order |
54 |
> in |
55 |
> > > > blocks of 512 bytes sequentially (the block size is configurable by the |
56 |
> > > > driver but 512 is the most common). But if you write to a nonfree RU |
57 |
> then |
58 |
> > > > all non- free RU get copied to a new AU. So the performance hit depends |
59 |
> on |
60 |
> > > > how many non-free RUs are in the AU when this happens. |
61 |
> > > > |
62 |
> > > > So to get the best performance you need to align the first FAT cluster on |
63 |
> > > > an AU boundary and that the RUs used by the reserved sectors after the |
64 |
> FAT |
65 |
> > > > are free. This is not so easy from usermode because you can't get the AU |
66 |
> > > > size and you can't erase the AU to make sure reserved sectors are free. |
67 |
> > > > The Windows 7 and later format utility will do it if you don't partition |
68 |
> > > > the card. The next best thing is to align it to an RU which should be |
69 |
> > > > pretty easy. |
70 |
> > > > |
71 |
> > > > You could guess the AU size by writting blocks of RU size from the start |
72 |
> of |
73 |
> > > > the card and timing it. Every time you hit the AU boundary there will be |
74 |
> a |
75 |
> > > > longer delay. |
76 |
> > > > |
77 |
> > > > For more details see the SD specification (chapter 4.13). |
78 |
> > > > |
79 |
> > > > https://www.sdcard.org/downloads/pls/ |
80 |
> > > > |
81 |
> > > > They also have formatter tools for Windows and OSX. I tried the Windows |
82 |
> > > > version years ago but had problems with it (can't remember what). |
83 |
> > > |
84 |
> > > Excellent information Fernando, thank you! |
85 |
> > > |
86 |
> > > So there is no tool for me to use to read the AU/RU on the chip? |
87 |
> > > |
88 |
> > |
89 |
> > |
90 |
> > Hi, |
91 |
> > |
92 |
> > sorry for being a little late...was too busy and my sdcard is still |
93 |
> > not formatted... ;) |
94 |
> > |
95 |
> > Thank you very much for the help and all the informations. Currently I |
96 |
> > start to understand the problems and solutions in formatting ONE |
97 |
> > partition with a FAT32 filesystem on a sdcard the correct way, but |
98 |
> > when it comes to more the one partition and filesystems for example |
99 |
> > like ext4fs I still dont know how to... |
100 |
> > |
101 |
> > Just a few minutes before I found this: |
102 |
> > http://www.bradfordembedded.com/2014/05/flashbenching/ |
103 |
> > http://wiki.laptop.org/go/How_to_Damage_a_FLASH_Storage_Device |
104 |
> > https://github.com/bradfa/flashbench |
105 |
> > http://wiki.laptop.org/go/SDCard_Testing |
106 |
> > https://lists.linaro.org/pipermail/flashbench-results/ |
107 |
> > https://blogofterje.wordpress.com/2012/01/14/optimizing-fs-on-sd-card/ |
108 |
> > |
109 |
> > I am still in the process of reading and hopefully understanding |
110 |
> > this... |
111 |
> > |
112 |
> > Best regards, |
113 |
> > Meino |
114 |
> |
115 |
> For partitioning just account for the offset of the 1st partition when |
116 |
> calculating the number of reserved sectors and make the FAT partition the first |
117 |
> partition. If the MBR pushes the FAT beyond the number of AUs that it would |
118 |
> otherwise occupy I would reconsider using an unpartitioned filesystem. |
119 |
> |
120 |
> I'm not very familiar with the structure of ext4 so I'm not sure what you can |
121 |
> do to optimize it but SD cards are designed with FAT32 in mind. A journaling |
122 |
> filesystem (or a FAT partition outside the first partition) for example will put |
123 |
> a lot of stress on areas that are not meant to support it. |
124 |
> |
125 |
> -- |
126 |
> Fernando Rodriguez |
127 |
> |
128 |
|
129 |
Hi Fernando, |
130 |
|
131 |
thanks a lot again for your thoughts! :) |
132 |
|
133 |
A little background to what I am trying to acchieve: I have an |
134 |
Android tablet, which supports FAT32 for the external flash (the |
135 |
sdcard) in its initial state. |
136 |
It has an internel flash, which is ext4 formatted (as far as I know). |
137 |
That means: It is possible to use ext4 on the sdcard also, because |
138 |
the Android kernel knows this fs. |
139 |
As Android is a SELinux, it only installs applications (with a few |
140 |
exceptions) on internal flash. |
141 |
BUT: :) |
142 |
There are applications for Android (I hate to say "Apps" ... it sounds |
143 |
like one would say "eds" for "editors" and "compils" for "compilers"), |
144 |
which make it possible to move applications from internal to external |
145 |
flash -- the sdcard, if one has a formatted the sdcard with a second |
146 |
partition with an ext4fs on it. |
147 |
|
148 |
Additionally I found this: |
149 |
https://wiki.gentoo.org/wiki/SDCard |
150 |
|
151 |
And: One could switch off journaling on ext4fs to minimize writes |
152 |
to the flash. Further options are available too. |
153 |
|
154 |
Best regards, |
155 |
Meino |