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 |
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.
 |
GNU/Linux Basic Guide
This 255-page guide will provide you with the keys to understand the philosophy of free software, teach you how to use and handle it, and give you the tools required to move easily in the world of GNU/Linux. Many users and administrators will be taking their first steps with this GNU/Linux Basic guide and it will show you how to approach and solve the problems you encounter.
Click Here to receive this Complete Guide absolutely free. |
|
 |
01-29-2009, 05:15 AM
|
#1
|
|
LQ Newbie
Registered: Jan 2009
Posts: 8
Rep:
|
How to poll for USB devices available to mount (with auto-mounting disabled)?
I don't want any old USB thumb drive mounting to my system therefore I'm trying to create a script that controls the mounting of USB devices and the permissions given to them. These permissions depend on other variables (eg. am I connected to a network?) therefore I don't think I can just add a device to a list of approved devices for mounting and block everything else. I need some dynamic way of doing it.
I've disabled the auto-mounting of removable/hot-pluggable drives, I now need some way of polling for the insertion of a USB device. Any ideas what I need to poll?
Tom
|
|
|
|
01-29-2009, 05:26 AM
|
#2
|
|
Moderator
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733
|
Whether a local user or remote user can mount a usb drive is usually handled by PolicyKit.
Since you disabled automounting, you might consider manually mounting usb drives instead with entries in /etc/fstab determining the permissions and ownership. The first field in /etc/fstab can use UUID=<filesystem_uid> instead of the device node. This is recommended anyway for removable drives because you can't depend on which device node it will be assigned to.
Also, for removable drives, be sure to use the "noauto" option.
For fat32 filesystems, which is the most common for pendrives, you determine the permissions and ownership in the mount command. So you can have an /etc/fstab entry for each pendrive you own and use different permissions or ownership. Using the "user" or "users" option, you can even mount the pendrive as a normal user. The permissions you use could mean that only you have permission to enter the mounted directory.
|
|
|
|
01-29-2009, 05:41 AM
|
#3
|
|
LQ Newbie
Registered: Jan 2009
Posts: 8
Original Poster
Rep:
|
I'd really like to be able to run the polling and mounting automatically using a daemon. I think that fdisk -l will give me a list of all devices connected (but not necessarily mounted) so I could run that every few seconds from a script to check if anything has been inserted into a USB socket, but this seems a bit clumsy.
I suppose I could dig through the source for fdisk and find out what it uses but I thought there might perhaps be an easier way?
Last edited by tl3462; 01-29-2009 at 06:19 AM.
|
|
|
|
01-29-2009, 06:33 AM
|
#4
|
|
Moderator
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733
|
If you don't want to use HAL, look at "ivman".
|
|
|
|
01-29-2009, 07:19 AM
|
#5
|
|
Senior Member
Registered: Nov 2008
Location: Paris, France
Distribution: Slackware-14.0 on a Lenovo T61 6457-4XG
Posts: 2,833
|
Poll for output of 'lsusb' or the file /proc/bus/usb/devices
Last edited by Didier Spaier; 01-29-2009 at 07:22 AM.
|
|
|
|
01-29-2009, 08:49 AM
|
#6
|
|
LQ Newbie
Registered: Jan 2009
Posts: 8
Original Poster
Rep:
|
Brilliant, ivman looks to be exactly what I was after.
I tried working with HAL - I found a python script that supposedly interacts with HAL 0.4 at http://people.redhat.com/davidz/hal-...c.html#AEN2152 but I have 0.5 I think so this wasn't giving me any joy.
ivman seems to be controlled by a configuration file so this might possibly be the answer but I haven't dug around for any documentation yet
... if not lsusb will do as my clumsy backup option!
Thank you both!
|
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -5. The time now is 11:07 AM.
|
|
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
|
|