I recently came across a USB drive and couldn't remember what was on it. So, I tried to mount it using:
but kept getting an error of 'Invalid argument'. The output from the following commands all seemed to point to there being something at da1s1:
It took a while to work out that I hadn't actually created a filesystem on the drive. Creating a new filesystem at da1s1 using the following command worked and eventually allowed me to mount the drive successfully:
This was definitely a PEBKAC error and took a lot longer to resolve than I like to admit. For future reference I'd like to script something to check for this situation. So, my question is... what is the canonical way in FreeBSD to check whether a filesystem actually exists when trying to mount a drive. Or alternatively, what output from above should have given me a clue that a filesystem didn't exist on the drive yet. Thanks
Code:
# mount -t msdosfs /dev/da1s1 /mnt
Code:
# camcontrol devlist
<Generic- SD/MMC 1.00> at scbus0 target 0 lun 0 (da0,pass0)
<Verbatim STORE N GO 2.00> at scbus1 target 0 lun 0 (da1,pass1)
Code:
# gpart show da1
=> 63 30924737 da1 MBR (15G)
63 1 - free - (512B)
64 30924736 1 fat32 [active] (15G)
Code:
# fstyp /dev/da1s1
msdosfs
Code:
# ls -al /dev/da1*
crw-rw---- 1 root operator 0x195 1 Jan 14:06 /dev/da1
crw-rw---- 1 root operator 0x19a 1 Jan 14:07 /dev/da1s1
Code:
# fsck_msdosfs -y /dev/da1s1
** /dev/da1s1
** Phase 1 - Read FAT and checking connectivity
** Phase 2 - Checking Directories
** Phase 3 - Checking for Lost Files
4 files, 15 GiB free (1930744 clusters)
Code:
# newfs_msdos -L FILES -F 32 /dev/da1s1