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?

I think it was an NTFS drive but I don’t remember 100%.
All my drives are NTFS or ext4, so it’s definitely one of those two file systems.

This just happened to me again with three drives.
One is ext4 and two are NTFS.

So here’s how it looked

osmc@VeroV:~$ df
Filesystem      1K-blocks       Used  Available Use% Mounted on
devtmpfs          1923744          0    1923744   0% /dev
tmpfs             1927144       9860    1917284   1% /run
/dev/osmcroot    29916552    4868972   23816360  17% /
tmpfs             1927144          0    1927144   0% /dev/shm
tmpfs                5120          0       5120   0% /run/lock
tmpfs                4096          0       4096   0% /sys/fs/cgroup
/dev/tee            27633        417      24923   2% /tee
/dev/sdi1      7814025212 7737663460   76361752 100% /media/Seagate 8TB 5_
/dev/sda1      3907016700 3895415700   11601000 100% /media/Seagate 4TB
/dev/sdg1      7811843048 7719314956   14371456 100% /media/Seagate 8TB 8
/dev/sdd1      7811843048 5509094244 2224592168  72% /media/IronWolf 8TB 1_
/dev/sdh1      7814025212 7572990800  241034412  97% /media/Seagate 8TB 1
/dev/sdb1      4883769340 4840989056   42780284 100% /media/Seagate 5TB
/dev/sdc1      7814025212 7766578708   47446504 100% /media/Seagate 8TB 3
/dev/sde1      7811843048 7658758672   74927740 100% /media/Seagate 8TB 7
/dev/sdf1      7814025212 7691757752  122267460  99% /media/Seagate 8TB 4
/dev/sdj1      7814025212 7767162760   46862452 100% /media/Seagate 8TB 2
/dev/sdk2      7813894140 7683684616  130209524  99% /media/Seagate 8TB 6_
tmpfs              385428          0     385428   0% /run/user/1000

Before doing any commands I tried just doing a reboot since @sam_nazarko was under the impression that /media/ gets cleaned out at boot but it didn’t.

@darwindesign I tied your command but it doesn’t escape for drives with spaces in them.

osmc@VeroV:~$ find /media -type d -name '*_'|sed '$ s/_$//'|xargs sudo rmdir && reboot
find: '/media/IronWolf 8TB 1': Permission denied
find: '/media/IronWolf 8TB 1_/lost+found': Permission denied
find: '/media/Seagate 8TB 8/lost+found': Permission denied
find: '/media/Seagate 8TB 6': Permission denied
find: '/media/Seagate 8TB 5': Permission denied
find: '/media/Seagate 8TB 7/lost+found': Permission denied
rmdir: failed to remove '/media/Seagate': No such file or directory
rmdir: failed to remove '8TB': No such file or directory
rmdir: failed to remove '6_': No such file or directory
rmdir: failed to remove '/media/IronWolf': No such file or directory
rmdir: failed to remove '8TB': No such file or directory
rmdir: failed to remove '1_': No such file or directory
rmdir: failed to remove '/media/Seagate': No such file or directory
rmdir: failed to remove '8TB': No such file or directory
rmdir: failed to remove '5': No such file or directory
osmc@VeroV:~$ sudo -s
root@VeroV:/home/osmc# find /media -type d -name '*_'|sed '$ s/_$//'|xargs sudo rmdir && reboot
rmdir: failed to remove '/media/Seagate': No such file or directory
rmdir: failed to remove '8TB': No such file or directory
rmdir: failed to remove '6_': No such file or directory
rmdir: failed to remove '/media/IronWolf': No such file or directory
rmdir: failed to remove '8TB': No such file or directory
rmdir: failed to remove '1_': No such file or directory
rmdir: failed to remove '/media/Seagate': No such file or directory
rmdir: failed to remove '8TB': No such file or directory
rmdir: failed to remove '5': No such file or directory

So I just shut down my V and disconnected the drives, then booted it back up and cleared the /media/ directory using sudo rmdir /media/* and then plugged the USB cable back in.

osmc@VeroV:~$ df
Filesystem     1K-blocks    Used Available Use% Mounted on
devtmpfs         1923744       0   1923744   0% /dev
tmpfs            1927144    9552   1917592   1% /run
/dev/osmcroot   29916552 4863204  23822128  17% /
tmpfs            1927144       0   1927144   0% /dev/shm
tmpfs               5120       0      5120   0% /run/lock
tmpfs               4096       0      4096   0% /sys/fs/cgroup
/dev/tee           27633     417     24923   2% /tee
tmpfs             385428       0    385428   0% /run/user/1000
osmc@VeroV:~$ cd /media/
osmc@VeroV:/media$ ls
'IronWolf 8TB 1'   README  'Seagate 8TB 5'  'Seagate 8TB 6'
osmc@VeroV:/media$ sudo rmdir /media/*
rmdir: failed to remove '/media/README': Not a directory
osmc@VeroV:/media$ ls
README
osmc@VeroV:/media$ ls
'IronWolf 8TB 1'  'Seagate 4TB'  'Seagate 8TB 1'  'Seagate 8TB 3'  'Seagate 8TB 5'  'Seagate 8TB 7'
 README           'Seagate 5TB'  'Seagate 8TB 2'  'Seagate 8TB 4'  'Seagate 8TB 6'  'Seagate 8TB 8'
osmc@VeroV:/media$ df
Filesystem      1K-blocks       Used  Available Use% Mounted on
devtmpfs          1923744          0    1923744   0% /dev
tmpfs             1927144       9860    1917284   1% /run
/dev/osmcroot    29916552    4863308   23822024  17% /
tmpfs             1927144          0    1927144   0% /dev/shm
tmpfs                5120          0       5120   0% /run/lock
tmpfs                4096          0       4096   0% /sys/fs/cgroup
/dev/tee            27633        417      24923   2% /tee
tmpfs              385428          0     385428   0% /run/user/1000
/dev/sda1      3907016700 3895415700   11601000 100% /media/Seagate 4TB
/dev/sdb1      4883769340 4840989056   42780284 100% /media/Seagate 5TB
/dev/sdc1      7814025212 7766578708   47446504 100% /media/Seagate 8TB 3
/dev/sdd1      7811843048 5509094244 2224592168  72% /media/IronWolf 8TB 1
/dev/sde1      7811843048 7658758672   74927740 100% /media/Seagate 8TB 7
/dev/sdf1      7814025212 7691757752  122267460  99% /media/Seagate 8TB 4
/dev/sdg1      7811843048 7719314956   14371456 100% /media/Seagate 8TB 8
/dev/sdh1      7814025212 7572990800  241034412  97% /media/Seagate 8TB 1
/dev/sdi1      7814025212 7737663460   76361752 100% /media/Seagate 8TB 5
/dev/sdj1      7814025212 7767162760   46862452 100% /media/Seagate 8TB 2
/dev/sdk2      7813894140 7683684616  130209524  99% /media/Seagate 8TB 6

Hi,

I’ve checked this and trailing mountpoints are definitely cleaned up on a reboot.

If there are multiple directories being created then you may have a faulty cable or power issue causing a number of large disconnects and reconnects. I would address this promptly. But there could also be an issue with the fact that the drives have almost identical labels.

As an aside, I am also concerned that you are running these drives at 100% capacity. This can give significant performance degradation.

Only on a reboot command or does it do it at boot regardless?
I ask since the issue is most likely caused from a crash or failure to shut down properly like a power outage.

When the device boots it is taken care of.

Weird, because that was the first thing I tried.
And even though I had nothing plugged in to the Vero I still had those three in /media/ and a README file.
So for some reason my Vero V did not clean out /media/ at boot.
Below is what showed up after I noticed the issue, shut down the Vero V, pulled power, unplugged the USB cable, plugged power back in without anything USB plugged in other than the remote dongle.
Those three mounts were still in /media/ for me.

osmc@VeroV:~$ df
Filesystem     1K-blocks    Used Available Use% Mounted on
devtmpfs         1923744       0   1923744   0% /dev
tmpfs            1927144    9552   1917592   1% /run
/dev/osmcroot   29916552 4863204  23822128  17% /
tmpfs            1927144       0   1927144   0% /dev/shm
tmpfs               5120       0      5120   0% /run/lock
tmpfs               4096       0      4096   0% /sys/fs/cgroup
/dev/tee           27633     417     24923   2% /tee
tmpfs             385428       0    385428   0% /run/user/1000
osmc@VeroV:~$ cd /media/
osmc@VeroV:/media$ ls
'IronWolf 8TB 1'   README  'Seagate 8TB 5'  'Seagate 8TB 6'