Koozali.org: home of the SME Server
Legacy Forums => Experienced User Forum => Topic started by: Rick Jones on September 28, 2003, 03:56:33 PM
-
Anyone got any neat schemes for auto-mounting a USB hard drive when plugged in? Also unmounting when unplugged to avoid bogus directories remaining?
The USB hotplugging all works, with the device being attached as /dev/sda1 (I'm assuming the drive will always be a single partition for this exercise).
So far I've manually added a line to fstab, with auto parameters, and hacked the scripts in /etc/hotplug to call mount -a after updfstab (the latter doesn't actually appear to do anything for USB devices).
This does achieve mount on plugin, but auto unmount could be a bit more tricky.
I just all seems a bit messy, I can't help thinking there must be a better way ... is there?
TIA
Rick
-
It has been a while but i think this is it i will try it tonight when i get home and if it is wrong i will let you know but.....
in /mnt mkdir cf (compact flash) or what ever you want
mount /dev/sda1 /mnt/cf
cd cf
This should get you where you want to be
modprobe sg
modprobe ide-scsi
modprobe usb-storage
mount /dev/sda1 /mnt/cf
-
Well, yes, I'm already doing that. But where I'm trying to get to is to have it happen simply as a result of physically plugging in the USB drive - with no command line intervention.
Plugging in fires a hotplug event, which will load the modules if required (that bit works!). With some tweaking I've got it also performing the mount, but it's all a bit hacky. By which I mean if there were a 2nd USB drive, or I inserted a drive with more than one partition, it wouldn't work, there'd need to be more script hacking.
There's also the drive-removal problem. The hot(un)plug cleanly releases the device, but the mount remains, so there is a mounted directory pointing at a device that no longer exists. It would be nice to have the removed devices unmount automatically. I can't see a good way to do that bit :(
Any further ideas welcome!
Rick.