Allocations

My ‘daily driver’ USB drive gave up the ghost recently, and after having secured a replacement1, it was time for the always-fun task of formatting. I could’ve left things as-is, but the stock partition was FAT32 with 32K block allocations. While not the end of the world, I was really hoping to set the new drive up with smaller block allocations. The previous drive was partitioned with 32K allocations, which wasn’t ideal given that I tend to keep a lot of small files around. To make a point, the largest of my blog posts is the colorful release of decolletage.vim at a whopping 12K. The directory for my blog (including all templates, server logs, boring behind-the-scenes stuff) is under 25MB, yet consumed over 90MB on the drive. This is a trivial, petty thing to be bothered by when dealing with today’s drive sizes, but it bugged me, and I was hoping to get smaller blocks on my next drive. I also wanted to stick with FAT32 as the 4GB file size limitation is meaningless to me, and exFAT just isn’t as widely supported. As far as I know, FUSE is still the only way to get exFAT support in Linux, and, well… ew. Here were my initial attempts:

Windows 10 Format Utility
Won’t do FAT32 on a 64GB drive.
CMD/DOS2 format Utility (under Windows 10)
Also won’t do FAT32 on a 64GB drive. Of course, before it gets around to yelling at you for that it yells at you for choosing too small of an allocation size. Though I think it let me get to 16K before saying no to FAT32.
Rufus
This is a neat little utility that will allow you to format large FAT32 volumes under modern versions of Windows. It will also seamlessly make the drive bootable into FreeDOS if you’d like, which is a nice perk. The lowest allocation size it seems to support is 16K, which isn’t ideal but I might’ve stuck with it just to be done. However, when I tried this, it actually formatted it with 32K blocks anyway.
macOS Disk Utility
Didn’t seem to want to do a drive of that size in FAT32.
macOS diskutil
I’m pretty sure you can force a FAT32 drive this way, but nothing in the manpages indicated that there was any way to adjust the allocation size (nor what the default was).
GParted
Seemingly no way to set allocation size. GParted, particularly in its live USB stick incarnation, is an incredibly useful tool though.
parted
GParted’s CLI pal. I started flipping through the manpages and realized that using it as a one-stop shop to handle partitioning and filesystem creation is discouraged, and didn’t get around to finding out whether or not adjusting allocation size was even a possibility. Didn’t seem worth it.

So, this was discouraging. I figured I’d try one last-ditch effort, fussing around with tools I haven’t touched for… likely a decade: fdisk and mkfs. parted was essentially asking me to do the same thing – start with it and finish off with mkfs, and that may have been a smoother, less arcane process. I mean, starting up fdisk greets you with

Command (m for help):

Because of course ’m’ means help. Not that there’s an ‘h’ command. Anyway. fdisk or parted just handles the partitioning bit, and I probably didn’t need to do that again since I had already reformatted the thing several times with unsatisfactory FAT32 partitions, but I opted to clear the thing out anyway. The juicy bit is using mkfs.fat, and explicitly specifying -F 32 to ensure FAT32 and -s 16 which was a lucky-ish guess, giving me 8K blocks. Even reading the manpage, it’s tricky figuring out how -s and -S interact – -S 4096 -s 1 left me with a broken filesystem, but ignoring -S and guessing at -s got me to a happy place.

It’s probably a good thing that disk partitioning and formatting utilities are becoming more streamlined, though I think the mainstream OSes pushing folks to exFAT for large removable media is bound to lead to trouble. I sure didn’t need to go through all of this trouble to set up a small allocation size; I would’ve been fine with how the thing came, or how Rufus formatted it. It’s likely for the best that things like that aren’t generally exposed to users. But it’s worth noting that if you do want to do something funky, the old tools are there and they work.


  1. The old stick was a Transcend JetFlash unit that died after about 2 years. I’ve replaced it with a Corsair Flash Voyager Vega. I cannot speak to the Vega’s longevity yet (obviously), but I can say that the physical design is superior in every way: the metal feels sturdier (the aluminum had deformed and been reshaped a few times on the Transcend), the metal is grippier, there’s an activity light, and the bit that sticks out is raised just enough more to make it easy to pull from the port. Oh, and it also fits the port properly. I’ve been happy with other Corsair products, hoping this proves to be a winner. ↩︎
  2. There’s also a PowerShell formatting command or module or whatever the heck you call the things that you type into PowerShell. But PowerShell is the closest thing I have to evidence that hell is real, so… thank u, next. ↩︎