[ubuntu-uk] Symlinking to USB hard drives

Glen Mehn glen.mehn at oba.co.uk
Tue Oct 5 18:55:32 BST 2010

  On 04/10/10 20:25, Neil Greenwood wrote:
> Hi all,
> I have a couple of matched USB hard drives that I use as part of my
> backup strategy. At the moment they both have the same label, so they
> end up mounted at /media/backup. But this means I can't easily tell
> which drive is which, and when I plug the second in, it gets mounted
> at /media/backup_.
> I'd like to re-label the drives to backup1 and backup2, but then have
> a symlink automatically created at /media/backup to whichever drive
> was first plugged in. I think I need to use a udev rule, but other
> than that I'm not sure.
> Does anyone have any ideas?

Hi Neil,

You can rename partitions in parted or gparted, which should sort it out 
for you. Then in your backup script, put something like:

if test -d /mounts/backup1
   do ln -s /mounts/backup1 /mounts/backup
elif test -d /mounts/backup2
   do ln -s /mounts backup2 /mounts/backup
else print "neither backup mount point exists, exiting"; exit 1

Does that make sense?



Glen Mehn
glen.mehn at oba.co.uk
skype: glenmehn | blog: http://glen.mehn.net/mba
UK: +44(0)7942 675 755 | US: +1 415 704 4737

More information about the ubuntu-uk mailing list