Skip to content

Conversation

@tsunghanliu
Copy link

@tsunghanliu tsunghanliu commented Jan 16, 2025

When the ESP partition is 256MB and the disk is using 4K sector size, mkfs.fat will prompt:

WARNING: Number of clusters for 32 bit FAT is less than suggested minimum.

Based on the implementation, the data area (i.e., without FAT32 header, reserved sectors and alignments/offset) should be larger than 65525 sectors. Therefore, 256MB is not enough for disks using 4K sector size.

Use truncate -s $((65696*4096)) part.bin; mkfs.fat -F 32 -S 4096 -v part.bin to verify if the sector number is enough. By giving different FAT settings, the necessary size might by changed.

For better compatibility and increasing 4MB doesn't consume a lot of disk space, it'd be good to have a bigger ESP partition.

Reference:
[1] mkfs.fat - https://github.com/dosfstools/dosfstools/blob/master/src/mkfs.fat.c
[2] https://superuser.com/questions/1702331/what-is-the-minimum-size-of-a-4k-native-partition-when-formatted-with-fat32

Choose a reason for hiding this comment

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

To allow upgrades of gadget in older images, you could do:

min-size: 256M
size: 260M

This will specify a valid range of sizes for upgrades, but new images will use the size field.

Copy link
Author

Choose a reason for hiding this comment

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

Thanks Alfonso! I've updated the commit.

When the ESP partition is 256MB and the disk is using 4K sector size,
mkfs.fat will prompt:
> WARNING: Number of clusters for 32 bit FAT is less than suggested minimum.

Based on the implementation, the data area (i.e., **without** FAT32 header,
reserved sectors and alignments/offset) should be larger than 65525 sectors.
Therefore, 256MB is not enough for disks using 4K sector size.

Use `truncate -s $((65696*4096)) part.bin; mkfs.fat -F 32 -S 4096 -v
part.bin` to verify if the sector number is enough. By giving different FAT
settings, the necessary size might by changed.

For better compatibility and increasing 4MB doesn't consume a lot of
disk space, it'd be good to have a bigger ESP partition.

Reference:
[1] mkfs.fat - https://github.com/dosfstools/dosfstools/blob/master/src/mkfs.fat.c
[2] https://superuser.com/questions/1702331/what-is-the-minimum-size-of-a-4k-native-partition-when-formatted-with-fat32

Signed-off-by: Robert Liu <[email protected]>
@tsunghanliu tsunghanliu force-pushed the increase-esp-partition branch from 481e251 to 65d4894 Compare February 13, 2025 05:53
Copy link
Member

@alfonsosanchezbeato alfonsosanchezbeato left a comment

Choose a reason for hiding this comment

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

LGTM

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