how to fixate usb hard drives mount path?

  • I have two usb hard drives, and everytime i reboot they get a new /dev/sdX and thus a new /var/media/hddpath. How can i prevent this from happening?

  • Set a link at /storage/.config/autostart.sh:

    Bash
    #!/bin/sh
    
    (
        ln -s /dev/disk/by-uuid/<YOUR_DRIVE_ID> /var/media/hddpath
    ) &

    i did it like this

    Bash
    #!/bin/sh
    
    (
        ln -s /dev/disk/by-uuid/53971acb-b470-4e13-86e0-214bdc22f621 /var/media/sda1-ata-KINGSTON_SNV2S20
        ln -s /dev/disk/by-uuid/e60c7dc1-9f50-4088-9686-2ce42f3f55b9 /var/media/sda1-ata-KINGSTON_SNV2S20/complete/tv2
    ) &


    and the first drive gets mounted at /var/media/sda1-ata-KINGSTON_SNV2S20 and the second one at /var/media/sdb1-ata-Samsung_SSD_840_

    inside /var/media/sda1-ata-KINGSTON_SNV2S20 there is a symlink 53971acb-b470-4e13-86e0-214bdc22f621 -> /dev/disk/by-uuid/53971acb-b470-4e13-86e0-214bdc22f621

    and inside /var/media/sda1-ata-KINGSTON_SNV2S20/complete/tv2 there is a symlink /dev/disk/by-uuid/e60c7dc1-9f50-4088-9686-2ce42f3f55b9

    not exactly what i wanted?

  • Sorry, I was wrong. Use mount instead of ln -s. Create a folder for each mount, too.

    Bash
    #!/bin/sh
    
    (
    	mkdir /var/media/<YOUR_PREFERRED_PATITION_NAME>
        mount /dev/disk/by-uuid/<YOUR_PARTITION_ID> /var/media/<YOUR_PREFERRED_PATITION_NAME>
    ) &

    To my knowledge, LE will always add external disk partitions to /var/media, so you eventually get them twice.

  • Code
    e2label /dev/sda1 "LABEL"

    Use e2label to set disk labels and the drive should be auto-mounted to /var/media/LABEL instead of the default behaviour of mounting to a path that includes the current /dev/device which depends on USB probe order (which cannot be controlled).