Fixed mount point of external usb hdd

7,120

Solution 1

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

Solution 2

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

Solution 3

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:
7,120

Related videos on Youtube

The Illusive Man
Author by

The Illusive Man

Updated on September 18, 2022

Comments

  • The Illusive Man
    The Illusive Man almost 2 years

    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?

  • The Illusive Man
    The Illusive Man over 11 years
    but this isn't only if I would want to have it permanent connected?