Gentoo Archives: gentoo-user

From: Fernando Rodriguez <frodriguez.developer@×××××××.com>
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 22:34:42
Message-Id: BLU436-SMTP1322722E1140022D7675BB68D730@phx.gbl
In Reply to: Re: [gentoo-user] [OT]: Optimal formatting a SDcard (64GB) with partions of diffent sizes and filesystems? by wabenbau@gmail.com
1 On Friday, August 07, 2015 8:33:17 PM wabenbau@×××××.com wrote:
2 > Mick <michaelkintzios@×××××.com> wrote:
3 >
4 > > On Friday 07 Aug 2015 00:23:35 wabenbau@×××××.com wrote:
5 > > > Mick <michaelkintzios@×××××.com> wrote:
6 > > > > I was wondering similar questions regarding a 32G flash card I
7 > > > > have. Using fdisk to partition it the starting sector was
8 > > > > automatically aligned with 2048 as it fdisk has been improved to
9 > > > > deal with 4KB sector drives.
10 > > > >
11 > > > > However, formatting it with mkfs.vfat I was none the wise if I
12 > > > > should use the '-s sectors-per-cluster' option or what to set it
13 > > > > at.
14 > > >
15 > > > For the SD Cards of my Android devices I use
16 > > >
17 > > > mkfs.vfat -F32 -s64
18 > > >
19 > > > This always gave me good performance.
20 > > >
21 > > > > Furthermore, how can I read the current cluster size off the flash
22 > > > > card? Is this appropriate?
23 > > > >
24 > > > > blockdev --getbsz /dev/sdb
25 > > > > 4096
26 > > >
27 > > > This gives you the physical blocksize of the device.
28 > > >
29 > > > If you wanna know the cluster size, that means the blocksize of your
30 > > > filesystem, you can use mtools. First
31 > > > configure /etc/mtools/mtools.conf and set a drive letter for your
32 > > > SD Card, e.g.
33 > > >
34 > > > drive c: file="/dev/sde1"
35 > > >
36 > > > then use
37 > > >
38 > > > minfo C:
39 > > >
40 > > > to query a lot of information about the filesystem. Beside some
41 > > > other infos you will get for example:
42 > > >
43 > > > sector size: 512 bytes
44 > > > cluster size: 8 sectors
45 > > >
46 > > > This means cluster size is 4096 Bytes.
47 > > >
48 > > > --
49 > > > Regards
50 > > > wabe
51 > >
52 > > Thanks!
53 > >
54 > > I've used minfo and this is what it showed:
55 > >
56 > > # minfo d:
57 > > device information:
58 > > ===================
59 > > filename="/dev/sdb1"
60 > > sectors per track: 32
61 > > heads: 64
62 > > cylinders: 30399
63 > >
64 > > mformat command line: mformat -t 30399 -h 64 -s 32 -H 2048 d:
65 > >
66 > > bootsector information
67 > > ======================
68 > > banner:"mkfs.fat"
69 > > sector size: 512 bytes
70 > > cluster size: 32 sectors
71 > > reserved (boot) sectors: 32
72 > > fats: 2
73 > > max available root directory slots: 0
74 > > small size: 0 sectors
75 > > media descriptor byte: 0xf8
76 > > sectors per fat: 0
77 > > sectors per track: 32
78 > > heads: 64
79 > > hidden sectors: 2048
80 > > big size: 62257152 sectors
81 > > physical drive id: 0x80
82 > > reserved=0x1
83 > > dos4=0x29
84 > > serial number: 870C0C43
85 > > disk label="VERBATIM32G"
86 > > disk type="FAT32 "
87 > > Big fatlen=15193
88 > > Extended flags=0x0000
89 > > FS version=0x0000
90 > > rootCluster=2
91 > > infoSector location=1
92 > > backup boot sector=6
93 > >
94 > > Infosector:
95 > > signature=0x41615252
96 > > free clusters=516445
97 > > last allocated cluster=1448265
98 > >
99 > >
100 > > So, with:
101 > >
102 > > sector size: 512 bytes
103 > > cluster size: 32 sectors
104 > >
105 > > I get a cluster of 16,384 bytes. This was created automagically,
106 > > when I ran:
107 > >
108 > > mkfs.vfat -c -n "Verbatim Flash" /dev/sdb1
109 > >
110 > > Without knowing the specific AU/RU as Fernando explained, should it
111 > > be smaller/bigger, or should I leave well alone.
112 >
113 > I think, this depends on how big the files are that you wanna store on the
114 > card. If you plan to store many very small files on it, than it is probably
115 > better to choose a smaller cluster size. But for music files, pictures and
116 > videos this size should be ok.
117 >
118 > --
119 > Regards
120 > wabe
121 >
122
123 IIRC somewhere the spec hints at a 32K optimal cluster size. I think this is
124 because the AUs where the FAT would be may be implemented with faster or more
125 tolerant flash memory (halving the cluster size means doubling the FAT size).
126 But if you know the AU size you can do the math and if the FAT fits on the same
127 number of AUs I don't see a reason not to use a different cluster size.
128
129 --
130 Fernando Rodriguez