Bug 205154

Summary: newfs_msdos issue
Product: Base System Reporter: RueiChang <k5867568>
Component: binAssignee: freebsd-fs (Nobody) <fs>
Status: Closed Not Accepted    
Severity: Affects Only Me CC: Ultima1252, bcr, damjan.jov, gonzo
Priority: ---    
Version: CURRENT   
Hardware: arm   
OS: Any   

Description RueiChang 2015-12-09 09:39:07 UTC
Hi, my name is Ruei. May I ask a question to you? I found newfs_msdos command is doing format operation.
However, I took a 80GB storage and a 150GB storage to format in Fat32, it always only work in 80GB. 150GB always be damaged storage.
    My command: newfs_msdos -F 32 -O android -c 8 storage_path
        Is there have any problem in my command? Looking forward to hearing from you soon. Thank you.
Comment 1 Benedict Reuschling freebsd_committer freebsd_triage 2016-04-03 19:23:29 UTC
Over to filesystem folks, maybe you can help with this.
Comment 2 Ultima 2016-04-03 20:18:20 UTC
(In reply to RueiChang from comment #0)
 Can you explain a bit more in depth what "damaged storage" is please? Is it not mountable? data corrupted? Details will help greatly.
Comment 3 RueiChang 2018-04-11 10:22:43 UTC
Sorry, it been a long time. This issue I forgot how to fix.
Thanks for your reply.
Comment 4 Damjan Jovanovic 2018-04-28 07:46:36 UTC
Both 80GiB and 150GiB files seem to work within FreeBSD CURRENT:


# dd if=/dev/zero of=80G seek=$((80*1024*1024*1024-1)) count=1 bs=1
# newfs_msdos -F 32 -O android -c 8 ./80G
newfs_msdos: warning, ./80G is not a character device
./80G: 167445080 sectors in 20930635 FAT32 clusters (4096 bytes/cluster)
BytesPerSec=512 SecPerClust=8 ResSectors=32 FATs=2 Media=0xf0 SecPerTrack=63 Heads=255 HiddenSecs=0 HugeSectors=167772160 FATsecs=163521 RootCluster=2 FSInfo=1 Backup=2
# file 80G
80G: DOS/MBR boot sector, code offset 0x58+2, OEM-ID "android ", sectors/cluster 8, sectors/track 63, heads 255, FAT (32 bit), sectors/FAT 163521, serial number 0x432c1018, unlabeled
# fsck_msdosfs ./80G 
** ./80G
** Phase 1 - Read and Compare FATs
** Phase 2 - Check Cluster Chains
** Phase 3 - Checking Directories
** Phase 4 - Checking for Lost Files
1 files, 4030760 free (20930634 clusters)
# mdconfig -a -f 80G
md0
# mount -t msdosfs /dev/md0 /mnt/test
(seems to work, can write and read a file)


# dd if=/dev/zero of=150G seek=$((150*1024*1024*1024-1)) count=1 bs=1
# newfs_msdos -F 32 -O android -c 8 ./150G 
newfs_msdos: warning, ./150G is not a character device
./150G: 313959560 sectors in 39244945 FAT32 clusters (4096 bytes/cluster)
BytesPerSec=512 SecPerClust=8 ResSectors=32 FATs=2 Media=0xf0 SecPerTrack=63 Heads=255 HiddenSecs=0 HugeSectors=314572800 FATsecs=306602 RootCluster=2 FSInfo=1 Backup=2
# file ./150G 
./150G: DOS/MBR boot sector, code offset 0x58+2, OEM-ID "android ", sectors/cluster 8, sectors/track 63, heads 255, FAT (32 bit), sectors/FAT 306602, serial number 0x3b941109, unlabeled
# fsck_msdosfs ./150G
** ./150G
** Phase 1 - Read and Compare FATs
** Phase 2 - Check Cluster Chains
** Phase 3 - Checking Directories
** Phase 4 - Checking for Lost Files
1 files, 1790528 free (39244944 clusters)
# mdconfig -a -f 150G 
md0
# mount -t msdosfs /dev/md0 /mnt/test
(seems to work, can write and read a file)


Where didn't this storage work? In your Android device? Maybe forcing sectors per cluster to be 8 is an issue for other FAT32 implementations? When I leave the "-c 8" out, sectors per cluster goes up to 64:

# newfs_msdos -F 32 -O android ./150G 
newfs_msdos: warning, ./150G is not a character device
./150G: 314495936 sectors in 4913999 FAT32 clusters (32768 bytes/cluster)
BytesPerSec=512 SecPerClust=64 ResSectors=32 FATs=2 Media=0xf0 SecPerTrack=63 Heads=255 HiddenSecs=0 HugeSectors=314572800 FATsecs=38391 RootCluster=2 FSInfo=1 Backup=2