Skip to content

rpi-make-boot-image - Make FAT12/FAT16 images cluster-exact - #388

Merged
timg236 merged 3 commits into
masterfrom
dev/roliver/fat12_fat16_opts
Aug 14, 2026
Merged

rpi-make-boot-image - Make FAT12/FAT16 images cluster-exact#388
timg236 merged 3 commits into
masterfrom
dev/roliver/fat12_fat16_opts

Conversation

@roliver-rpi

Copy link
Copy Markdown
Contributor

No description provided.

…SIZE

Left to itself mkfs.fat picks the FAT width from the size of the device
alone, so an explicit IMAGE_SIZE of 64MB or more failed outright: at the
default one sector per cluster the resulting cluster count lies well
beyond what the chosen width can address.

Determine the width from the number of clusters the image will actually
hold, and pass that to mkfs.fat.
The 8.3 name pattern required an extension, and was matched against the
full path rather than the file name. Both caused the number of directory
entries needed for long file names to be over-estimated.
The image size was derived from a cluster count that counted the root
directory entries as data but never accounted for the root directory
area itself, which on FAT12 and FAT16 sits outside the data region, and
the number of root entries was fixed at 256 regardless of the source
files. Size the image instead from the reserved sectors, the FAT, the
root directory and the data clusters in turn, allocate it with truncate
and drop the -C option so that mkfs.fat is given an exact sector count.

Take the number of root directory entries from the source files, rounded
up to a whole sector so that the Linux vfat driver will mount the
result, and enforce a minimum data region so that very small payloads
still produce a filesystem.

FAT_OVERHEAD now specifies spare space to leave free in the filesystem
and defaults to none, rather than being an allowance for metadata that
is now accounted for exactly.
@roliver-rpi
roliver-rpi requested a review from timg236 August 7, 2026 12:56

@timg236 timg236 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@claude looks ok :)

@timg236
timg236 merged commit e50a709 into master Aug 14, 2026
1 check passed
@timg236
timg236 deleted the dev/roliver/fat12_fat16_opts branch August 14, 2026 16:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants