Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 13 Jan 2024 18:22:42 +1100
From:      Ian Smith <smithi@nimnet.asn.au>
To:        Polytropon <freebsd@edvax.de>,freebsd@dreamchaser.org
Cc:        FreeBSD Mailing List <freebsd-questions@freebsd.org>
Subject:   Re: Problem mounting new Sandisk 1TB USB drive
Message-ID:  <B01CA8C4-6F3F-451D-8332-70763C18E4FF@nimnet.asn.au>
In-Reply-To: <20240111014215.d25a19f3.freebsd@edvax.de>
References:  <746cd0fe-9de8-414b-8b5d-7030d423fa7f@dreamchaser.org> <d00f483a-5956-4d1d-bf60-13b8fa159b47@souji-thenria.net> <b47a25dd-3fde-494b-8afe-0766afbc1016@dreamchaser.org> <85758e7a-f9bb-4568-a863-53c2439045ce@souji-thenria.net> <e997f796-ea07-4fca-a483-a3de42870e6d@dreamchaser.org> <20240110233304.7a8b7f10.freebsd@edvax.de> <1d60d68a-3569-4054-a460-41c5dd422a42@dreamchaser.org> <20240111014215.d25a19f3.freebsd@edvax.de>

next in thread | previous in thread | raw e-mail | index | archive | help

Late to the 'old and stupid' party ... out of the pile, I'm responding to this one since Gary gives it as reference in his PR revival at
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=244461

On 11 January 2024 11:42:15 am AEDT, Polytropon <freebsd@edvax.de> wrote:
 > On Wed, 10 Jan 2024 16:42:22 -0700, Gary Aitken wrote:
 > > On 1/10/24 15:33, Polytropon wrote:
 > > > On Wed, 10 Jan 2024 13:03:28 -0700, Gary Aitken wrote:

(cutting mercilessly)

 > > > The stick is actually pre-formatted with exFAT.
 > > > 
 > > > Problem here: exFAT disguises itself as an NTFS partition,
 > > > but it does not have NTFS metadata and content, so ntfs-3g
 > > > cannot mount it, even though tools like gpart or fdisk
 > > > show a NTFS partition.

It's worse than that, thanks again Microsoft!  Reference: https://en.m.wikipedia.org/wiki/Partition_type

MBR partition type 7 can be IFS, HPFS (both OS/2), NTFS or ExFAT (both MS).

It's kinda understandable between HPFS and NTFS; well before FUSE there was read safely / write maybe code for both that was largely identical. I used it to read old OS/2 disks up to about FreeBSD 9.

But overlaying NTFS with ExFAT was unforgivable really ... as this thread adequately demonstrates.

 > > > So here is what you should check:
 > > > 
 > > > 1. /boot/loader.conf contains:
 > > > 
 > > > 	fuse_load="YES"

 > > # Enable FUSE functionality for exfat filesystem mounting
 > > fuse_enable="YES"
 > > fuse_load="YES"
 > 
 > THe _enable settings belong to /etc/rc.conf; /boot/loader.conf
 > uses the _load settings.

 > > > 2. Mount device manually, read-only, perform checks, then
 > > >     unmount again:
 > > > 
 > > > 	# mount.exfat -o ro /dev/da0s1 /mnt/memstick
 > > > 	# df -f /mnt/memstick
 > > > 	# ls -R /mnt/memstick
 > > > 	# umount /mnt/memstick
 
 > Should have been "df -h". :-)
 > 
 > Intention: Compare "dmesg" entry (device reporting size)
 > with filesystem size, and then compare to what's written
 > on the device itself.
 
 > > A series of mount.exfat / umount / mount.exfat on fbsd seemed to
 > > clear it up.

 > There are also fsck tools for most filesystems, and there
 > probably is one for exFAT, just in case.

sysutils/exfat-utils : exfatfsck(8)
also mkexfatfs(8), dumpexfat(8), exfatlabel(8).

 > > > NB: mount.exfat does not have a manpage or help option.
 > > 
 > > $ apropos exfat
 > > mount.exfat-fuse(8) - mount an exFAT file system

 > Okay, thanks for that pointer. It's not obvious that you
 > need the manpage of "mount.exfat-fuse" when you want to
 > know the options of "mount.exfat" though...

sysutils/fusefs-exfat is installed as mount.exfat-fuse, with a symlink for /usr/local/sbin/mount.exfat

Unfortunately there's no such link for manpage mount.exfat-fuse(8)

 > > > Why don't you simply run newfs on the stick, with the
 > > > filesystem *you* _want_ to use? You can use UFS it you
 > > > want to, works perfectly well. ;-)
 > > 
 > > I want to be able to read it from an android phone, and I was/am
 > > concerned reformatting may make it unreadable by the phone.

I was pleasantly surprised to hear that Android reads/writes exfat. I installed it for Ventoy, but can now directly write from the phone, ta! I also have some 64G USB2 sticks that become useful with exfat.

 > That's a trap to easily fall into: exFAT does not identify
 > itself as exFAT or FAT, but as NTFS, but it is not NTFS.

Nor is it HPFS (in about 7 years of OS/2 in the nineties, I can't recall losing a single file to HPFS)

~~~~~~~

To address points Gary raises in the abovementioned PR:

-> I would consider it a bug. Documenting ambiguous behavior does not make it any less of a problem.

Agreed.

-> It affects anyone who attempts to mount a usb stick with >32GB of storage.

Well, and smaller exfat media too.

-> If gpart can tell that a partition is exFAT, it should report it as such to avoid confusion

It doesn't seem like a small 'if'.

It means adding code to detect the real type in use - and there may be none before a makefs.

And it's not binary; IFS and HPFS as well.  Maybe there's some simple test to delineate between those four, some clear signature?  I don't know; you'd need to examine fsck (or analogous) code, test and present it to the gpart maintainer.

Good luck!



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?B01CA8C4-6F3F-451D-8332-70763C18E4FF>