Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 09 Mar 2005 14:25:41 -0500
From:      Duane Winner <dwinner-lists@att.net>
To:        freebsd-questions@FreeBSD.org
Subject:   auto mount external hard drive but only when present?
Message-ID:  <422F4DB5.1040900@att.net>

next in thread | raw e-mail | index | archive | help
Hi all,

Hoping someone might have a good technique for this situation:

I have a laptop with a docking station and in the expansion bay of the 
dock, I have a second hard drive, which I have configured as /dev/ad4s1d 
and mount it to /hd2

Normally on workstations with a 2nd drive, I'll just put another line in 
fstab and it will mount at each boot.

But because this is a laptop, and will be pulled off the dock when I'm 
on the road, I can't have that, because FreeBSD will scream into single 
user mode if that partition isn't there. I could put a 'noauto' switch 
into fstab, but that still leaves me with the problem:

The reason for the second drive is for backups: I want to run rsnapshot 
to take regular snapshots of my primary drive filesystems to the 2nd 
drive, and rsnapshot runs as a cron job. Now rnsnapshot is smart enough 
to know not to create the snapshot root if the mount isn't there, but 
while I am docked, I'll have to remember to manually mount the second 
drive. If I forget (which I'm apt to do), then no backups :(

What I'm looking for is a script or something that will mount 
/dev/ad4s1d to /hd2 automatically when it's present, but ignore it when 
it's not, and if possible to unmount it gracefully on shutdown.

I looked at amd automounting, but that seems to be a bit overkill (I 
really don't like the idea of adding NFS et.al. if I can avoid it).

Any ideas?

Cheers,
DW



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?422F4DB5.1040900>