LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
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


Reply
  Search this Thread
Old 05-15-2021, 07:42 PM   #1
dorlow
LQ Newbie
 
Registered: Nov 2009
Posts: 8

Rep: Reputation: 0
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.
 
Old 05-15-2021, 07:50 PM   #2
frankbell
LQ Guru
 
Registered: Jan 2006
Location: Virginia, USA
Distribution: Slackware, Ubuntu MATE, Mageia, and whatever VMs I happen to be playing with
Posts: 19,363
Blog Entries: 28

Rep: Reputation: 6150Reputation: 6150Reputation: 6150Reputation: 6150Reputation: 6150Reputation: 6150Reputation: 6150Reputation: 6150Reputation: 6150Reputation: 6150Reputation: 6150
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?
 
Old 05-15-2021, 08:02 PM   #3
dorlow
LQ Newbie
 
Registered: Nov 2009
Posts: 8

Original Poster
Rep: Reputation: 0
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.
 
Old 05-15-2021, 08:09 PM   #4
frankbell
LQ Guru
 
Registered: Jan 2006
Location: Virginia, USA
Distribution: Slackware, Ubuntu MATE, Mageia, and whatever VMs I happen to be playing with
Posts: 19,363
Blog Entries: 28

Rep: Reputation: 6150Reputation: 6150Reputation: 6150Reputation: 6150Reputation: 6150Reputation: 6150Reputation: 6150Reputation: 6150Reputation: 6150Reputation: 6150Reputation: 6150
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/?
 
Old 05-15-2021, 08:09 PM   #5
dorlow
LQ Newbie
 
Registered: Nov 2009
Posts: 8

Original Poster
Rep: Reputation: 0
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
 
Old 05-15-2021, 08:13 PM   #6
computersavvy
Senior Member
 
Registered: Aug 2016
Posts: 3,345

Rep: Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484
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.
 
Old 05-15-2021, 08:19 PM   #7
frankbell
LQ Guru
 
Registered: Jan 2006
Location: Virginia, USA
Distribution: Slackware, Ubuntu MATE, Mageia, and whatever VMs I happen to be playing with
Posts: 19,363
Blog Entries: 28

Rep: Reputation: 6150Reputation: 6150Reputation: 6150Reputation: 6150Reputation: 6150Reputation: 6150Reputation: 6150Reputation: 6150Reputation: 6150Reputation: 6150Reputation: 6150
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.
 
Old 05-15-2021, 11:42 PM   #8
ondoho
LQ Addict
 
Registered: Dec 2013
Posts: 19,872
Blog Entries: 12

Rep: Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053
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.
 
Old 05-15-2021, 11:56 PM   #9
mrmazda
LQ Guru
 
Registered: Aug 2016
Location: SE USA
Distribution: openSUSE 24/7; Debian, Knoppix, Mageia, Fedora, others
Posts: 5,852
Blog Entries: 1

Rep: Reputation: 2074Reputation: 2074Reputation: 2074Reputation: 2074Reputation: 2074Reputation: 2074Reputation: 2074Reputation: 2074Reputation: 2074Reputation: 2074Reputation: 2074
Quote:
Originally Posted by frankbell View Post
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.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Replacing string by incrementing number mzh Programming 7 06-01-2011 05:43 AM
LXer: Add an Auto-Incrementing Build-Number to Your Build Process LXer Syndicated Linux News 0 07-09-2008 01:00 AM
Number incrementing using regular expressions fudam Linux - General 3 11-28-2006 12:58 AM
Automaticly incrementing Version Number BoldKiller Programming 7 03-26-2005 12:08 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 07:32 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration