Gentoo Archives: gentoo-user

From: Meino.Cramer@×××.de
To: gentoo-user@l.g.o
Subject: Re: [gentoo-user] [OT]: Optimal formatting a SDcard (64GB) with partions of diffent sizes and filesystems?
Date: Fri, 07 Aug 2015 19:45:05
Message-Id: 20150807194450.GC4388@solfire
In Reply to: Re: [gentoo-user] [OT]: Optimal formatting a SDcard (64GB) with partions of diffent sizes and filesystems? by Mick
1 Mick <michaelkintzios@×××××.com> [15-08-07 20:04]:
2 > On Friday 07 Aug 2015 04:27:15 Fernando Rodriguez wrote:
3 > > On Thursday, August 06, 2015 6:18:59 PM Meino.Cramer@×××.de wrote:
4 > > > Hi,
5 > > >
6 > > > for my tablet PC I used a used 32GB FAT32 formatted SDcard. The
7 > > > formatting was already done by the manufacturer.
8 > > > Then I screwed it up and had to do the partioning and formatting
9 > > > myself again. "No big deal", I thought -- and was wrong.
10 > > > Yes, the "thing" I got could be read and written. But it was
11 > > > DAMN slow in comparison to the original formatting.
12 > > >
13 > > > I googled and found a description, which described exactly,
14 > > > what I wanted: An optimal formatting for one big FAT32 partion.
15 > > > I did it again ;) and: TADA! The speed was back.
16 > > > LINK:http://zero1-st.blogspot.de/2012/05/formatting-fat32-volumes-larger-> > than.html
17 > > >
18 > > > Now I need the something identical but explained in a way
19 > > > that it can be successfully applied to any partion layout
20 > > > and any SDcard size.
21 > > > Currently the new SDcard has 64GB (yes, the tablet eats that size
22 > > > well :) and needs at least two partions: One FAT32 and one ext4.
23 > > > May be that I need a different layout later.
24 > > >
25 > > > To what aspect and "logic" do I have to keep my eyes on, when
26 > > > it comes partioning/formatting any SDcard size with any partion
27 > > > layout and any filesystem?
28 > > >
29 > > > Thank you very much in advance for any help!
30 > > > Best regards,
31 > > > Meino
32 > >
33 > > I wrote a long reply to this and it appears to have been swallowed by
34 > > /dev/null.
35 > >
36 > > SD cards don't have 128K blocks. Except for the very early ones (standard
37 > > capacity), they are divided in allocation units (AU) that are 1MB to 4MB
38 > > for SDHC and even larger for SDXC. The only way to get that value is by
39 > > reading a register in the card (so you can't do it in usermode on linux).
40 > >
41 > > The AUs are divided into Recording Units (RUs). The size of these can be
42 > > deduced from the card speed class (that's the number inside the C on the
43 > > label), and the card capacity. For class 2 and 4 if the card is less than
44 > > 1GB it's 16KB, otherwise it's 32KB. For class 6 it is 64KB, and for class
45 > > 10 it's 512KB.
46 > >
47 > > After an AU is erased you can write to any of the free RUs in any order in
48 > > blocks of 512 bytes sequentially (the block size is configurable by the
49 > > driver but 512 is the most common). But if you write to a nonfree RU then
50 > > all non- free RU get copied to a new AU. So the performance hit depends on
51 > > how many non-free RUs are in the AU when this happens.
52 > >
53 > > So to get the best performance you need to align the first FAT cluster on
54 > > an AU boundary and that the RUs used by the reserved sectors after the FAT
55 > > are free. This is not so easy from usermode because you can't get the AU
56 > > size and you can't erase the AU to make sure reserved sectors are free.
57 > > The Windows 7 and later format utility will do it if you don't partition
58 > > the card. The next best thing is to align it to an RU which should be
59 > > pretty easy.
60 > >
61 > > You could guess the AU size by writting blocks of RU size from the start of
62 > > the card and timing it. Every time you hit the AU boundary there will be a
63 > > longer delay.
64 > >
65 > > For more details see the SD specification (chapter 4.13).
66 > >
67 > > https://www.sdcard.org/downloads/pls/
68 > >
69 > > They also have formatter tools for Windows and OSX. I tried the Windows
70 > > version years ago but had problems with it (can't remember what).
71 >
72 > Excellent information Fernando, thank you!
73 >
74 > So there is no tool for me to use to read the AU/RU on the chip?
75 >
76 > --
77 > Regards,
78 > Mick
79
80
81 Hi,
82
83 sorry for being a little late...was too busy and my sdcard is still
84 not formatted... ;)
85
86 Thank you very much for the help and all the informations. Currently I
87 start to understand the problems and solutions in formatting ONE
88 partition with a FAT32 filesystem on a sdcard the correct way, but
89 when it comes to more the one partition and filesystems for example
90 like ext4fs I still dont know how to...
91
92 Just a few minutes before I found this:
93 http://www.bradfordembedded.com/2014/05/flashbenching/
94 http://wiki.laptop.org/go/How_to_Damage_a_FLASH_Storage_Device
95 https://github.com/bradfa/flashbench
96 http://wiki.laptop.org/go/SDCard_Testing
97 https://lists.linaro.org/pipermail/flashbench-results/
98 https://blogofterje.wordpress.com/2012/01/14/optimizing-fs-on-sd-card/
99
100 I am still in the process of reading and hopefully understanding
101 this...
102
103 Best regards,
104 Meino

Replies

Subject Author
Re: [gentoo-user] [OT]: Optimal formatting a SDcard (64GB) with partions of diffent sizes and filesystems? Fernando Rodriguez <frodriguez.developer@×××××××.com>