LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware (https://www.linuxquestions.org/questions/slackware-14/)
-   -   Hot-mount USB devices with Xusb-hotmount (https://www.linuxquestions.org/questions/slackware-14/hot-mount-usb-devices-with-xusb-hotmount-542304/)

gnashley 04-01-2007 03:07 AM

Hot-mount USB devices with Xusb-hotmount
 
I've come up with a pretty nice program for auto-mounting USB FLASH devices and hard drives.
Xusb-hotmount will place icons on your desktop for each partition on the device. Right-clicking the icon opens an action menu which allows you to mount/unmount the partition. The main program action allows you mount or umount all partitions and safely remove the device.

This version only works under kernel-2.4. So that normal users can mount and unmount the devices, you'll need to put something like this in your /etc/sudoers file:
and
%Xusb-hotmount ALL=NOPASSWD:/sbin/mount
%Xusb-hotmoun ALL=NOPASSWD:/sbin/umount

Then create a group for Xusb-hotmount and add the user to the group (amigo is me) in /etc/group:
Xusb-hotmount::105:amigo,root

This program only uses Xlibs and should work with nearly any window manager.

Get the package or sources here:
http://distro.ibiblio.org/pub/linux/...Xusb-hotmount/

GrapefruiTgirl 04-01-2007 08:46 PM

Hiya :)
For the sake of science, I'd like to know what this little tool might do in the case of a USB webcam, for example, and/or how it might be of use with such a device.
My cam is recognized automatically by my system, but one would never know it without monitoring dmesg or checking the log or system-info-center.
Any comment? Thanks!
:)

gnashley 04-02-2007 12:45 AM

This automounter should work with anything that shows up as a SCSI device on the USB bus. That means USB hard-drives and FLASH memory devices such as in your camera or an mp3 player. If you've been able to mount the memory in your camera using the manual methods, Xusb-hotmount should pick it up and mount it automatically.

GrapefruiTgirl 04-02-2007 01:09 AM

Well... I don't know that it's SCSI, as I haven't even got SCSI support in the kernel that I recall.. And I don't know either about 'memory' in the camera; it's a webcam, and I don't really 'mount it' I just plug it in and run the application of choice (so far I have sn-webcam set up) to use the cam. No mounting, manual or otherwise that I can tell.Here's what shows in the info center:
USB camera

Class
0
((Defined at Interface level))
Subclass
0
Protocol
0
USB Version
1.10

Vendor ID
0xc45
(Microdia)
Product ID
0x6029
(Triplex i-mini PC Camera)
Revision
1.01

Speed
12 Mbit/s
Channels
0
Max. Packet Size
0

gnashley 04-02-2007 02:27 AM

Oh, sorry. It's early here and I didn't read correctly. I thought you meant to connect a digital camera with a FLASH memory to your computer using a USB cable.
Xusb-hotmount does not try to handle any USB devices other than mass-storage devices. It's meant to mount partitions which are on such devices, like mp3 players, thumb-drives, digital cameras, real USB hard-disks and cards you plug into a multi-card reader. Should work with any sd or xd type cards without problems. I'm not sure about Compact Flash, though. I don't have one with which to make tests.

All such USB devices are treated as SCSI devices by the kernel.

SCerovec 04-02-2007 02:49 AM

Quote:

Originally Posted by GrapefruiTgirl
Hiya :)
For the sake of science, I'd like to know what this little tool might do in the case of a USB webcam, for example, and/or how it might be of use with such a device.
My cam is recognized automatically by my system, but one would never know it without monitoring dmesg or checking the log or system-info-center.
Any comment? Thanks!
:)

You have 2 choices:
1. It doesn't help you with your cam - it's for storage devices only (a digital camera can be a Video device or a Storage device), so forget it (sorry :-( )

2. If you have the will, you could study the code and try to make your cam work:
a) find who manages the event for managing your cam upon plug-in
b) modify an existing script so it takes care that the right app gets _your_ cam ;)
c) post all that stucks here (join this or whatever project you choose :) )

So, it's up to you ...

SCerovec 04-02-2007 03:29 AM

Regarding the project
 
Hi, I just took a glance at your package...

It's a awesome job you did here.

Unfortunately it seems that I'm really stuck to 2.6 kernels so far ... sorry not to test it right on ...

About my impressions:

Pros:
It's automatic so beginners will have hot-plugable filesystems.
It's WM independent so it will work for most users

Cons:
There might be some WM's that don't support icons at all (Blackbox and Fluxbox ...). But those are advanced users already...

All in all A+ for a 2.4 based desktop system running X.
My recommendation ;)

gnashley 04-02-2007 05:40 AM

Too bad you can't see how it works right now. The code is still cluttered, but I wanted to get something out that works and that you (SCerovec) could look at. There are several places where, conceptually, your code might plug into mine.

It's completely WM-independent since the icon display uses just Xlibs -especially nice for fluxbox, WindowMaker or iceWM systems.
I've been looking the last couple of days on how to implement similar behaviour with 2.6 kernel -it's going to take a different approach I think. The code in this version could probably work, but since hotplug is usually turned off under 2.6 it would be better to do it another way.

Actually, I have worked out how to do this with another GUI -a DockApp that can also run in windowed-mode. Instead of display separate icons for each partition you can click through them from a single 64x64 window. The program includes its' own (gtk-1.2) GUI config program also. It only requires a few changes in the existing code, but it does need WindowMaker installed to work, so far.

I learned several neat tricks working out the current version which are gonna be useful again -the use of a trap instead of polling should be interesting to you(The Xusb-hotmount script itself) and the use of a 'requester' in order to sort out which user is connecting the device. The trouble to get 'su' to work was the nightmare and mostly what caused the above to be necessary.

GrapefruiTgirl 04-02-2007 08:30 AM

Quote:

Originally Posted by SCerovec
You have 2 choices:
1. It doesn't help you with your cam - it's for storage devices only (a digital camera can be a Video device or a Storage device), so forget it (sorry :-( )

2. If you have the will, you could study the code and try to make your cam work:
a) find who manages the event for managing your cam upon plug-in
b) modify an existing script so it takes care that the right app gets _your_ cam
c) post all that stucks here (join this or whatever project you choose )

Actually, my cam works just fine! I thought I made that clear :) but sorry if I didn't.
I was just curious, if there was any advantage or benefit from trying to use such a tool for the device. Maybe just for popping an icon on the screen to let me know that the cam was online/powered up, or perhaps for being able to 'disconnect' it, because currently it is 'always ON', even if I am not using a capture program at the moment-- the light is on, and it's always 'plugged in' but I wouldn't mind a method of turning it off without physically unplugging it.

gnashley 04-02-2007 09:12 AM

It's a idea GrapefruiTgirl, but perhaps outside the scope of what I'm trying to do. It would probably be fairly easy to do the same sort of trick, though for quite a variety of programs. Of course there are probably panel applets or systray programs that do that for cameras if you have the proper stuff installed.

As far as turning off the light -I don't think you'll get far with that somehow. This seems to be mostly device-dependent. I have some devices which only light up when being written to, some which are always on and some that light when reading or writing.

Haven't I seen you on some scripting/programming threads? I mean, if you know a little BASH you might be able to come up with something for your cam. If you are using kernel-2.4 it's pretty easy to 'hook' a hotplug event for any module or device you want.

GrapefruiTgirl 04-02-2007 09:35 AM

Hmm, ok cool, I shall look into your suggestions there, and thank you for that input, gnashley. :)

I do have a feeling that this thing lights up whenever plugged in, and the light remains on all the time. I don't know how I would software-disable power to the port; probably not possible, by nature of USB ports.

I am getting 'quite comfortable' with BASH, and have posted here and there in the programming threads when it's on a topic I am familiar with, but I am only 3 months new to linux, so I have a looooooong way to go yet before maybe being able to create a decent such a piece of code in shell-script, let alone in C.

For the record, I am using 2.6.20, self constructed kernel.:)

SCerovec 04-03-2007 04:54 AM

RE:2.6.20 /USB cam
 
@GrapefruiTgirl
First to congratulate your (own) krenel build. :-) (that's da way to go =) )

In the way of configuring the kernel you may have noticed that there -might- be the ability to switch off the power of the plugged USB device via the /sys/ filesystem ...

Since you using a kernel more advanced than 2.6.17.13 (Slack 11.0 default) It might be fairly possible and safe...

just peek around /sys/* with your favorite FM (mc recommended with Optins/Configuration/Lynx style motion enabled ;-) )
You are looking for a file called power or state that's writable ;-)

And look at the kernel config around ACPI, USB and similar...

BTW, did you test this homount-thingy of mine? I'm looking for a quite fresh Linux-newcomer for the 1st impression... ( http://www.linuxquestions.org/questi...d.php?t=494900 )

off the record: it took me far more than 2x three months to digest making my own kernel (well I started with mandrake ...)
:-)

GrapefruiTgirl 04-03-2007 08:15 AM

Why thank you SCerovec :) I have built probably 50 kernels by now; it was very near the first thing I wanted to get a grip on after switching to Linux---and with no regrets, I mean, my system is SO customizable, I don't know how I ever managed to have fun under WinXX :). Took me about a week to figure it out, with part of the problem being missing kernel headers at the start of it all. Currently, depending on what I'm working on, I tweak/recompile the kernel about once a week; for example, I just got an old Mustek flatbed scanner hooked up and working perfectly, which required a couple modules to be made which I chose to not use prior. The silly scanner doesn't even work on Windows and was out in the shed for the past year, so I am quite pleased with that.. :)
The Webcam was the project before the scanner, and before that I got packet-writing geared up for my CDRW finally, which was the most tricky project I've dealt with yet. Before that it was getting dual-displays running on my nVidia card.

I don't recall seeing any 'power-control' settings in xconfig for the USB ports, but you've inspired me to look again; that would be nice to find, as the constant camera light being on is kind of annoying.. I'll poke around in /sys and /proc for any indications; I use MC a lot, but don't know what you mean by the Lynx-style motion though. Expand upon please?:P..

No, I haven't tried your/any hotmount thingy, only because I have no USB flash devices or similar for which I would need it. My drives/hardware is all internal. If there's something I would use it for, I would happily try it out!

SCerovec 04-04-2007 03:15 AM

The 50 kernels you're ahead is giht what I was gratulating you ;-) - having a working one means mileage, especialy if you begun on 2.4 series :-)

The lynlx-stile motion is when you type [<-] (cursor left) you get back in the upper dir. That way one doesn't have to be on the ".." and hit [enter] when somewhere (/etc? ) in a over-populated dir. ;-)

You do use links for /usr/doc right? it's the same way nd I recommend it to all.

Now back to the topic:

How come You use no USB-Flash? don't you share files this way? If so, I guess you have a good web connection ;-).

GrapefruiTgirl 04-04-2007 08:24 AM

Actually :) I never did compile a 2.4 kernel. The first one I made after getting Linux, was 2.6.17.13, which I downloaded and started with. And I always have a working one in LILO. I usually keep a history of about three kernels in LILO, and if I settle on a new compile after proving that it works and does what I want, I add it to LILO, and remove the oldest one from the list.

That's a good idea about the Lynx-style navigation! It sure would save a bit of page-flipping.

RE: The USB_Flash : Well, I am on dial-up actually, and usually no better than 28.8k :( so quite a NON-good web connection! I am connected to a WinXP computer by ethernet/LAN, which has the modem in it. So no, I don't 'share files', if I need to send a file somewhere, it's the old fashioned way--- Email it/upload it. The XP machine and mine don't share anything except the internet connection.
Plus, until my finances improve, I cannot afford nifty new gizmos like USB flash drives or a multitude of other new and cool gadgets I'd like to have :)


All times are GMT -5. The time now is 02:55 AM.