fix: accept blocksize=4096 in fat32.Read for 4k native block devices#320
Merged
deitch merged 1 commit intodiskfs:masterfrom Dec 23, 2025
Merged
Conversation
When go-diskfs opens a 4k native block device, it detects the logical block size as 4096 from the OS and passes this to fat32.Read(). However, the validation was rejecting any blocksize other than 0 or 512, causing 'unknown filesystem' errors. This is a follow-up to PR diskfs#316 which added support for reading FAT32 filesystems with bytesPerSector=4096 from the BPB, but didn't update the blocksize validation. The blocksize parameter is only used for validation; the actual bytesPerSector is always read from the BPB. Fixes reading VFAT filesystems on 4k native disks when opened as block devices (e.g., /dev/vda1). Also fix the write code for 4k disks. Signed-off-by: Noel Georgi <git@frezbo.dev>
Contributor
Author
|
To see the 4k failure we need an actual loop device or block device. |
deitch
approved these changes
Dec 23, 2025
Collaborator
|
Looks good, thank you. |
jfroy
added a commit
to jfroy/go-diskfs
that referenced
this pull request
Apr 21, 2026
This patch allows creating FAT32 filesystems with 4K block size. This is intended to create UEFI System Partitions (ESPs) on NVME namespaces with a 4Kn format. This is a follow-up to PR diskfs#320 which added support for reading FAT32 filesystems with 4K block size. Signed-off-by: Jean-Francois Roy <jf@devklog.net> Assisted-by: Claude:claude-opus-4-7
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When go-diskfs opens a 4k native block device, it detects the logical block size as 4096 from the OS and passes this to fat32.Read(). However, the validation was rejecting any blocksize other than 0 or 512, causing 'unknown filesystem' errors.
This is a follow-up to PR #316 which added support for reading FAT32 filesystems with bytesPerSector=4096 from the BPB, but didn't update the blocksize validation. The blocksize parameter is only used for validation; the actual bytesPerSector is always read from the BPB.
Fixes reading VFAT filesystems on 4k native disks when opened as block devices (e.g., /dev/vda1).
Also fix the write code for 4k disks.