Bug 240998

Summary: gpart(8) detects exFAT fs as MBR
Product: Base System Reporter: Slawomir Wojciech Wojtczak <vermaden>
Component: binAssignee: freebsd-bugs (Nobody) <bugs>
Status: Closed Not A Bug    
Severity: Affects Many People CC: ae
Priority: ---    
Version: 12.1-RELEASE   
Hardware: Any   
OS: Any   

Description Slawomir Wojciech Wojtczak 2019-10-02 08:37:50 UTC
On /dev/md2 I created exFAT filesystem (on whole device).



The gpart(8) tool interprets (incorrectly) that as MBR:

# gpart show md2
=>     63  2097089  md2  MBR  (1.0G)
       63  2097089       - free -  (1.0G)



The fstyp(8) tool correctly shows its exFAT:

# fstyp -u /dev/md2
exfat



For the record file(1) is also wrong:

# file -s /dev/md2
/dev/md2: DOS/MBR boot sector




Regards,
vermaden
Comment 1 Slawomir Wojciech Wojtczak 2019-10-02 08:38:04 UTC
This is on 12.1-BETA2 system.
Comment 2 Andrey V. Elsukov freebsd_committer freebsd_triage 2019-10-02 09:50:35 UTC
gpart(8) is used to manage partition tables. exFAT is filesystem, not a partition table.
Comment 3 Slawomir Wojciech Wojtczak 2019-10-02 10:17:02 UTC
But its a lie, its not a MBR partition table there = bug.
Comment 4 Andrey V. Elsukov freebsd_committer freebsd_triage 2019-10-02 10:24:01 UTC
exFAT filesystem has boot sector, that contains MBR's signature:
http://elm-chan.org/docs/exfat_e.html

When you create exFAT filesystem on a raw disk, it automatically creates MBR partition table.
Comment 5 Slawomir Wojciech Wojtczak 2019-10-02 11:06:14 UTC
So gpart should show exFAT/MBR label then?
Comment 6 Conrad Meyer freebsd_committer freebsd_triage 2019-10-02 20:33:56 UTC
+1 to everything ae@ has already mentioned.

exFAT (FAT in general) has a DOS MBR boot block at the beginning of the filesystem image.  gpart is for managing partitions.

I understand the confusion, but printing "MBR" when an MBR header is present is a broadly reasonable interpretation of a FAT filesystem header by a tool looking for MBR or GPT partitions.  I'd suggest not putting filesystems on unpartitioned disks, or just not invoking gpart on unpartitioned disks.

file(1) is contrib code, there's some upstream a bug can be reported at.
Comment 7 Slawomir Wojciech Wojtczak 2019-10-02 21:02:34 UTC
Ok, your system, your choice.

Regards,
vermaden