LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 02-05-2024, 04:02 AM   #1
ipux
LQ Newbie
 
Registered: Jan 2024
Posts: 8

Rep: Reputation: 0
How can I automatically mount any USB flash drive on the same mount point?


Hi,

In my case, I have a computer with several users, and it's possible that some of the participants will use their own USB keys to work on the machine in question.

How can I make sure that once the USB stick is plugged in, it's available in rw on all users, and that it doesn't mount in the current user's directory?

I've seen that it's possible to assign rules in the fstab configuration, but this requires (as far as I know) entering the corresponding UUID of the USB key, which isn't possible in my case as it's never the same keys.

To put it simply, I'd like it to work like Windows: when a USB key is plugged in, it's available to all users.

Thanks in advance.
 
Old 02-05-2024, 04:42 AM   #2
hazel
LQ Guru
 
Registered: Mar 2016
Location: Harrow, UK
Distribution: LFS, AntiX, Slackware
Posts: 7,691
Blog Entries: 19

Rep: Reputation: 4495Reputation: 4495Reputation: 4495Reputation: 4495Reputation: 4495Reputation: 4495Reputation: 4495Reputation: 4495Reputation: 4495Reputation: 4495Reputation: 4495
Find out what the kernel calls the usb drive by plugging it in and running
Code:
dmesg|tail -10
It's /dev/sdb on most setups, but not always. I once had a printer with a built-in disk drive and my kernel registered that as /dev/sdb and usb keys as /dev/sdc.

Whatever drive designation the kernel uses, use that in /etc/fstab. You don't have to use UUIDs.

Last edited by hazel; 02-05-2024 at 04:44 AM.
 
Old 02-05-2024, 06:09 AM   #3
yancek
LQ Guru
 
Registered: Apr 2008
Distribution: Slackware, Ubuntu, PCLinux,
Posts: 10,580

Rep: Reputation: 2500Reputation: 2500Reputation: 2500Reputation: 2500Reputation: 2500Reputation: 2500Reputation: 2500Reputation: 2500Reputation: 2500Reputation: 2500Reputation: 2500
The Linux systems I've used generally mount external devices under /media or /run directories not the user /home directory. If I understand your post, there will be several users on this computer and they will likely use their own usb sticks (multiple) and you want all of them to have total access to any usb to write to and/or delete anything on the usb, is that correct? If you give users write permissions, you give them permission to delete. What filesystem type would you expect to be on them? Would this be expected to vary? If you expect windows filesystems, the method will be a bit different.
 
Old 02-05-2024, 06:35 AM   #4
ipux
LQ Newbie
 
Registered: Jan 2024
Posts: 8

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by hazel View Post
Find out what the kernel calls the usb drive by plugging it in and running
Code:
dmesg|tail -10
It's /dev/sdb on most setups, but not always. I once had a printer with a built-in disk drive and my kernel registered that as /dev/sdb and usb keys as /dev/sdc.

Whatever drive designation the kernel uses, use that in /etc/fstab. You don't have to use UUIDs.
Hi,

Yes, it's /dev/sdb in my case too, Would you have an example of configuration for the file? Should I put something like /dev/sdbXX or maybe /dev/sdb* so that any plug-in key works?

Thanks
 
Old 02-05-2024, 06:43 AM   #5
hazel
LQ Guru
 
Registered: Mar 2016
Location: Harrow, UK
Distribution: LFS, AntiX, Slackware
Posts: 7,691
Blog Entries: 19

Rep: Reputation: 4495Reputation: 4495Reputation: 4495Reputation: 4495Reputation: 4495Reputation: 4495Reputation: 4495Reputation: 4495Reputation: 4495Reputation: 4495Reputation: 4495
Quote:
Originally Posted by ipux View Post
Yes, it's /dev/sdb in my case too, Would you have an example of configuration for the file? Should I put something like /dev/sdbXX or maybe /dev/sdb* so that any plug-in key works?
Here is a line from my fstab:
Code:
/dev/sdb1        /media/usb       vfat        user,noauto      0   0
"user" means that anyone can mount a device but only the same person can unmount it. "noauto" prevents the startup scripts from trying to automatically mount a plugin device that isn't there.

I don't know if you can allow for different partitioning models. When you buy a memory stick, it typically has a single partition formatted as vfat because it's designed for Windows users. They probably wouldn't repartition the drive but a Linux user might.
 
Old 02-05-2024, 06:44 AM   #6
ipux
LQ Newbie
 
Registered: Jan 2024
Posts: 8

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by yancek View Post
The Linux systems I've used generally mount external devices under /media or /run directories not the user /home directory. If I understand your post, there will be several users on this computer and they will likely use their own usb sticks (multiple) and you want all of them to have total access to any usb to write to and/or delete anything on the usb, is that correct? If you give users write permissions, you give them permission to delete. What filesystem type would you expect to be on them? Would this be expected to vary? If you expect windows filesystems, the method will be a bit different.
Hi,

Yes, that's right, I'd like them to have full access. In my case, it's in the /etc/currentuser directory. When I connect to another user, since the key was mounted in the first user's directory, I don't have access rights. With the number of USB keys that will be plugged into this computer, it's impossible to make a specific configuration per key. I think the file system will be NTFS, FAT32 or ext4.
 
Old 02-05-2024, 06:47 AM   #7
hazel
LQ Guru
 
Registered: Mar 2016
Location: Harrow, UK
Distribution: LFS, AntiX, Slackware
Posts: 7,691
Blog Entries: 19

Rep: Reputation: 4495Reputation: 4495Reputation: 4495Reputation: 4495Reputation: 4495Reputation: 4495Reputation: 4495Reputation: 4495Reputation: 4495Reputation: 4495Reputation: 4495
Quote:
Originally Posted by ipux View Post
I think the file system will be NTFS, FAT32 or ext4.
Then you might want to put auto as the type.
 
Old 02-05-2024, 06:47 AM   #8
ipux
LQ Newbie
 
Registered: Jan 2024
Posts: 8

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by hazel View Post
Here is a line from my fstab:
Code:
/dev/sdb1        /media/usb       vfat        user,noauto      0   0
"user" means that anyone can mount a device but only the same person can unmount it. "noauto" prevents the startup scripts from trying to automatically mount a plugin device that isn't there.

I don't know if you can allow for different partitioning models. When you buy a memory stick, it typically has a single partition formatted as vfat because it's designed for Windows users. They probably wouldn't repartition the drive but a Linux user might.

Thanks for the explanations, I'll try like this.
 
Old 02-06-2024, 12:27 AM   #9
computersavvy
Senior Member
 
Registered: Aug 2016
Posts: 3,345

Rep: Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484
Note that for most usb devices there will be no partitioning done at the time purchased and they usually will be formatted as vfat. That means most devices would be seen as /dev/sdb and not /dev/sdb1 for mounting.

Also, if there is more than one device plugged in at a time they would get in sequence differing names such as sdb for the first one, sdc for the next, etc. Each would need its own mount point as well as accounting for the differing device names.

If you used the same mount point for all then only the last one mounted would be accessible as it would be mounted 'over' the previous one and the earlier one would no longer be accessible. That is a recipe for data disaster if files were open on one device then another is mounted and blocks access to the first.
 
Old 02-06-2024, 07:19 AM   #10
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,796

Rep: Reputation: 5952Reputation: 5952Reputation: 5952Reputation: 5952Reputation: 5952Reputation: 5952Reputation: 5952Reputation: 5952Reputation: 5952Reputation: 5952Reputation: 5952
I do have a few older flash drives that do not have a partition but I would say in general that most do.
Typically how they are formatted just depends on the manufacture and sometimes by size i.e. <32GB either FAT32 or exFAT and >32GB NTFS or maybe exFAT.

What distribution / version is running on this system?

Since how permissions work are different between Windows, flash drives are typically automatically mounted with read/write only for that user that is currently logged in. A custom udev rule might be necessary to mount a flash drive for access by all users.
 
Old 02-06-2024, 08:16 AM   #11
hazel
LQ Guru
 
Registered: Mar 2016
Location: Harrow, UK
Distribution: LFS, AntiX, Slackware
Posts: 7,691
Blog Entries: 19

Rep: Reputation: 4495Reputation: 4495Reputation: 4495Reputation: 4495Reputation: 4495Reputation: 4495Reputation: 4495Reputation: 4495Reputation: 4495Reputation: 4495Reputation: 4495
Quote:
Originally Posted by michaelk View Post
I do have a few older flash drives that do not have a partition but I would say in general that most do.
The last two that I bought from a stationery shop had a partition table and a single vfat partition. The kernel registers them as sdb, sdb1.
 
  


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
Can't mount USB 3.0 flash drive. -- Will mount in USB 2.0 port though. jim.thornton Linux - Newbie 17 01-03-2018 09:38 AM
[SOLVED] Usb flash drive mount point not found hewjr1000 Linux - Hardware 2 11-24-2010 07:32 AM
[SOLVED] Usb flash drive error: Unable to read mount point hewjr1000 Linux - Newbie 4 11-18-2010 05:59 PM
mount NFS to mount point then share out the mount point ionic_slim Linux - Networking 2 04-20-2008 12:17 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 10:18 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