LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 05-18-2010, 11:01 PM   #1
Josh000
Member
 
Registered: Aug 2009
Distribution: Slackware 13 64bit
Posts: 534

Rep: Reputation: 35
Mounting suggestions


Hello, I am after some suggestions on how I could change my mounting method to suit my needs.

At the moment, I simply mount the device to a location as root.

What I would like to do is setup automounting, but in a particular way. In particular, I would like it if when I put in a usb stick, it would be automatically mounted to say /media/usb1, and a second stick would be to /media/usb2, while an esata connected drive would go to /media/sata1

Even better would be if I put in the first usb stick and it was mounted at /media/usb1, it would *always* be mounted at /media/usb1, no matter what order I connected it to my computer in

I would also like to quickly ask about the difference about udev rules and HAL. At the moment I have only used HAL for my touchpad, and have not touched udev at all. What are the differences/advantages etc...
 
Old 05-19-2010, 12:15 AM   #2
Richard Cranium
Senior Member
 
Registered: Apr 2009
Location: McKinney, Texas
Distribution: Slackware64 15.0
Posts: 3,858

Rep: Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225
Is this in a graphical environment or not?

If you are using KDE, XFCE, or Gnome *and* you are a member of the plugdev group, then your USB drives will be automatically mounted for you. You should be able to read and write to them.

If you are not running under those environments, then you should try pmount and ivman. Both are available at Slackbuilds.
 
Old 05-19-2010, 12:47 AM   #3
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578
Blog Entries: 31

Rep: Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208
Quote:
Originally Posted by Josh000 View Post
Even better would be if I put in the first usb stick and it was mounted at /media/usb1, it would *always* be mounted at /media/usb1, no matter what order I connected it to my computer in

I would also like to quickly ask about the difference about udev rules and HAL. At the moment I have only used HAL for my touchpad, and have not touched udev at all. What are the differences/advantages etc...
A local udev rules file is the obvious solution. The best reference is Daniel Drake's Writing udev rules but is a little dated, for example udevadm has replaced udevinfo on recent systems.

udev was layered on top of HAL but the intention is to move HAL functionality into udev and drop HAL.
 
Old 05-19-2010, 03:28 AM   #4
Josh000
Member
 
Registered: Aug 2009
Distribution: Slackware 13 64bit
Posts: 534

Original Poster
Rep: Reputation: 35
Thanks for your replies

Richard - I'm not interested in relying on a specific DE for a solution, and pmount and ivman don't meet my needs as I described them. Thanks though.

Catkin - So udev is the eventual replacement for HAL? Or will it always be a compliment?

Is what I want possible as I described exactly, with just udev rules?
 
Old 05-19-2010, 04:53 AM   #5
Richard Cranium
Senior Member
 
Registered: Apr 2009
Location: McKinney, Texas
Distribution: Slackware64 15.0
Posts: 3,858

Rep: Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225
HAL is a layer on top of udev (catkin has it backwards). HAL is going away and most of the functionality in HAL is supposed to be pushed into udev.

udev as configured on a slackware 13.0 box will automatically create devices for you in /dev/disks that allow you to reference your USB stick by id, label, name, path (in /sys), and uuid. See /lib/udev/rules.d/60-persistent-storage.rules and examine the contents of /dev/disks before and after you plug in one of your USB sticks.

The section "Running external programs upon certain events" in the link catkin gave you will do what you want, but you'll have to persist the match between the device uuids and the sequenced names that you prefer yourself. As well as perform the lookup each time.
 
Old 05-19-2010, 07:27 AM   #6
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578
Blog Entries: 31

Rep: Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208
Quote:
Originally Posted by Josh000 View Post
So udev is the eventual replacement for HAL? Or will it always be a compliment?

Is what I want possible as I described exactly, with just udev rules?
According to the linked Wikipedia page, HAL's functionality will be built into udev and HAL phased out.

I'm not sure whether you can do what you want entirely with udev rules; it may require a small script to be run from udev rules. See this LQ post for an outline of how to do it. The technique works but may not be the most elegant way of doing it. If you want sample code to log to /var/log/messages, please ask.
 
Old 05-19-2010, 07:33 AM   #7
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578
Blog Entries: 31

Rep: Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208
Quote:
Originally Posted by Richard Cranium View Post
The section "Running external programs upon certain events" in the link catkin gave you will do what you want, but you'll have to persist the match between the device uuids and the sequenced names that you prefer yourself.
There may be attributes of the USB sticks that allow unique identification without UUIDs, perhaps a serial number or perhaps Josh000 only has one USB stick of each identifiable model/revision. The udevadm info -a -p <path> command will show.
 
Old 05-19-2010, 08:00 AM   #8
Richard Cranium
Senior Member
 
Registered: Apr 2009
Location: McKinney, Texas
Distribution: Slackware64 15.0
Posts: 3,858

Rep: Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225
Quote:
Originally Posted by catkin View Post
There may be attributes of the USB sticks that allow unique identification without UUIDs, perhaps a serial number or perhaps Josh000 only has one USB stick of each identifiable model/revision. The udevadm info -a -p <path> command will show.
Good point.

However, he didn't appear to believe that pmount and ivman would do what he wanted, so I think that he really does want the first usb stick that he sticks into a usb port of that machine will always be mounted on /media/usb1 forevermore.
 
Old 05-19-2010, 09:26 AM   #9
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578
Blog Entries: 31

Rep: Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208
Quote:
Originally Posted by Richard Cranium View Post
I think that he really does want the first usb stick that he sticks into a usb port of that machine will always be mounted on /media/usb1 forevermore.
That's doable by reasonably simple script called from a udev rule.
 
Old 05-19-2010, 10:57 AM   #10
Richard Cranium
Senior Member
 
Registered: Apr 2009
Location: McKinney, Texas
Distribution: Slackware64 15.0
Posts: 3,858

Rep: Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225
Quote:
Originally Posted by catkin View Post
That's doable by reasonably simple script called from a udev rule.
True, but the script needs to "remember" old assignments so there has to be persisted state somewhere. If he has a lot of usb sticks, the lookup could get slow if he isn't careful. :-)
 
Old 05-19-2010, 10:47 PM   #11
Josh000
Member
 
Registered: Aug 2009
Distribution: Slackware 13 64bit
Posts: 534

Original Poster
Rep: Reputation: 35
Thanks guys,

To clarify what I was after, it was basically windowsish behaviour. ie the same drive letter will be assigned each time, unless that drive letter has been taken already. Obviously with mount points instead of drive letters.

Basically, an unknown device would take the first available drive letter(mount pount...with auto generated as needed I guess), and any device previously used would be assigned the same drive letter it was before, unless already taken.

Having a list of every removable media I ever use with its own unique mount point certainly isn't a solution
 
Old 05-19-2010, 11:39 PM   #12
Richard Cranium
Senior Member
 
Registered: Apr 2009
Location: McKinney, Texas
Distribution: Slackware64 15.0
Posts: 3,858

Rep: Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225
I don't see why you thought pmount and ivman wouldn't do what you wanted. USB devices will be mounted at /media/usbdisk, /media/usbdisk1, /media/usbdisk2, etc.

I have to admit that...
Quote:
Even better would be if I put in the first usb stick and it was mounted at /media/usb1, it would *always* be mounted at /media/usb1, no matter what order I connected it to my computer in
...sure reads like you wanted a persistent mapping of usb sticks to mountpoints.

Whatever floats your boat.
 
Old 05-20-2010, 12:03 AM   #13
Josh000
Member
 
Registered: Aug 2009
Distribution: Slackware 13 64bit
Posts: 534

Original Poster
Rep: Reputation: 35
Quote:
Originally Posted by Richard Cranium View Post
I don't see why you thought pmount and ivman wouldn't do what you wanted. USB devices will be mounted at /media/usbdisk, /media/usbdisk1, /media/usbdisk2, etc.
I haven't used them, I was just going by what I had read.

pmount and ivman seem to satisfy the mounting as a normal user

Quote:
I have to admit that......sure reads like you wanted a persistent mapping of usb sticks to mountpoints.
Well, I do, but not as you and catkin implied. I had hoped that comparing it w=to windows drive letters cleared things up, but apparantly not.

Basically...lets say I have 3 usb sticks, a, b and c. They are mounted with a on /media/usb2, b on /media/usb1 and c on usb3.

What I want, is that whenever I put in usb stick a, it will always be mounted on /media/usb2, regardless of if /media/usb1 is available or not.

So if I have usbsticks b and a mounted, they will automount at /media/usb1 and /media/usb2 respectivley. A new never used before disk will then go to /media/usb3.

If I then unmount usb disk b, freeing up /media/usb1, and place in a second never used before stick, it will go to /media/usb1 since it is currently unused.

If I then put in usb stick a again, it will be mounted at the newly created /media/usb4.


Does that make sense? If it does, are you saying pmount and ivman fit the bill?
 
Old 05-20-2010, 03:54 AM   #14
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578
Blog Entries: 31

Rep: Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208
Thanks for clarifying the requirement Josh000; it is what I had understood from the beginning.

I have briefly netsearched lvman and pmount but do not understand how they can be used to do what you want but that may be my faulty understanding. One concern is that the last release of lvman was in February 07.

As long as each USB stick can be uniquely identified, your requirement could be satisfied by a bash script run from a udev rule and using a configuration file to remember past USB stick to /media/usb<n> mounts. In the case of a new USB stick the script would have to create the new mountpoint directory and add to its configuration file.

The trickiest part is the unique identification of each USB stick. AFAIK there is no universal standard amongst USB stick manufacturers specifying which USB attributes are provided. This will be tricky regardless of how the mount is done. Having a UUID on each USB stick's file system would make it a lot easier; it could be found by navigating the sysfs. Would that be OK for you?
 
Old 05-20-2010, 04:35 AM   #15
Josh000
Member
 
Registered: Aug 2009
Distribution: Slackware 13 64bit
Posts: 534

Original Poster
Rep: Reputation: 35
Hi catkin,

thanks for your reply.


I was mainly interested if such a thing were possible, and it looks like an interesting project.

Any solution that relies on files existing on the usb filesystem would not be acceptable.

I would think the best way would be to look at whatever unique information there is, and use that....otherwise I might have to settle for manufacturer + size as an identifier.

This would not keep it unique, but would be "close enough" so to speak.
 
  


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



LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

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