Solved How to mount fat32lba?

I recently acquired a cool usb stick with usb type c on one end and usb type a on the other;
I figured I could use it to conveniently copy some files from my phone to bsd;

Code:
sudo pkg install exfat-utils fusefs-exfat fusefs-ntfs

I have fusefs loaded:
Code:
sudo kldstat
Id Refs Address                Size Name
 1  129 0xffffffff80200000  1d34598 kernel
 2    1 0xffffffff81f35000   5d51c8 zfs.ko
 3    1 0xffffffff8250c000    1c3a8 geom_eli.ko
 4    1 0xffffffff833f9000   11e630 nvidia-modeset.ko
 5    1 0xffffffff83600000  33a5358 nvidia.ko
 6    2 0xffffffff83518000    31a10 linux.ko
 7    6 0xffffffff8354a000     be70 linux_common.ko
 8    1 0xffffffff83556000     3390 acpi_wmi.ko
 9    1 0xffffffff8355a000     3250 ichsmb.ko
10    1 0xffffffff8355e000     2178 smbus.ko
11    1 0xffffffff83561000    93260 if_iwlwifi.ko
12    1 0xffffffff835f5000     5f00 ig4.ko
13    1 0xffffffff869a6000    2dc30 linux64.ko
14    1 0xffffffff835fb000     2278 pty.ko
15    1 0xffffffff869d4000     3558 fdescfs.ko
16    1 0xffffffff869d8000     73c0 linprocfs.ko
17    1 0xffffffff869e0000     440c linsysfs.ko
18    1 0xffffffff869e5000     3360 uhid.ko
19    1 0xffffffff869e9000     4364 ums.ko
20    1 0xffffffff869ee000     33c0 usbhid.ko
21    6 0xffffffff869f2000     3380 hidbus.ko
22    1 0xffffffff869f6000     e5ac snd_uaudio.ko
23    1 0xffffffff86a05000     3360 wmt.ko
24    1 0xffffffff86a09000     4d20 ng_ubt.ko
25    3 0xffffffff86a0e000     abb8 netgraph.ko
26    2 0xffffffff86a19000     a250 ng_hci.ko
27    2 0xffffffff86a24000     2670 ng_bluetooth.ko
28    1 0xffffffff86a27000     3218 iichid.ko
29    1 0xffffffff86a2b000     21e8 hms.ko
30    1 0xffffffff86a2e000     30a8 hidmap.ko
31    1 0xffffffff86a32000     3355 hmt.ko
32    1 0xffffffff86a36000     22cc hconf.ko
33    1 0xffffffff86a39000    12e08 fusefs.ko

Code:
gpart show /dev/da0
=>       63  120176577  da0  MBR  (57G)
         63       1985       - free -  (993K)
       2048  120174559    1  fat32lba  (57G)
  120176607         33       - free -  (17K)

It looked like everything was in order so I tried to mount the partition:

Code:
sudo mount -v -t vfat /dev/da0s1 ./mnt
mount: /dev/da0s1: Invalid fstype: Invalid argument
zroot/ROOT/default on / (zfs, local, noatime, nfsv4acls, fsid af253d1ade9720a3, vnodes: count 243017 )

Code:
sudo mount -v -t msdos /dev/da0s1 ./mnt
mount_msdosfs: /dev/da0s1: Invalid argument
zroot/ROOT/default on / (zfs, local, noatime, nfsv4acls, fsid af253d1ade9720a3, vnodes: count 243017 )

Code:
sudo mount -v -t msdosfs /dev/da0s1 ./mnt
mount_msdosfs: /dev/da0s1: Invalid argument
zroot/ROOT/default on / (zfs, local, noatime, nfsv4acls, fsid af253d1ade9720a3, vnodes: count 243018 )

Originally, I tried to format the drive using gpart manually:
Code:
sudo gpart create -s mbr /dev/da0
sudo gpart add -t fat32 -a 1m -s 10G /dev/da0

but the phone wasn't able to mount the partition, so I wiped the drive and the phone automatically formatted it.

Am I missing something obvious here like fat32lba not being supported on freebsd , or something?
 
How big is the stick?

I normally create large MSDOS fses by letting my Canon camera format it. Just too many variants.
 
Hmmm, I installed kde plasma and tried used the gui 'automount' option, and it worked for some reason;

according to the output of mount:

Code:
/dev/da0s1 on /media/SanDisk_Dual_Drive_04011f7ab7456add15b0930c7662095cc514bf074b0b524a313c287a37632fe4156000000000000000000000967e47ebff8d8418ab558107492918a6_s1 (fusefs)

So I started looking through fusefs related pages and found this:


but unfortunately:


Code:
sudo mount_fusefs -v -s /dev/da0s1 -m ~/mnt
mounting fuse daemon on device /dev/da0s1
mount_fusefs: /dev/da0s1 on /usr/home/c/mnt: Device not configured

I wonder what kde does that makes this work.
 
You have a usb stick?
in kde you can copy files to stick? and test with other devices?
Its not related to fusefs. you not need to installing any package or something else.
 
After formatting, You should create file system on it:

newfs_msdos /dev/da0s1

after this you can mount it:
mount_msdosfs /dev/da0s1 /media
OMG you're right!
I can't believe I forgot to create a filesystem on it the first time!

I got it to work:


Code:
[c@bsdpc]> sudo gpart destroy -F /dev/da0
da0 destroyed
[c@bsdpc]> sudo gpart create -s mbr /dev/da0
da0 created
[c@bsdpc]> sudo gpart add -t fat32 -a 1m -s 10G /dev/da0
da0s1 added
[c@bsdpc]> sudo newfs_msdos /dev/da0s1
/dev/da0s1: 20966336 sectors in 327599 FAT32 clusters (32768 bytes/cluster)
BytesPerSec=512 SecPerClust=64 ResSectors=32 FATs=2 Media=0xf0 SecPerTrack=63 Heads=255 HiddenSecs=0 HugeSectors=20971520 FATsecs=2560 RootCluster=2 FSInfo=1 Backup=2
[c@bsdpc]> sudo mount -t msdosfs /dev/da0s1 ./mnt
 
Originally you showed the stick having (coming with?) a 57G fat32lba slice, using the whole stick:

Code:
gpart show /dev/da0
=>       63  120176577  da0  MBR  (57G)
         63       1985       - free -  (993K)
       2048  120174559    1  fat32lba  (57G)
  120176607         33       - free -  (17K)

Perhaps that only failed because you tried mounting it as "-t vfat" which failed as 'Invalid fstype'. Is type "vfat" a Linux thing?

But later, after destroying and creating it a time or two:

OMG you're right!
I can't believe I forgot to create a filesystem on it the first time!

Looks like it came as msdosfs, type fat32lba, which may be needed for greater than 32G.

I got it to work:

Code:
[c@bsdpc]> sudo gpart destroy -F /dev/da0
da0 destroyed
[c@bsdpc]> sudo gpart create -s mbr /dev/da0
da0 created
[c@bsdpc]> sudo gpart add -t fat32 -a 1m -s 10G /dev/da0
da0s1 added
[c@bsdpc]> sudo newfs_msdos /dev/da0s1
/dev/da0s1: 20966336 sectors in 327599 FAT32 clusters (32768 bytes/cluster)
BytesPerSec=512 SecPerClust=64 ResSectors=32 FATs=2 Media=0xf0 SecPerTrack=63 Heads=255 HiddenSecs=0 HugeSectors=20971520 FATsecs=2560 RootCluster=2 FSInfo=1 Backup=2
[c@bsdpc]> sudo mount -t msdosfs /dev/da0s1 ./mnt

If you use 'gpart show -r ~/mnt' (-r shows raw partition type) you'll see '!11' for fat32. If instead you use 'gpart add -t fat32lba' you'll see '!12'.

What you have is fine for 10G, but over 32G you likely need fat32lba. newfs_msdosfs works the same but with lba layout is less limited.

Using exFAT is another option; you can use any size stick for the first slice, the only one Android will use. It's worked well for me so far.
 
Originally you showed the stick having (coming with?) a 57G fat32lba slice, using the whole stick:



Perhaps that only failed because you tried mounting it as "-t vfat" which failed as 'Invalid fstype'. Is type "vfat" a Linux thing?

But later, after destroying and creating it a time or two:



Looks like it came as msdosfs, type fat32lba, which may be needed for greater than 32G.



If you use 'gpart show -r ~/mnt' (-r shows raw partition type) you'll see '!11' for fat32. If instead you use 'gpart add -t fat32lba' you'll see '!12'.

What you have is fine for 10G, but over 32G you likely need fat32lba. newfs_msdosfs works the same but with lba layout is less limited.

Using exFAT is another option; you can use any size stick for the first slice, the only one Android will use. It's worked well for me so far.
Hmmm, quite possible. I mean since the system recognizes the lba variant it is likely that mounting it should be supported. I'm at the Vulkanised conference right now, so I don't have my bsd box with me, but when I return I
will definitely get back to you on that.
 
Okay, so I plugged in the usb stick into my phone, and formatted it;
Looking at its contents from the pc again, I see this:
Code:
[c@bsdpc]> gpart show /dev/da2
=>       63  120176577  da2  MBR  (57G)
63       1985       - free -  (993K)
2048  120174559    1  fat32lba  (57G)
120176607         33       - free -  (17K)

[c@bsdpc]> gpart show -r /dev/da2
=>       63  120176577  da2  MBR  (57G)
63       1985       - free -  (993K)
2048  120174559    1  12  (57G)
120176607         33       - free -  (17K)

As per your suggestion, I've added the '-r' option and we can see '12' as expected;
Although I agree, the 'vfat' type is probably a linux thing, I did try other filesystems, as well, If you look at the first post;
I suspect, however, that perhaps the phone creates the partition, but not the filesystem on it.
To confirm this, I will try creating the fs manually:
Code:
[c@bsdpc]> sudo newfs_msdos /dev/da2s1
Password:
/dev/da2s1: 120145152 sectors in 1877268 FAT32 clusters (32768 bytes/cluster)
BytesPerSec=512 SecPerClust=64 ResSectors=32 FATs=2 Media=0xf0 SecPerTrack=63 Heads=255 HiddenSecs=0 HugeSectors=120174559 FATsecs=14667 RootCluster=2 FSInfo=1 Bac
kup=2

It looks like that didn't report any errors. Let's try mounting again:
Code:
[c@bsdpc]> sudo mount -t msdosfs /dev/da2s1 ./desktop/mnt
[c@bsdpc]>

I think that worked! But before we celebrate, let's try copying something to and from the phone.
Something bigger than 4Gs, to be more specific;
I wish I still had that win11 iso around, oh well; we'll do it manually!
Code:
[c@bsdpc]> cd desktop/mnt/
[c@bsdpc]> touch hello_world.txt
[c@bsdpc]> dd if=/dev/random of=./hello_world.txt bs=1M count=5120
dd: ./hello_world.txt: File too large
4096+0 records in
4095+1 records out
4294967295 bytes transferred in 96.426015 secs (44541582 bytes/sec)

I guess we have our answer; It seems that 4G is still a limit on fat32lba partitions when using them with newfs_msdos;
Luckily, from what I understand, exfat comes to the rescue. So I will try erasing the usb contents,
and creating an exfat filesystem:
Code:
[c@bsdpc]> rm hello_world.txt
[c@bsdpc]> cd ~/desktop/
[c@bsdpc]> sudo umount ./mnt
[c@bsdpc]> sudo gpart destroy -F /dev/da2
Password:
da2 destroyed
[c@bsdpc]> sudo gpart create -s mbr /dev/da2
da2 created
[c@bsdpc]> sudo gpart add -t fat32lba -s 57G /dev/da2
da2s1 added
[c@bsdpc]> sudo /usr/local/sbin/mkfs.exfat /dev/da2s1
mkexfatfs 1.4.0
Creating... done.
Flushing... done.
File system created successfully.
[c@bsdpc]> sudo kldload fusefs
[c@bsdpc]> sudo mount.exfat-fuse /dev/da2s1 ./mnt
FUSE exfat 1.4.0 (libfuse2)
[c@bsdpc]> cd mnt/
[c@bsdpc]> touch hello_world.txt
[c@bsdpc]> dd if=/dev/random of=./hello_world.txt bs=1M count=5120
5120+0 records in
5120+0 records out
5368709120 bytes transferred in 485.501388 secs (11058072 bytes/sec)
[c@bsdpc]> sudo umount ./mnt
Password:
[c@bsdpc]>

It looks like it worked this time. Hurray! Let's see if the phone detects the stick...
Yessss, It does, and I can even try to open the suspicious hello_world.txt file, but of course the phone says the size is too large. I've deleted it. Okay, just to make sure, I'm going to try to copy a pdf from my phone to the pc, and see if that works, as well.
It works, this is fantastic.

Summing up, the problem was caused by the ambiguous nature of the terms used by the phone.
The phone claimed to have formatted the stick, but mounting the partition would fail.
The reason for this was that the phone only created a partition, but not a filesystem on it.
Creating a filesystem manually, resolved the problem.
In addition to this, it seems that in order to be able to manipulate files over 4Gs in size on a fat32lba partition, the filesystem type must be exfat, or newer. This can be accomplished by manually creating the partitioning scheme as shown above.
Also, probably worth mentioning that you'll need the following:
exfat-utils fusefs-exfat fuse;
 
You can't always be certain that gpart show is correct.

Sometimes is worth runnng file -s /dev/da0s1.
Interestingly, if I format the usb stick using my phone:
Code:
[c@bsdpc]> gpart show /dev/da2
=>       63  120176577  da2  MBR  (57G)
         63       1985       - free -  (993K)
       2048  120174559    1  fat32lba  (57G)
  120176607         33       - free -  (17K)
[c@bsdpc]> sudo file -s /dev/da2
Password:
/dev/da2: DOS/MBR boot sector; partition 1 : ID=0xc, start-CHS (0x1,0,1), end-CHS (0x3ff,254,63), startsector 2048, 120174559 sectors, extended partition table (last)
[c@bsdpc]> sudo file -s /dev/da2s1
/dev/da2s1: DOS/MBR boot sector
[c@bsdpc]> sudo /usr/local/sbin/mkfs.exfat /dev/da2s1
mkexfatfs 1.4.0
Creating... done.
Flushing... done.
File system created successfully.
[c@bsdpc]> sudo file -s /dev/da2
/dev/da2: DOS/MBR boot sector; partition 1 : ID=0xc, start-CHS (0x1,0,1), end-CHS (0x3ff,254,63), startsector
2048, 120174559 sectors, extended partition table (last)
[c@bsdpc]> sudo file -s /dev/da2s1
/dev/da2s1: DOS/MBR boot sector

Since the output of the 'file' command is the same before and after setting up the 'exfat' filesystem manually,
perhaps the problem is that the filesystem was exfat all along, which could be the reason why I wasn't able to mount the drive using the msdosfs mount type.

To confirm this 'hypothesis' I will format the stick again via phone, but this time I will try to mount it using fuse-exfat straight away:
Code:
[c@bsdpc]> gpart show /dev/da2
=>       63  120176577  da2  MBR  (57G)
         63       1985       - free -  (993K)
       2048  120174559    1  fat32lba  (57G)
  120176607         33       - free -  (17K)

[c@bsdpc]> sudo file -s /dev/da2
/dev/da2: DOS/MBR boot sector; partition 1 : ID=0xc, start-CHS (0x1,0,1), end-CHS (0x3ff,254,63), startsector 2048, 120174559 sectors, extended partition table (last)
[c@bsdpc]> sudo file -s /dev/da2s1
/dev/da2s1: DOS/MBR boot sector
[c@bsdpc]> sudo mount.exfat-fuse /dev/da2s1 ~/desktop/mnt
FUSE exfat 1.4.0 (libfuse2)
[c@bsdpc]>

Well, that would confirm it ?
Summing up, the problem was caused by the ambiguous nature of the terms used by the phone.
The phone claimed to have formatted the stick, but mounting the partition would fail.
The reason for this was that the phone only created a partition, but not a filesystem on it.
I stand corrected, the phone did in fact create a filesystem, but not the one I was expecting.
It created the exfat filesystem, meanwhile I was trying to mount it specifying msdosfs.
Well, that is good to know for the future, I guess.
 
let's try copying something to and from the phone.
Something bigger than 4Gs, to be more specific;
Code:
[c@bsdpc]> cd desktop/mnt/
[c@bsdpc]> touch hello_world.txt
[c@bsdpc]> dd if=/dev/random of=./hello_world.txt bs=1M count=5120
dd: ./hello_world.txt: File too large
4096+0 records in
4095+1 records out
4294967295 bytes transferred in 96.426015 secs (44541582 bytes/sec)

I guess we have our answer; It seems that 4G is still a limit on fat32lba partitions when using them with newfs_msdos;

No, 4GiB is the absolute limit on file size on any type of FAT (12, 16, 32, 32lba) filesystem. The limit is the largest 32-bit integer. [edit: actually 4GiB-1 = 0xffffffff]
ExFAT and others like NTFS, EXT*, and of course UFS and ZFS allow far larger flles.
 
Back
Top