LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware
User Name
Password
Linux - Hardware This forum is for Hardware issues.
Having trouble installing a piece of hardware? Want to know if that peripheral is compatible with Linux?

Notices


Reply
  Search this Thread
Old 08-21-2023, 10:52 PM   #1
DarkWolf113440
LQ Newbie
 
Registered: Jul 2009
Location: Montana, USA
Distribution: OpenSUSE 13.2
Posts: 16

Rep: Reputation: 4
Need guidance on configuring mount options for removable storage devices


Hi folks, I need some help figuring out how to adjust mount options for removable media, specifically USB thumb drives. What I'm trying to do is set up 2FA logins on Ubuntu using pam_usb and a thumb drive as an authentication token. I've got pam_usb installed and configured, but it's a little buggy. Basically, my understanding of how the process is suppose to work is this:

1. plug in USB thumb drive

2. type username at login prompt (or GUI login screen)

3. pam_usb reads it's config, looks for the USB thumb drive, finds the OTP authentication token, reads from the token

4. If the authentication is good, pam_usb completes the login process and writes a new OTP value to the thumb drive

Now, here's the problem, after a successful authentication, I pull the thumb drive from the USB port and hang it back around my neck. Next time I try to use the USB thumb drive to login, the authentication fails.

I've discovered that this is because without properly unmounting the drive (yeah, I know that's the whole idea behind unmounting the device) the new OTP value never actually gets written out to the thumb drive, so the next time I use it, it's reading the old, expired OTP token. What I want to do is fix it so that when I insert the thumb drive, it auto mounts with the sync option so that the new OTP token is written out to the drive immediately, so that I can simply pull the thumb drive and have no problem next time I use it.

I've been reading man pages and posts and I'm not really seeing anything directly on point here, I'm reading myself in circles, going from fstab to udev rules to udisks2 to polkit, etc... Can anyone point me in the right direction here, it sure would be appreciated. Thanks!
 
Old 08-22-2023, 05:41 AM   #2
yancek
LQ Guru
 
Registered: Apr 2008
Distribution: Slackware, Ubuntu, PCLinux,
Posts: 11,155

Rep: Reputation: 2657Reputation: 2657Reputation: 2657Reputation: 2657Reputation: 2657Reputation: 2657Reputation: 2657Reputation: 2657Reputation: 2657Reputation: 2657Reputation: 2657
Does this software work as intended if you correctly unmount the usb before removing it? Seems like the simplest solution. You should be able to place an entry in fstab for this to work. What have you tried in fstab? Or perhaps a script to run on boot. I'm not familiar with the software so can't really help with that. Good luck.
 
Old 08-22-2023, 02:36 PM   #3
onebuck
Moderator
 
Registered: Jan 2005
Location: Central Florida 20 minutes from Disney World
Distribution: SlackwareŽ
Posts: 13,969
Blog Entries: 46

Rep: Reputation: 3194Reputation: 3194Reputation: 3194Reputation: 3194Reputation: 3194Reputation: 3194Reputation: 3194Reputation: 3194Reputation: 3194Reputation: 3194Reputation: 3194
Member Response

Hi,

Personally, I would do a 'sync' then a 'umount' of the device to insure that the everything is flushed to the persistent storage (your USB device). I know 'umount' should process a clean dis-mount but I'm old school an wish to have things flushed properly and don't like a lazy 'umount'. I do suggest you look at the 'man' for each command. By just pulling the USB your a likely to cause issues period.

Hope this helps.
 
Old 08-22-2023, 11:59 PM   #4
DarkWolf113440
LQ Newbie
 
Registered: Jul 2009
Location: Montana, USA
Distribution: OpenSUSE 13.2
Posts: 16

Original Poster
Rep: Reputation: 4
Thanks onebuck and yancek for your responses. I haven't modified my fstab yet, my understanding (and please correct me if I'm wrong on this) is that fstab really wasn't intended for removable data storage devices, only for devices that are and will for the most part remain connected to the system such as internal drives. As for manually ejecting (unmounting) the device, it does work most of the time, though not always, sometimes for reasons I haven't figured out yet, when I successfully login using the USB key, unmount it and use it again later, it won't work again, but I think that's another unrelated issue. The reason I am looking for a cache syncing solution here is mainly for ease of use. The USB thumb drive I'm using is on a lanyard (so I don't lose it, as I'm famous for doing) and for occasions when I'm using my system(s) (if this works I have other command line mode Linux boxes I want to use this on), it's simply quicker and easier to just pull the USB key, and hang it back around my neck rather then going through the process of figuring out where the USB key showed up in the /dev tree and then umounting it, which may result in me getting sidetracked and forgetting the USB key. From what I've read, others have had trouble too with pam_usb not syncing the new OTP token to the USB device. I don't know if the cause of what others are experiencing is the same, I suspect file permission issues in some of those cases, I did have that issue as well, but that was easily resolved. I considered writing a small program that would run a CRC on the OTP token file and then monitor the OTP token file's access time and when that changes, run another CRC to see if the contents of the file has indeed changed and if so, force a cache flush, but I'm not sure if the CRC would be coming from the actual file on the USB device or on the cached, updated version waiting to be written to the device.

I know this all may seem as though I making a mountain out of a mole hill here, but I believe there's a way to do this, I remember years ago seeing something relating to changing the caching mode of removable devices, I just don't remember where it was or how to go about doing it.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
How to always mount removable devices with "noatime"? make Linux - Software 1 11-19-2008 12:32 AM
hal-storage-mount-removable no <-- (action, result) flebber SUSE / openSUSE 2 10-20-2007 07:58 AM
USB stick - hal-storage-removable-mount refused serge_shp Linux - Software 1 07-01-2007 07:53 PM
removable (usb-)devices mount points zlin50 Slackware 6 05-29-2006 05:34 PM
On the fly mount points for removable storage disks kite Slackware 1 10-09-2005 08:19 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware

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