Page 1 of 1

mkfs.vfat creates multiple MBR signatures

Posted: Thu Dec 24, 2015 8:45 am
by mindentropy
I am trying to read from a FAT32 file system in my OS and I am faced with the following problem:

I am creating a FAT32 partition from a file image.

My commands are as follows:
Create a 2MB file image.

Code: Select all

dd if=/dev/zero of=fatfs.img bs=1024 count=2048
To create the filesystem I use:

Code: Select all

mkfs.vfat -n "Test volume" -F 32 -v fatfs.img
When I open the fatfs.img in a hex editor I see boot signatures 0x55 0xAA in the first 512 bytes. The offset from 0x1BE i.e. the partition table data entry is empty. I see 3 more 0x55 0xAA signatures at 512 byte offsets. What seems to be wrong? I see the same MBR repeated after 3072 bytes.

Re: mkfs.vfat creates multiple MBR signatures

Posted: Thu Dec 24, 2015 8:50 am
by Octocontrabass
mindentropy wrote:The offset from 0x1BE i.e. the partition table data entry is empty.
Why would there be a partition table? You didn't partition your (virtual) disk.
mindentropy wrote:I see 3 more 0x55 0xAA signatures at 512 byte offsets. [...] I see the same MBR repeated after 3072 bytes.
This is normal. Refer to Microsoft's FAT32 specification for details.

Re: mkfs.vfat creates multiple MBR signatures

Posted: Thu Dec 24, 2015 11:14 am
by mindentropy
Thanks for the help. Got it that I have not made a partition.

In the Microsoft FAT32 specification I got it that there is a backup boot sector BPB_BkBootSec which equals 6 which is 3072 which is what I have observed.

The only problem now that I see is that in the specification the FAT32 boot sector is three 512-byte sectors long. What I see is only two 512 bytes ending with the 0xAA55 signature. What seems to be wrong here?

Re: mkfs.vfat creates multiple MBR signatures

Posted: Fri Dec 25, 2015 1:40 am
by Octocontrabass
Microsoft's FAT32 boot code is 3 sectors long, but FAT32 boot code from other developers may be longer or shorter.