unmounting a filesystem safely that doesn't exist anymore

Christopher Sean Hilton chris at vindaloo.com
Wed Jun 14 20:17:00 UTC 2006

On Mon, Jun 12, 2006 at 04:44:48PM -0400, Zaphod Beeblebrox wrote:
> On 6/12/06, Ulrich Spoerlein <uspoerlein at gmail.com> wrote:
> >
> >Björn König wrote:
> >
> >> I did a mistake: I unplugged my digital camera accidentally before I
> >unmounted the
> >> filesystem. *doh* This happens very often, because I'm very
> >scatterbrained. =) The kernel
> >> will panic and all filesystems remain unclean in any case now. I know
> >that this is a well
> >> know issue and in past discussions you stated that this behaviour is
> >intended and won't be
> >> changed ad hoc. I just want to know if somebody knows a workaround or
> >small trick that
> >> prevents the other filesystems from being unclean on next boot-up.
> >
> >You might give the automounter (am-utils) a whirl. They are very
> >confusing to set up, but you can set the unmount-if-unused timeout to
> >something like 5 seconds. This could narrow the window enough to not
> >panic you system frequently :)
> That's rather hackish ... especially since this is a common problem and a
> rather obvious hole in using FreeBSD for noobs.

I've been using the automounter to handle these mounts for about three
years now. When I started I would be have to run fsck on my memory
stick about twice a day. Now it's more like once a month. In short it

I've got to admit that I agree with the fact that this is a more than
rather hackish solution to the problem. The real issue here is that
for Unix, filesystems come in two types: Those on hard disks which are
perpetually available once they've been mounted once, and those which
come from the network which can come and go as they please. The
automounter works as a solution to this problem by making a local
filesystem on hotplugable hardware look like it's coming from a

It took me the better part of a day to figure out how to make the
automounter work properly in this situation. In my case I was using a
UFS formatted memory stick which complicated things. The automounter
was coded with the assumption that UFS filesystems only exist on
drives that are bolted into the computer. The automounter will gladly
mount a UFS volume but because it's a UFS volume it never feels the
need to dismount the volume and leave it in a clean state. 

Another problem is that most tools today makes a similar the
assumption about mounted volumes that they didn't graft into the
filesystem. So, for example opening up the Nautilus file browser on
/amd/ufs0 on my system creates an entry in some magic file somewhere
that tells Nautilus to periodically visit that directory. As far as
amd is concerned these visits are valid requests to mount the
filesystem. The end result is that the filesystem again remains
permanently mounted. 

With MS-DOS FAT filesystems the problem is who mounted the
filesystem. Amd mounts my MP3 player read-write on /amd/mp3 perms 777
root:wheel. I use rsync to copy podcasts from a holding directory on
my desktop to it. And rsync complains all the time that it can copy
the files but it cannot change the date/time. This is because
chris:chris cannot change an entry in a directory owned by root:wheel,
as it should be.

It doesn't sound like I'm trying to sell this but in the long run I
actually believe that amd is the best of a bunch of mediocre
solutions. I wish however that:

     Amd didn't make the assumption that a UFS volume was going to be
     there forever;

     Gnome could be told that filesystems under /amd or some other
     programmable mount point will come and go with the wind so don't
     cache the names;

     That more applications would understand that there are people
     using the automounter and that a mount request can be
     accomplished by a simple:

          $ ls -l /amd/foo

     and a umount request can be accomplished by a doing:

          $ amq -u /amd/foo

Look for a followup with configs.g

-- Chris

Chris Hilton                                   chris-at-vindaloo-dot-com
                "All I was doing was trying to get home from work!"
                                                 -- Rosa Parks

More information about the freebsd-questions mailing list