Date: Thu, 10 Mar 2005 02:40:22 +0100 From: Mario Hoerich <m@MHoerich.de> To: Duane Winner <dwinner-lists@att.net> Cc: freebsd-questions@FreeBSD.org Subject: Re: auto mount external hard drive but only when present? Message-ID: <20050310014017.GC8033@Pandora.MHoerich.de> In-Reply-To: <422F4DB5.1040900@att.net> References: <422F4DB5.1040900@att.net>
next in thread | previous in thread | raw e-mail | index | archive | help
# Duane Winner:
> 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
[...]
> 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:
Just a (rather crude) quickhack:
#!/bin/sh
SLEEP=300
MOUNTED=0
while [ 1 ]; do
sleep $SLEEP
if [ $MOUNTED = 0 ]; then
mount -t ufs2 /dev/ad4s1d /hd2 >/dev/null 2>&1
if [ $? = "0" ]; then
MOUNTED=1
fi
else
touch /hd2/.touchme >/dev/null 2>&1
if [ $? = "1" ]; then
umount -f /hd2 >/dev/null 2>&1
MOUNTED=0
fi
fi
done
Basically, this'll try every $SLEEP seconds to either mount
the disk or, once this has been done successfully, to touch
a file on /hd2. If that fails, the disk's no longer there,
so force-unmount it.
I can't really test it, so I'm none too sure this works, though. :(
HTH,
Mario
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20050310014017.GC8033>
