Got a mount with a trailing underscore

I’m aware of what cause this and the other thread talking about solutions (of which I am not interested in doing).
It’s never happened to me before, but just happened to me now.
So I shut the Vero V down and disconnected my drives then booted it back up.
Then I looked into the Vero V using SSH and sure enough there is the the folder with the HDD mount name in /media/.
If I try to go into it or remove it I just get a “Permission denied”.
What SSH command can I do to remove it from /media/?
If I can remove it then I presume that when I load up that drive it will get mounted without the underscore behind it.

Suggest first to post here ls -lah output to give you a save respond

I figured it out.

So if you have this issue and know how to SSH here is an easy tutorial.

  1. Shut down your Vero
  2. Unplug your drive(s) (just to be safe)
  3. Turn your Vero back on
  4. SSH into your Vero
  5. sudo -s
  6. rmdir /media/<HDDNAME> && reboot

That should fix it.
To check go ahead and SSH back in after the reboot is complete and make sure its gone by doing:

  1. cd /media/
  2. ls

It should be empty now, except for a README file.
If so then go ahead and start plugging your drive(s) in.
The Vero should now mount the drive without the trailing underscore.
Once everything is mounted you can double check using df in SSH.

Thank you for the quick reply but I got it.
I love our community here.
Great people always ready to help.

Actually, should not be necessary to re-boot after deleting the rogue directory. Just plug in the USB/SD card and it should mount with the correct label.

You forgot the part where you used ls to find the directory name but you don’t need it and can be done with a single command if you use a wildcard…

sudo rmdir /media/*

EDIT: replaced sudo rmdir /media/*_ with sudo rmdir /media/* as the folder without the underscore is the one we want to remove.

Yeah, I didn’t want to suggest that just incase someone has some special use case where they have a directory in there that shouldn’t be removed.
Not sure what that would be but over the decades I’ve learned to avoid sweeping solutions because there always seems to be one person who has a unique use case.
You also don’t need to power down and disconnect your drives either.
Unfortunately many people will just copy and paste commands they see on the internet not knowing what they do, then they accidentally format an entire drive or something silly.
But I guess if you already knew what I was talking about in my first post and you know how to use SSH and what not you’re probably not the person who will do something too stupid.

BTW, when I tried sudo rmdir /media/<HDDNAME> I got a permission issue.
That might be because the drive is NTFS?
So that’s why I did sudo -s first.
You think I’m missing something there?

I get your point, but in this case I’m not so sure it would be much of a concern. If there is something other than an empty folder that command will not remove it. Also you would typically only have mount points in /media and that command will also not remove those.

NTFS wouldn’t have anything to do with it. The drive in question is the system drive and that is ext4 and when you reboot after unplugging the drive there is no mount point, just a folder that didn’t get automatically removed for some reason. As for as the sudo command goes it shouldn’t make any difference switching to the sudo user and running the command (what you were doing) and running the command as the sudo user without switching the active user (what my command did).

Had a bit more of a think on this after realizing my brain fart of giving a command that removed the wrong folder. This one should take care of the issue without unplugging the drive.

find /media -type d -name '*_'|sed 's/_$//'|xargs sudo rmdir && reboot

This finds any folder in /media that ends in an underscore and then removes the underscore from the end of the name and removes that folder name without the underscore if it is empty and if that is successful it then reboots so the drive gets remounted to the original location.

1 Like

Hmmm, but the underscore is given to the actual mounted drive because the old mount still exists in media as a folder without the underscore suffix, likely from a crash or something, and to compound the issue if it happens multiple times you can get multiple underscores (some other user experienced that issue).
I’m with you though, there really shouldn’t be anything in media except mounts that the system does for removable storage so it should be safe to wipe media and reboot.
Weird that my sudo command gave me permission issues though originally.
Maybe I originally did rm instead of rmdir or something?
This has only happened to me once and I don’t plan on making it happen again, but if it does I’ll test out find /media -type d -name '*_'|sed '$ s/_$//'|xargs sudo rmdir && reboot, but sudo rmdir /media/* should probably suffice.

Correct. If you had a drive that auto-mounted as “test” and this condition happened, you would then have an empty folder called “test” and an active mount point called “test_”. The fix is removing the folder “test” so when the automounter runs again it will be able to make a mount point called “test” again. As such my one liner looks for any folders in /media that end with an underscore, and removes a folder that has the same name without an underscore (if it exists) which is unlikely to end up removing anything it shouldn’t since both folders would have to exist with this naming scheme and the folder without an underscore would also have to be empty (it will spit out an error if it isn’t empty). It should be a very safe to run copy and paste to take care of the issue.

I just edited the command in my previous post slightly and now it will deal with multiples as well…

osmc@VeroV:~$ cd /media
osmc@VeroV:/media$ sudo mkdir test test_ test__ test___
osmc@VeroV:/media$ ls -l
total 20
-rw-r--r-- 1 root root  232 Nov 15  2023 README
drwxr-xr-x 2 root root 4096 Dec 15 17:36 test
drwxr-xr-x 2 root root 4096 Dec 15 17:36 test_
drwxr-xr-x 2 root root 4096 Dec 15 17:36 test__
drwxr-xr-x 2 root root 4096 Dec 15 17:36 test___
osmc@VeroV:/media$ find /media -type d -name '*_'|sed 's/_$//'|xargs sudo rmdir
osmc@VeroV:/media$ ls -l
total 8
-rw-r--r-- 1 root root  232 Nov 15  2023 README
drwxr-xr-x 2 root root 4096 Dec 15 17:36 test___
osmc@VeroV:/media$

@DBMandrake I thought we fixed this kind of thing years ago and cleaned up /media on boot?

What filesystem does the drive use?