Re: mounting USB disk
On Thu, 14 Jul 2011 00:13:47 +1000
Andrew McGlashan <andrew.mcglashan@affinityvision.com.au> wrote:
> Hi,
>
> Tony van der Hoff wrote:
> > Runnung Squeeze here. I have a script which runs nightly, to backup
> > certain directories to a USB disk, which does a fine job, provided the
> > disk is mounted.
>
> Why not run blkid and if you find the "right" device by it's UUID, then
> mount it in your backup script. Do the backup and then umount the device.
>
> If the right device is not found, report that and quit the script.
>
> Using the UUID via blkid is important because you want to be sure you
> have the right backup device. A little harder if you have multiple USBs
> for the backup, but then you could cater all of your known UUIDs
>
Another way that works well is to give the disk a label.
the fstab can then refer to it by label :
LABEL=backup /mnt/backup ext3 noauto,users 0 0
you can then simply grep the mount command with no arguments to see if it's there and mount it if not:
if ! mount | grep -q ${BACKDIR}
then
mount ${BACKDIR}
fi
HTH.
Brian
Reply to: