SlackwareThis Forum is for the discussion of Slackware 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.
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.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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...
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.
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.
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.
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.
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.
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.
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. :-)
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
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.
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?
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?
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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.