Auto Mount USB

Roland Smith rsmith at
Mon Aug 18 20:10:54 UTC 2008

On Mon, Aug 18, 2008 at 12:06:38PM -0400, Brian Miller wrote:
> All,
> Not sure how to word all of this. I am trying to auto mount my USB tumb
> drive in FreeBSD (The version that comes with PFSense) I believe most of
> my troubles are related to lack of knowledge.
> I can mount the drive just fine with the mount command. I also was able
> to add it to the fstab and have it mount at boot.
> However if the drive is removed it has to be mounted again. How do you
> get it to mount back up with out having to run the mount command again?

You'd have to use an automounter, like amd(8) that comes with FreeBSD.  
> Also I noticed while playing with it that the device assignment keeps
> changing each time it is plugged back into the system. Started with
> /dev/da0s1, then da1s1, then da2s1, da3s1 and so on. Which means I have
> to change my mount comand every time.

This should not happen. The devfs filesystem that FreeBSD uses removes
device nodes if the devices are removed (unless the devices are still in

Are you unmounting the filesystem on the thumbdrive before removing the
drive from the USB port? If not this could be the cause of the
problem. Note that removing a mounted drive can crash your system!
_Always_ unmount a filesystem _before_ removing the device it is on.

[As an aside, FreeBSD's disk device drivers and filesystems predate "hot"
removeable devices by a considerable margin; they were written with the
(implicit) assumption that disk devices are not removed while the system
is running. Although work has been done in DragonflyBSD (a derivative of
FreeBSD 4) to fix this, those changes haven't made it into FreeBSD 6/7.x.]

If you have device nodes for devices that aren't there anymore, you can
try running 'camcontrol rescan all' as root.

If the filesystem on the thumbdrive has a label FOO, you should see that
label as a device node in /dev/msdosfs/FOO (for FAT* filesystems) or
/dev/ufs/FOO (for UFS formatted drives). Unlike the da devices this
doesn't depend on the sequence in which devices are plugged in. Labels
can be made with tunefs(8) (for UFS filesystems) or newfs_msdos(8) for
msdos filesystems.

[plain text _non-HTML_ PGP/GnuPG encrypted/signed email much appreciated]
pgp: 1A2B 477F 9970 BA3C 2914  B7CE 1277 EFB0 C321 A725 (KeyID: C321A725)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 195 bytes
Desc: not available
Url :

More information about the freebsd-questions mailing list