why is my mounted drive keep incrementing a number at the end to the folder?
Linux - SoftwareThis forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
why is my mounted drive keep incrementing a number at the end to the folder?
Ok, I'm trying to get back into Linux. I've been out of it for a few years. I know I've ran into this before. I have a USB drive that I have mounted to /media/backup. I just checked and there is now a /media/backup, /media/backup1, and media/backup2. I think everytime I reboot, it can't mount to the old folder so it auto creates a new folder to mount it to. I'm trying to create a crontab job that writes files to it, but it's kind of hard when it keeps incrementing up.
I'm using Linux Mint. But, I've had this problem in the past with Ubuntu and I'm sure it's not a distro specific issue at all. I didn't add it manually to fstab. I'm a little hesitant because in the past, when I've messed with fstab and rebooted, I can't boot anymore, at least to gui. I know I can just go back to /etc/fstab and change it back.... so it's not a huge deal if it breaks that. But, it seems like it should just work as-is. I was hoping of a more user-friendly way to keep the mount point than to mess with fstab.
I've not encountered anything like this. In my experience, newer distros mount removable media that's not included in /etc/fstab to something like /run/media/[username]/ unless directed otherwise.
What command are you using to mount the device to /media/?
A couple of thoughts since the system is auto-mounting the drive and it appears to have the file system labeled so it mounts with the label.
If you check the mount point with the drive unplugged, are there any directories there? Maybe a relic of the backup software writing something to the drive when it was not plugged in, so it just wrote to a directory instead. I have seen that happen myself.
Also, is it possible that you have unplugged it then plugged it back in before udev has had time to clear out the old entry and a new entry had to be made? This can easily happen if plugging it in is not a firm single push but instead allows intermittent connections. This can result in the incremental numbers.
I've had this problem myself at some point, and I believe it was fixed by manually removing all folders under /media. Possibly even removing /media itself.
Is this an old Ubuntu install that has been dist-upgraded over the years? When did you start it, and at what version is it now?
Running automated stuff on a dynamically automounted device probably isn't such a good idea.
Therefore I think the fstab solution is valid and good, but I wouldn't use the same folder udisks (or equiv.) uses, i.e. /media.
I would suggest identifying it by UUID. That ensures that the same device always mounts to the same mountpoint.
Mounting by LABEL is equivalent, and much easier on most human brains if and when labels need managing, than by UUID. All my native filesystem entries in my hundreds of fstabs are by LABEL since well over a decade ago, without issues, even though I do a heavy amount of partition cloning for backup, testing and upgrade purposes.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.