Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm doing a backup script and need to have a fixed mount point for an external usb drive. If it is the first usb connected it will mount in /media/usb0/, however if it is the second, third... it will mount in /media/LABEL_OF_THE_DISK/. The same apply for sdX. If it is the first will be sdc1 (I have two disks already), but if it is the second will be sdd, third sde....

The hdd is disconnected and only will be connected when is the backup time (once a week)

I may look where is it mounted and pass a parameter to the script as "actual_mount_point", but I'd like to connect the hdd, run the script and backup done, without need be writing anything.

So the question is: Is it possible to have a fixed mount point for an external drive?

share|improve this question

You could also write a udev-rule, which allows you to point what to do when disk connected:

# cat /etc/udev/rules.d/99-usb-mount.rules
SUBSYSTEM=="usb", ACTION=="add", ENV{ID_SERIAL_SHORT}=="XXXXXXXXXX", RUN+="/path/to/script1.sh"
SUBSYSTEM=="usb", ACTION=="remove", ENV{ID_SERIAL_SHORT}=="XXXXXXXXXX", RUN+="/path/to/script2.sh"

You can automate backup on disk connection, for example

share|improve this answer
Do I have to create such file? Because I only have 70-persistent-cd and 70-persisten-net rules files. Also the XXXXXXXXXX what represents? The UUID? – Ayozint Jan 6 '13 at 23:28

you can add an entry to /etc/fstab

get the uuid of your device with blkid (locate/print block device attributes) and make an entry in fstab (hold static informations about filesystem) with that, e.g. UUID=645a3aa3-09a3-4e9d-bc69-0a5466684137 /media/usb-data/ ext4 defaults 1 1

see "man fstab" for more details

share|improve this answer
but this isn't only if I would want to have it permanent connected? – Ayozint Jan 6 '13 at 11:45
It will work fine for transient connections too. The device is just skipped if it's not available when init invokes mount -a. When the device is available, just do mount /mnt/point, using the mountpoint specified in /etc/fstab. – dubiousjim Jan 6 '13 at 12:09
up vote 0 down vote accepted

Ok! I found out where was the problem. I had in the fstab this line:

/dev/sdc1 /media/usb0 auto rw,user,noauto 0 0

So when I connected the first USB, it always was mounted in /media/usb0. However now I removed that line, and doesn't matter when I connect the usb, it always is mounting in /media/LABEL

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.