Linux - Software This 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.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
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.
|
 |
05-15-2021, 07:42 PM
|
#1
|
LQ Newbie
Registered: Nov 2009
Posts: 8
Rep:
|
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.
|
|
|
05-15-2021, 07:50 PM
|
#2
|
LQ Guru
Registered: Jan 2006
Location: Virginia, USA
Distribution: Slackware, Ubuntu MATE, Mageia, and whatever VMs I happen to be playing with
Posts: 19,947
|
Just to fill out the record, what distro/version are you using? (Your user agent icon says Ubuntu, but so too do many of the *buntus.)
Did you add the USB drive to your /etc/fstab file?
Have you checked the log files to see if they shed any light on this?
|
|
|
05-15-2021, 08:02 PM
|
#3
|
LQ Newbie
Registered: Nov 2009
Posts: 8
Original Poster
Rep:
|
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.
|
|
|
05-15-2021, 08:09 PM
|
#4
|
LQ Guru
Registered: Jan 2006
Location: Virginia, USA
Distribution: Slackware, Ubuntu MATE, Mageia, and whatever VMs I happen to be playing with
Posts: 19,947
|
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/?
|
|
|
05-15-2021, 08:09 PM
|
#5
|
LQ Newbie
Registered: Nov 2009
Posts: 8
Original Poster
Rep:
|
I just added it to fstab. I guess I'll find out if I rebooted if I messed it up... I think I got it right. I put this in...
/dev/sda1 /media/david/Backup ext4 defaults 0 2
|
|
|
05-15-2021, 08:13 PM
|
#6
|
Senior Member
Registered: Aug 2016
Posts: 3,345
|
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.
|
|
|
05-15-2021, 08:19 PM
|
#7
|
LQ Guru
Registered: Jan 2006
Location: Virginia, USA
Distribution: Slackware, Ubuntu MATE, Mageia, and whatever VMs I happen to be playing with
Posts: 19,947
|
I would suggest identifying it by UUID. That ensures that the same device always mounts to the same mountpoint.
Here's an example from my fstab for an external HDD I keep permanently connected:
Code:
UUID=5AFABB30FABB06F3 /media/sdb1 ntfs rw,auto,umask=000 1 1
You would need to use the noauto flag for a device you intend to remove and reinsert.
Here's an excellent tutorial on fstab and UUID: https://www.cyberciti.biz/faq/linux-...-update-fstab/
Last edited by frankbell; 05-15-2021 at 08:24 PM.
|
|
|
05-15-2021, 11:42 PM
|
#8
|
LQ Addict
Registered: Dec 2013
Posts: 19,872
|
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.
|
|
|
05-15-2021, 11:56 PM
|
#9
|
LQ Guru
Registered: Aug 2016
Location: SE USA
Distribution: openSUSE & OS/2 24/7; Debian, Knoppix, Mageia, Fedora, others
Posts: 6,537
|
Quote:
Originally Posted by frankbell
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.
|
|
|
All times are GMT -5. The time now is 02:34 PM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|