January 18th, 2005, 14:18
I mounted my usb pen drive manually and decided it was time to automount cdrom/floppy/etc. again. I had it setup on my FreeBSD 4.1.1 play box years ago and haven't really touched it since. I discovered it was pretty easy to setup mounts in fstab with noauto and really hadn't gotten around to messing with it since. A quick google search gave me a couple good links to start with from the FreeBSD Handbook ( and Daemon News ( The Daemon News article was aimed at FreeBSD 4.x but it's close enough.

Automounter uses your fstab so I was halfway since I already had my devices in place with noauto set on them. These are the physical mount points. We are going to use another path for the dynamic. I'm using /floppy, /cdrom and /usb for my dynamic mounts but you can use whatever suits you.

/dev/fd0 /mnt/floppy msdosfs rw,noauto 0 0
/dev/acd0 /mnt/cdrom cd9660 ro,noauto 0 0
/dev/da0s1 /mnt/usb msdosfs rw,noauto 0 0

Add the following to your /etc/rc.conf. The default for the flags should be fine for now. You can tweak the timeout and other things later. Reboot or manually start these.


We need to create a map file to set paths and options for autmount to use. Edit your /etc/

/defaults type:=host;fs:=${autodir}/${rhost};rhost:=${key}

* opts:=rw,grpid,resvport,vers=3,proto=udp,nosuid,no dev

localhost type:=auto;fs:=${map};pref:=${key}/

localhost/cdrom type:=program;fs:=/mnt/cdrom;\
mount:="/sbin/mount mount /mnt/cdrom";\
unmount:="/sbin/umount umount /mnt/cdrom"

localhost/floppy type:=program;fs:=/mnt/floppy;\
mount:="/sbin/mount mount /mnt/floppy";\
unmount:="/sbin/umount umount /mnt/floppy"

localhost/usb type:=program;fs:=/mnt/usb;\
mount:="/sbin/mount mount /mnt/usb";\
unmount:="/sbin/umount umount /mnt/usb"

Automount uses the dynamic path of /host/locahost/* for local mounts and then we'll symlink it to where we want from there. I removed my existing /cdrom since I need to symlink it. Don't create /host or /net since AMD will dynamically create these for local and network mount points respectively. We need to create /.amd_mnt for automounter to use and our mount points.

mkdir /.amd_mnt
ln -s /host/localhost/floppy /floppy
ln -s /host/localhost/cdrom /cdrom
ln -s /host/localhost/usb /usb

I did a cd /usb and /cdrom as a user and there's all my files. I did a mount a few minutes later and saw that both were unmounted. I like not needing to setup sudo to let my user mount/unmount these drives. The default idle time before automatically unmounting is 120 seconds (2 minutes) and that's perfect for the removable media I'm using. You may want to tweak that in the amd flags if you have other needs or are using it to mount network shares too. I did play with having AMD mount some SMB shares but it was being a pain with the passwords. I decided that I didn't really need these to mount and umount automatically as I usally just mount them and leave them mounted. NFS mounts are fairly straightforward using AMD too since it's really using NFS as the mechanism to make it work.

There's a lot more options using amd.conf ( and other amd ( options. I like the example on Daemon News with using AMD to automatically unmount a spooler on a noisy drive and spin it down via camcontrol in a script. There's a lot of cool things you could do with this. I'm definitely going to have to play more with AMD but it's nice to have my removable media working nicely right now. :silly:

January 19th, 2005, 05:12
Tops! Been putting this sort of thing off for a while :)

January 22nd, 2005, 18:01
Mine isn't liking my symlink to /cdrom. I changed it to /cdrw and it works great. Apparently something else was looking at /cdrom too. Just thought I pass this along.

February 8th, 2005, 07:05
Hrm .. I've tried all sorts of things, but I can't get it to work, all I get is "host is down" error :(

I'm just using the cdrom bit, on a 4.11-STABLE system

Feb 8 21:48:59 erwin amd[41364]: switched to logfile "syslog"
Feb 8 21:48:59 erwin amd[41364]: AM-UTILS VERSION INFORMATION:
Feb 8 21:48:59 erwin amd[41364]: Copyright (c) 1997-1999 Erez Zadok
Feb 8 21:48:59 erwin amd[41364]: Copyright (c) 1990 Jan-Simon Pendry
Feb 8 21:48:59 erwin amd[41364]: Copyright (c) 1990 Imperial College of Science, Technology & Medicine
Feb 8 21:48:59 erwin amd[41364]: Copyright (c) 1990 The Regents of the University of California.
Feb 8 21:48:59 erwin amd[41364]: am-utils version 6.0.3s1 (build 492100).
Feb 8 21:48:59 erwin amd[41364]: Built by root@erwin.number6 on date Tue Jan 11 18:49:43 EST 2005.
Feb 8 21:48:59 erwin amd[41364]: cpu=alpha (little-endian), arch=alpha, karch=alpha.
Feb 8 21:48:59 erwin amd[41364]: full_os=freebsd4.11-STABLE, os=freebsd4, osver=4.11-STABLE, vendor=unknown.
Feb 8 21:48:59 erwin amd[41364]: Map support for: root, passwd, union, nis, ndbm, file, error.
Feb 8 21:48:59 erwin amd[41364]: AMFS: nfs, link, nfsx, nfsl, host, linkx, program, union, inherit, ufs,
Feb 8 21:48:59 erwin amd[41364]: lofs, cdfs, pcfs, auto, direct, toplvl, error.
Feb 8 21:48:59 erwin amd[41364]: FS: cd9660, lofs, mfs, nfs, nfs3, null, msdos, ufs, umap, union.
Feb 8 21:48:59 erwin amd[41364]: Network: wire="" (netnumber=192.168.100).
Feb 8 21:48:59 erwin amd[41364]: My ip addr is
Feb 8 21:48:59 erwin amd[41365]: released controlling tty using setsid()
Feb 8 21:48:59 erwin amd[41365]: file server localhost type local starts up
Feb 8 21:48:59 erwin amd[41366]: /host: disabling nfs congestion window
Feb 8 21:48:59 erwin amd[41365]: first time load of map /etc/ succeeded
Feb 8 21:48:59 erwin amd[41365]: /etc/ mounted fstype toplvl on /host
Feb 8 21:49:14 erwin amd[41365]: /etc/ mounted fstype auto on /host/localhost
Feb 8 21:49:14 erwin amd[41365]: /host/localhost/cdrom: mount (amfs_auto_cont): Host is down

February 8th, 2005, 13:20
AMD uses a physical mount point and then the symlink to the automount path (i.e. /host/localhost/cdrom) to call the actual mounting. I had issues using /cdrom for the virtual but it works fine for the physical mount. Your and fstab should point to where you map it manually (i.e. /cdrom or /mnt/cdrom) and then use the symlink to make the automount point you want to use.

I'm using /cdrom in and fstab then create my symlink to /cdrw.

ln -s /host/localhost/cdrom /cdrw.

Cd to /cdrw and viola, it mounts the CD without intervention. The directions I started with were for 4.x so I don't think it should be an issue.