[ubuntu-nz] How to mount USB drive when no-one is logged in?
Johann Schoonees
j.schoonees at irl.cri.nz
Wed Apr 30 03:29:26 BST 2008
I've googled and searched the archives but I'm getting swamped with
marginally related "USB drive does not mount" hits. Here goes:
When I log into the kubuntu Feisty desktop, there is an icon showing
that my external USB drive is connected and mounted.
However, cron runs a nightly back-up script for me at 3 am when no-one
should be logged in, but after migrating from Fedora to Feisty, it fails
at the point where I try to mount the external USB drive:
MOUNT_OK=no
for DISK in $DISK_LABELS
do
# mount -w "$MOUNT_POINT/$DISK" 2> /dev/null
mount -w "$MOUNT_POINT/$DISK"
MOUNT_RES=$?
if [ "$MOUNT_RES" = "0" ]; then
MOUNT_OK=yes
break
fi
done
results in:
mount: can't find /media/backup_0 in /etc/fstab or /etc/mtab
mount: can't find /media/backup_1 in /etc/fstab or /etc/mtab
mount: can't find /media/backup_2 in /etc/fstab or /etc/mtab
...
even when a disk with label backup_1 (or 2 etc.) is connected.
There is no entry for /dev/sdb1 in /etc/fstab. There is one in etc/mtab
when someone is logged into the desktop, but not when not. It looks
something like this:
/dev/sdb1 /media/backup_1 ext3 rw,noexec,nosuid,nodev,sync,data=ordered 0 0
Under Fedora it used to look like this:
/dev/sdb1 /media/backup_1 ext3 rw,nosuid,nodev 0 0
The exact mount point depends on the disk label. I have more than one
back-up disk, each with a unique label.
Under Fedora there used to be an entry in fstab like this:
/dev/sdb1 /media/backup_1 ext3 pamconsole,exec,noauto,managed 0 0
which changed automatically (apparently under control of something
called fstab-sync which I don't see in kubuntu) according to the label
of the connected drive.
In short, how should my script detect and mount a connected USB external
drive when no-one is logged in?
Any help appreciated,
Johann
More information about the ubuntu-nz
mailing list