How do I make sure my external drive mounts to the same path every time?

Hello! I’m using a Raspberry Pi 4 with OSMC, and I have a little drive connected via USB. It has worked just fine for some time now. I do unplug the drive sometimes and plug it into my computer to add more movies and shows. I’m guessing I must have unplugged it while the pi was still on, or unplugged it and plugged it back into a different USB port, because when I tried to watch anything just now, I would get an error saying the file is not available and asking if I wanted to delete it. So I figured out that previously the drive must have always mounted to /media/ExternalSSD (and I had definitely unplugged it enough times to know it was mounting back to that same path every time), but it just started mounting to /media/ExternalSSD_ (the same but with a _ at the end). So I just changed the sources in the settings to be /media/ExternalSSD_/Movies and /media/ExternalSSD_/TVShows. This is easy enough to do if the problem comes up again, but I’m wondering if there is any way to force it to auto mount to one path based on some sort of ID from the drive or something like that? I will obviously take more care in the future to have the pi powered off before I unplug the drive, and I’ll try to make sure I always use the same USB port, but I’m not even 100% sure that’s what would cause it to make up a new mount location, and the /media/ExternalSSD path still exists (it’s empty obviously, as nothing is mounted there). Thanks in advance! I appreciate any advice :slight_smile:

Normally that folders should be removed after a reboot and then your USB Device should be mounted with it’s original label.

Can you reboot and then show what ls -lah give you and also upload logs with grab-logs -A and share the URL

Okay, I rebooted. Here’s what it looks like in /media:

And here are the logs: https://paste.osmc.tv/erodetizax

Feb 21 01:59:30 osmc ntfs-3g[545]: Mounted /dev/sda1 (Read-Write, label "ExternalSSD", NTFS 3.1)
Feb 21 01:59:30 osmc ntfs-3g[545]: Cmdline options: rw,nodev,nosuid,uid=1000,gid=1000,dmask=0077,fmask=0177,fmask=0111,dmask=0000,uhelper=udisks
Feb 21 01:59:30 osmc ntfs-3g[545]: Mount options: nodev,nosuid,uhelper=udisks,allow_other,nonempty,relatime,rw,default_permissions,fsname=/dev/sda1,blkdev,blksize=4096
Feb 21 01:59:30 osmc ntfs-3g[545]: Global ownership and permissions enforced, configuration type 7
Feb 21 01:59:30 osmc udisks-glue[518]: Successfully automounted /dev/sda1 at /media/ExternalSSD_
Feb 21 01:59:30 osmc udisks-glue[518]: Device file /dev/mmcblk0 inserted
Feb 21 01:59:30 osmc udisks-glue[518]: Device file /dev/sda inserted
Feb 21 01:59:30 osmc kernel: hdmi-audio-codec hdmi-audio-codec.2.auto: ASoC: error at snd_soc_dai_startup on i2s-hifi: -19
Feb 21 01:59:30 osmc kernel: hdmi-audio-codec hdmi-audio-codec.2.auto: ASoC: error at snd_soc_dai_startup on i2s-hifi: -19
Feb 21 01:59:30 osmc udisks-glue[518]: Device file /dev/sda1 mounted at /media/ExternalSSD_

Ok, seems one for @DBMandrake to check

1 Like

What does ls -lah /media/ExternalSSD say?

It’s empty in /media/ExternalSSD and /media/ExternalSSD_ has the drive mounted and works (I can watch stuff, although it had to re scan everything when I changed the library source path). Hmm, but now I’m wondering if somehow the permissions just got off on ExternalSSD?

Thanks.

  • Power off the device
  • Unplug the SSD
  • Power on
  • sudo rmdir /media/*
  • Do you get an error? If so sudo rm -r /media/ExternalSSD
  • Plug in the SSD.
  • Re-scan.
1 Like

That worked! I noticed that when I powered the pi back on without the drive plugged in, the /media/ExternalSSD folder was still there, but the /media/ExternalSSD_ folder wasn’t. I didn’t get an error (well, I got an error saying /media/README is not a directory, but I knew what you were going for).

Do you know what I can do to prevent this happening again?

Either way, I really appreciate your help! :slight_smile: I like this solution better than changing the path and adding a _ every time I mess up, lol

Thanks for confirming.

Make sure you ‘remove safely’ the disc or shut down the Pi before unplugging it.

1 Like

Roger that. Thanks again! Y’all were so kind and speedy! :slight_smile: