Gentoo Archives: gentoo-user

From: Todd Goodman <tsg@×××××××××.net>
To: gentoo-user@l.g.o
Subject: Re: [gentoo-user] Re: Resizing a FAT partition?
Date: Thu, 30 Jul 2015 20:04:05
Message-Id: 20150730200342.GO6904@ns1.bonedaddy.net
In Reply to: Re: [gentoo-user] Re: Resizing a FAT partition? by Francisco Ares
1 * Francisco Ares <frares@×××××.com> [150730 15:53]:
2 [..SNIP..}
3 > Flash memory devices are tricky when you try do defrag, as there is extra
4 > logic inside them to do the opposite: spread as much data as possible, as
5 > to equalize the number of write operations - the main limit for flash
6 > memory - for all sectors.
7 >
8 > Most defrag tools do this by reading files to RAM, reordering them, erasing
9 > the originals from the media, then writing them again, using no direct
10 > sector access, leaving that to the operating system. And it works on
11 > magnetic media, as it creates empty spaces suitable for continuous files.
12 >
13 > So that extra logic may fool you, making you believe it worked, when it
14 > didn't.
15 >
16 > Considering this, as already said, I would copy everything to another
17 > media, set up a new partition layout, format the new partitions as desired,
18 > then get all data back to the new layout.
19 >
20 > Just my 2 cents, of course.
21 >
22 > Good luck
23 > Francisco
24
25 I don't believe this is right (though I've been wrong before.)
26
27 Both partitions and filesystems (including defragging filesystems)
28 operate at the block level.
29
30 Wear leveling and bad block handling happen "below" the block level.
31
32 If you gave flash memory data for block n and later tried to read block
33 n and got back something different it would be very broken.
34
35 Of course physically logical block n might actually be stored in
36 physical block y, but the flash controller (or whatever is responsible
37 for wear leveling and bad block mapping) still needs to know to give
38 back the data from physical block y when it's asked for logical block n.
39
40 Todd