Static device path for USB HDD?

  • Hey guys, I'm hoping that one of you with more Linux knowledge than me can help me solve this problem. A bit of background: I encrypted an entire USB HDD using VeraCrypt, and I use it to backup certain directories. I just run a script and enter my password, and the script mounts the drive using VeraCrypt, rsyncs all my data over, and then unmounts the drive. NOTE: To OMV, it appears that there's no filesystem on the drive at all until it is mounted using VeraCrypt. The problem I'm having is that the device path can change, i.e., /dev/sdg for this USB HDD. If I add another drive to my array, the USB drive might become /dev/sdh. I don't want to have to keep updating my script, so is there some static path that my script can point to? Or is there a way to force a device path for a given device, i.e., /dev/sdz?


    Thanks!

    • Offizieller Beitrag

    I would mount the drive using its uuid which you can find with blkid. When you mount a drive in OMV, it uses the uuid just for the reason you mention and uuid never changes.

    omv 7.0.4-2 sandworm | 64 bit | 6.5 proxmox kernel

    plugins :: omvextrasorg 7.0 | kvm 7.0.10 | compose 7.1.2 | k8s 7.0-6 | cputemp 7.0 | mergerfs 7.0.3


    omv-extras.org plugins source code and issue tracker - github


    Please try ctrl-shift-R and read this before posting a question.

    Please put your OMV system details in your signature.
    Please don't PM for support... Too many PMs!

  • Yes, I was thinking the same thing after a bit of research, but it looks like it only shows up after it is mounted. For example, right now I have the drive plugged in, but I haven't mounted it with VeraCrypt yet. I can't see the uuid which tells me that my script won't see if either.

    • Offizieller Beitrag

    That is because veracrypt probably creates the block device. With LUKS, I mount the drive by name (sdb_crypt for example) because the name doesnt change and is unique on my system. No idea if you can do with veracrypt.

    omv 7.0.4-2 sandworm | 64 bit | 6.5 proxmox kernel

    plugins :: omvextrasorg 7.0 | kvm 7.0.10 | compose 7.1.2 | k8s 7.0-6 | cputemp 7.0 | mergerfs 7.0.3


    omv-extras.org plugins source code and issue tracker - github


    Please try ctrl-shift-R and read this before posting a question.

    Please put your OMV system details in your signature.
    Please don't PM for support... Too many PMs!

  • OK, after some more research, I believe that I have found a solution. I'm curious to know what you think.


    I created /etc/udev/rules.d/50-usb-hdd.rules containing the following lines:


    SUBSYSTEMS=="usb", ATTRS{manufacturer}=="Seagate", ATTRS{product}=="FreeAgent GoFlex", ATTRS{serial}=="<serial # here>", SYMLINK+="usbhdd"
    SUBSYSTEMS=="usb", ATTRS{manufacturer}=="Seagate", ATTRS{product}=="FreeAgent GoFlex", ATTRS{serial}=="<serial # here>", SYMLINK+="usbhdd"


    This covers the two USB hard drives I use for my backups.


    Ran "udevadm trigger" to trigger the rules.


    Now I can always find either drive at /dev/usbhdd, and it appears to work fine with my script as well as VeraCrypt. Of course, I'll have to update the rules if I ever get any different drives. Perhaps I should make the rules more generic?


    Do you see anything obviously wrong with this solution?


    Thanks for the help.

    • Offizieller Beitrag

    I don't see anything wrong. As for the rules, that is up to you. If you don't get new drives very often, then I wouldn't worry about it.

    omv 7.0.4-2 sandworm | 64 bit | 6.5 proxmox kernel

    plugins :: omvextrasorg 7.0 | kvm 7.0.10 | compose 7.1.2 | k8s 7.0-6 | cputemp 7.0 | mergerfs 7.0.3


    omv-extras.org plugins source code and issue tracker - github


    Please try ctrl-shift-R and read this before posting a question.

    Please put your OMV system details in your signature.
    Please don't PM for support... Too many PMs!

  • Thank you for the review. I did decide to make it a little more generic, and it's still working well.


    SUBSYSTEMS=="usb", ATTRS{manufacturer}=="Seagate", ATTRS{product}=="FreeAgent GoFlex", SYMLINK+="usbhdd"


    Problem solved! Woohoo! :D

Jetzt mitmachen!

Sie haben noch kein Benutzerkonto auf unserer Seite? Registrieren Sie sich kostenlos und nehmen Sie an unserer Community teil!