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.
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.
If you it might be most robust to use the udevadm info -a -p <path> command to get the information because there was an LQ thread recently where someone reported that lsusb -v was reporting different information. I am willing to post information from my USB sticks to hep with the project if you like.
Last edited by catkin; 05-20-2010 at 05:29 AM.
Reason: speeling
If you it might be most robust to use the udevadm info -a -p <path> command to get the information because there was an LQ thread recently where someone reported that lsusb -v was reporting different information. I am willing to post information from my USB sticks to hep with the project if you like.
Hi catkin,
I appreciate the offer of assistance.
I am not too sure how much time I will spend on this, as it just isnt that important in the scheme of things. I was just curious
Plus, I spilet coke on my laptop yesterday, so it will probably be a while before I get back to linux stuff since that was my only PC...
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.
Well, I haven't used Microsoft Windows any more than absolutely necessary in the last 10 or so years, so I am not familiar with the way that pile of stuff works.
Quote:
Originally Posted by Josh000
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?
What you describe above is inconsistent behavior, unless you are telling me that usb stick "a" is a very special case. Plus I think the last stick you mention should be usb stick "b" instead of "a".
The pmount code will test /media/usbdisk mount points by default, using the sequence /media/usbdisk, /media/usbdisk1, /media/usbdisk2, etc. When it finds one that is in not currently in use (nothing mounted there), that's where it will mount the usb stick. (Which is pretty much how the various desktop environments that I've used do it. Nautilus just uses /media/disk, /media/disk-1, /media/disk-2, etc.)
pmount checks /etc/fstab for the device you are trying to mount and will actually use "mount" if it finds a match. So you would put an entry for usb "a" in there if it is a special usb disk that you want mounted at a specific location.
I've glossed over a couple of things, such as the actual base name for the mount point comes out of hal. That means that you can make a hal policy so that usb sticks will be mounted on /media/usb, /media/usb-1, etc.
What you describe above is inconsistent behavior, unless you are telling me that usb stick "a" is a very special case. Plus I think the last stick you mention should be usb stick "b" instead of "a".
I double checked my example, and I didn't make a mistake.
Why do you think the behaviour is inconsistant? If anything, I see it as consistant, and none of the devices would be special cases...
I double checked my example, and I didn't make a mistake.
Why do you think the behaviour is inconsistant? If anything, I see it as consistant, and none of the devices would be special cases...
I find the statements...
Quote:
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.
...and...
Quote:
If I then put in usb stick a again, it will be mounted at the newly created /media/usb4.
...to be inconsistent.
But then again, you never mentioned removing usb stick "a" at all in your example.
So, to simplify the discussion a little bit, let's assume that you have 5 usb sticks, named A, B, C, D, and E.
You plug them into your USB mega-hub in the order A, B, C, D, and E. pmount and ivman will mount them this way:
A -> /media/usbdisk
B -> /media/usbdisk-1
C -> /media/usbdisk-2
D -> /media/usbdisk-3
E -> /media/usbdisk-4
You then unmount A and E for some reason and then plug them back in; this time you plugged E in first and A second. Your mounts now look like:
A -> /media/usbdisk-4
B -> /media/usbdisk-1
C -> /media/usbdisk-2
D -> /media/usbdisk-3
E -> /media/usbdisk
In other words, the lowest numbered (or blank numbered) mount point that is not in use will be the one used to mount the next USB drive plugged into the computer. If that's what you want, pmount and ivman can do that.
I find the statements......and......to be inconsistent.
I still dont see any inconsistancy. Rather that example demonstrates what I was after very well.
I was not after just the first available mount point being used, but additionaly an automatic persistance of mount point assignation.
Quote:
In other words, the lowest numbered (or blank numbered) mount point that is not in use will be the one used to mount the next USB drive plugged into the computer. If that's what you want, pmount and ivman can do that.
Your example is just for first available mount points being used, which isn't what I want at all.
using your example, E should have been assigned to /media/usbdisk-4 despite /media/usbdisk being available, because that is where it was used.
But as the discussin revealed, this qould actually require quite a bit of work to implement, and probably isnt worth it.
I was not after just the first available mount point being used, but additionaly an automatic persistance of mount point assignation.
That's what I thought after the first time that you stated pmount and ivman wouldn't work for you. But if that's what you want, then the statements "I always want USB stick A to be mounted at /media/usb2." and "If I then put in USB stick A again, it will be mounted at the newly created /media/usb4." contradict each other since /media/usb4 is not the same place as /media/usb2 but USB stick A is USB stick A.
I believe the following is what you want:
You don't care where a given USB stick is mounted for the very first time.
You do care that once it is mounted on a given mount point, that it will always be mounted at that mount point if you ever plug it into that computer again.
Bullet number 2 implies that once you've used a mount point for a given USB stick, you will not be able to use it for any other one.
If that enumerated list is what you really want, then I agree that pmount and ivman will not do the trick.
It wouldn't be that difficult to do via a udev rule that called an external program, but you would have to have a file somewhere that maintained the mapping between the mount points that you've used and whatever you are using from udev to tell one usb stick apart from another. If you are a glutton for punishment, you could do it with bash or ash (one rather bright fellow wrote a distributed version control system in bash). Most people would use perl or python.
That's what I thought after the first time that you stated pmount and ivman wouldn't work for you. But if that's what you want, then the statements "I always want USB stick A to be mounted at /media/usb2." and "If I then put in USB stick A again, it will be mounted at the newly created /media/usb4." contradict each other since /media/usb4 is not the same place as /media/usb2 but USB stick A is USB stick A.
It isnt inconsistant. I stataed the condition that if a usb stick could not be mounted at its normoal mountpoint, then the next available must be used,
In my example /media/usb2 was taken by another stick, so it was assigned /media/usb4 instead.
Do you get what I mean?
[wuote]
Bullet number 2 implies that once you've used a mount point for a given USB stick, you will not be able to use it for any other one.
[/quote]
This isnt so. A given mount point can be used by any stick not used previously as long as it is available.
Any stick used previously should be mounted where it was previously as long as it is available, otherwise the next available mount point should be used.
Quote:
If that enumerated list is what you really want, then I agree that pmount and ivman will not do the trick.
Yup, and it loks like too much trouble to make it work. It was just an exercise in curiosity
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. :-)
I run Ubuntu variants. When I connect USB sticks or media cards, they are automatically mounted as /media/xxxx, where "xxxx" is the volume label of the file system. For example, most of my media cards as Secure
Digital (SD) or Compact Flash (CF). I set the volume labels to "SDtitle" or "CFtitle" and assign a meaningful title string. When connected, a media card then always mounts as /media/SDthisTitle or /media/CFthatTitle.
I got all of this behavior for free simply by setting the volume label.
By the way, my NTFS file systems -- for that other OS -- also mount as /media/someLabel for each of the C:, D:, etc partitions.
~~~ 0;-Dan
PS/ All of this is udev and script based. I don't think any of it is specific to *-buntu. Let me know if you want me to suss-out the config details from one of my boxen.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.