Check cluster size of FAT32 disk in Linux by Josh Sherman

Related Articles

After getting into retro gaming using the Anbernic RG35XX and PowKiddy v90, I decided it was time to dust off my old Nintendo 3DS XL and get it a little more battle ready to do some retro gaming. Part of the spring cleaning was to upgrade the memory card from the 32GB card I was using, to the 256GB card I had laying around, which I originally had in my v90.

Worth noting, the 256GB card was simply overkill on the v90, mainly because of how long it would take to scan the disk after a crazy shutdown sequence. Moving to a 64GB card lowered the scan time significantly, while still allowing enough room for things the v90 was capable of playing.

Ok, to upgrade my 3DS SD card I went and backed it up, formatted the new card and transferred the files to it. piece of cake.

However, after putting the card back in and booting up, it was very slow to boot compared to the other memory card. After some research, what I experienced was expected behavior for the 3DS when using a larger SD card. I guess that makes sense, the card is 8x bigger, and I guess the 3DS has to do a scan or something.

Regardless of the slowdown, I’m happy with the decision to throw some more memory in there, and the lag is only a few seconds, and launching the game from the SD card with no noticeable issues.

However, I did a little more research and read that if you use a larger card, you need to make sure the card is formatted for 32kb per cluster, otherwise things will be slow.

Well, things were slow for me, so obviously my card wasn’t formatted correctly.

Before I hastily reformatted the card and started over, I decided to figure out how to tell what cluster size the card was set to. To do this, you must use dosfsck command with the following arguments:

  • -v – literal output, otherwise you won’t get the cluster value
  • -n – Mode without activation, because we just want information, not to mess with the card

Concatenating these arguments with the path to the FAT32 disk, replace
mmcblk0p1 With the path on your system:

% sudo dosfsck -v -n /dev/mmcblk0p1
fsck.fat 4.2 (2021-01-31)
Checking we can access the last sector of the filesystem
There are differences between boot sector and its backup.
This is mostly harmless. Differences: (offset:original/backup)
  Not automatically fixing this.
Boot sector contents:
System ID "mkfs.fat"
Media byte 0xf8 (hard disk)
       512 bytes per logical sector
     32768 bytes per cluster
        64 reserved sectors
First FAT starts at byte 32768 (sector 64)
         2 FATs, 32 bit entries
  31293440 bytes per FAT (= 61120 sectors)
Root directory start at cluster 2 (arbitrary size)
Data area starts at byte 62619648 (sector 122304)
   7821417 data clusters (256292192256 bytes)
16 sectors/track, 4 heads
      2048 hidden sectors
 500692992 sectors total
FATs differ but appear to be intact.
  Using first FAT.
Checking for unused clusters.
Dirty bit is set. Fs was not properly unmounted and some data may be corrupt.
 Automatically removing dirty bit.
Checking free cluster summary.

Leaving filesystem unchanged.
/dev/mmcblk0p1: 704 files, 186552/7821417 clusters

If you look closely, you can find the cluster size, or you can just pipe the output to grep to make something less noisy:

% sudo dosfsck -v -n /dev/mmcblk0p1 | grep 'bytes per cluster'
     32768 bytes per cluster

Will you look at this, it turns out my card is already designed to use a 32kb cluster size. It turns out that this is by far the default cluster size for most disk utilities, so it looks like you might have to go out of your way to set it to something other than 32kb.

good things? want more?

Weekly emails about technology, development and sometimes sauerkraut.

100% Fresh, Grade A Content, Never Spam.


Popular Articles