Author Topic: Why so much dead space in FAT32 ?  (Read 1041 times)

0 Members and 1 Guest are viewing this topic.

Offline Dan MoosTopic starter

  • Frequent Contributor
  • **
  • Posts: 357
  • Country: us
Why so much dead space in FAT32 ?
« on: April 03, 2022, 11:42:07 pm »
I'm adding FAT 32 SD card support   to my home brew computer, and I'm struck by the apparently wasted space on a FAT32 formatted SD card.

Their are 8192 512 byte sectors until the first partition boot sector on the card I'm currently working with. after that there are 2420 "reserved sectors until the FAT itself.
I realize that on an SD card with tens of gigs of space, this isn't that much, but it still seems wasteful.

Why is it like this?
 

Offline Berni

  • Super Contributor
  • ***
  • Posts: 5023
  • Country: si
Re: Why so much dead space in FAT32 ?
« Reply #1 on: April 04, 2022, 05:48:19 am »
There are many ways to format a SD card. If you have a partition table with unused space in it, that might be the fault of the utility used to create the partition. Some filesystems also want to be in neat multiples of size so sometimes you also get some unused space on the end of the disk too.

There are also some legacy reasons for keeping certain offsets to make sure it is compatible with old PCs. We unfortunately picked up a lot of legacy baggage with it so FAT32 is a pretty crappy filesystem these days. The exFAT is a modern version of it that fixes most of its flaws, but Microsoft is being bitchy about patents on that one too.
 

Offline magic

  • Super Contributor
  • ***
  • Posts: 7181
  • Country: pl
Re: Why so much dead space in FAT32 ?
« Reply #2 on: April 04, 2022, 06:00:29 am »
Appendix C of the SD Filesystem Specification answers all your questions and then some you don't even know you have.

Download it because it's a leaked pirate PDF ;)
https://dokumen.pub/sd-specifications-part-2-file-system-specification-version-300.html

BTW, there are cameras that actually enforce this layout. If you plug a differently formatted card, they will complain and say it cannot be used for recording. I follow those guidelines when formatting SD cards for best performance and compatibility with equipment.
« Last Edit: April 04, 2022, 06:05:59 am by magic »
 

Online ejeffrey

  • Super Contributor
  • ***
  • Posts: 3884
  • Country: us
Re: Why so much dead space in FAT32 ?
« Reply #3 on: April 04, 2022, 06:09:58 am »
The space before the partition boot record is nothing to do with the filesystem and everything to do with the tool that produced the MBR.  There have been a number of weird factors that go into that.  Extremely old tools would insist that every partition start on a cylinder boundary.  Since MBR is the first sector of the first cylinder the rest of that cylinder would be empty.  Obviously CHS addressing is long obsolete but LBA partitioning tools often set their own alignments. Modern systems also often want to align filesystems on larger allocation boundaries such as flash erase groups, or SMR groups.  This can create weird gaps.

I'm not sure whether the gap between the PBR and the first sector of the filesystem is a requirement of the filesystem or just chosen by the tool that created it, but I'd guess similar reasons apply
 

Offline Gyro

  • Super Contributor
  • ***
  • Posts: 9921
  • Country: gb
Re: Why so much dead space in FAT32 ?
« Reply #4 on: April 04, 2022, 09:27:41 am »
This is probably a naive suggestion, but hopefully you're aware of the SD Association card formatter. Presumably this formats cards optimally...

https://www.sdcard.org/downloads/formatter/
Best Regards, Chris
 

Offline fchk

  • Frequent Contributor
  • **
  • Posts: 255
  • Country: de
Re: Why so much dead space in FAT32 ?
« Reply #5 on: April 04, 2022, 11:28:35 am »
Why is it like this?

The default logical block size is 512 byte. The underlying physical block sizes for writing and erasing of the underlying flash memory however are much larger, 4k up to 128k. In order to get the best performance and the least amound of wear partitions should start on a physical block boundary. The reserved space ensures this even for quite big ease blocks.

In the early days the first partition would start at C0 H1 S1, which translates to LBA 63. This is an odd address and caused a huge performance loss when hard disks with internal 4k sectors came out, and it is even worse for SSDs.

fchk
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf