[ubuntu-nz] How to mount USB drive when no-one is logged in?
Johann Schoonees
j.schoonees at irl.cri.nz
Thu May 1 02:05:55 BST 2008
I think I'm beginning to see the light. Thanks muchly to those who helped.
I did not understand the jist of mount. It seems one does not have to
rely on fstab entries to mount a device (at least not if I am root,
which my back-up cron script will be). Just `mount -ow /dev/sdb1
/media/backup_drive' (making sure the directory exists) and I'm away.
Haven't had a chance to try this yet. I'll experiment this weekend.
This is me thinking aloud a bit in the hope that someone will beat me
round the head with any glaring errors.
Under Fedora, I think fstab was automatically updated with newly plugged
USB devices, by default mounted on /media/<label> or /media/usbdisk if
it had no label. That made it necessary for my script to iterate
through all my known disk labels to find out which one was mounted, if any.
With ubuntu, all I need to do is *not* put anything in fstab, detect
whether a drive a connected with `fdisk -l /dev/sdb', and mount it (if
not already) in a fixed place like /media/backup_drive.
Isn't fdisk a slightly scary/overkill tool to use for simply listing
connected USB devices?
Now, what happens if I also left my memory stick plugged in? In that
case fdisk will print entries for /dev/sdb1, /dev/sdb2, etc. Then I
could use something like e2label to find my back-up drive's label, no?
Looking through `man -k label' on my Fedora system at work, `devlabel
add -d /dev/sdb1 -s /root/backup_drive' looks quite neat, but I suppose
it will want each unique (by UUID) device to be linked with a different
symlink? Or is there a way for the symlink to stay the same across
different devices mounted one at a time, which is really what I'm after?
And the day will surely come when I break all the rules and leave *two*
back-up drives connected. :-> The joy of idiot-proof script writing,
where the idiot is me...
Johann
More information about the ubuntu-nz
mailing list