On Tue, 2010-11-30 at 10:32 -0800, Alan Evans wrote:
Is it possible to get gnome-volume-manager style auto mount/umount
of
USB drives in /media (or elsewhere) when nobody is logged into the
desktop? The behavior when I'm logged in (auto-mounting in a directory
named after the Volume Name, auto-unmounting, etc) is exactly what I
would like when I'm not logged in. It doesn't matter if the mount
point is owned by root, as I just want to back up some files in a cron
job but only if there's a drive plugged in.
I suppose I could script it all, except: 1. I'm not a very skilled
script writer, 2. I don't really know where to start to accomplish
this, and 3. It seems to me that there's already something on the
system that does perfectly what I want.
-Alan
Alan
I had a similar situation about fifteen years ago, although it was with
a zip drive then. Refining my solution every time the dust hit the fan,
I have arrived at the following:
I made a subdirectory (/media/flash) to mount the flash drive on.
I put the following entry in /etc/fstab so only the right USB drive
would be mounted, and it wouldn't be mounted automagically:
UUID=3470cd52-98ec-4eb8-972f-53be4909a856 /media/flash auto
noauto,defaults 1 2
You can get the UUID by using ls -l /dev/disk/by-uuid
The attached script (in /etc/cron.daily) runs every night. It backs up
my /home stuff using dump(1), then copies some goodies to
my /root/conf.d directory (where I keep stuff I need to reference when
the disk crashes) and backs that up (with tar(1)). (It backs up
Monday's stuff at 0330 Tuesday, etc., hence the counterintuitive file
names.)
By keeping the USB drive unmounted it's preserved from most disasters.
By keeping it plugged in it's available for backup.
By using the UUID in /etc/fstab I prevent my files from being backed up
on the wrong USB drive - you know, the one you inserted and forgot to
remove...
If the USB drive can't be mounted, the error is in the email and the
drive isn't unmounted.
If there's an error during the backup, the drive stays mounted.
If the drive is already mounted, it's because there was an error, so the
script terminates.
Root email is your friend.
Don't be afraid of scripts. You learn by doing. The goal is to err,
and err, and err again, but less, and less, and less.