LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware (https://www.linuxquestions.org/questions/slackware-14/)
-   -   Slack 10.2 auto reading flash stick (https://www.linuxquestions.org/questions/slackware-14/slack-10-2-auto-reading-flash-stick-477489/)

kd5giv 08-26-2006 03:20 AM

Slack 10.2 auto reading flash stick
 
Hello,

Is it possible to get an USB memory stick to mount when I stick it in the usb slot and unmount it on command? Scientific linux mounted it by me just putting it in but then kept it mounted, even though I told it to unmount.

vonst 08-26-2006 07:47 AM

As long as you have all the USB modules compiled and your fstab updated, your memory stick will register as a device. Then you can manually mount and umount it without a hitch.

My guess is that if Scientific Linux was "automounting" the memory stick, then it was doing it to a crontab. Every time you umounted it, the cron would see you had the device and mount it again.

--vonSt

uselpa 08-26-2006 09:47 AM

Quote:

Originally Posted by vonst
My guess is that if Scientific Linux was "automounting" the memory stick, then it was doing it to a crontab. Every time you umounted it, the cron would see you had the device and mount it again.

I have never heart of somebody using cron to automount. Automounting is done either by udev, or hotplug, or autofs, or (you name it). But never by cron.

vonst 08-26-2006 04:05 PM

I'm not an expert by any means. My personal experience is that hotplug and udev register the devices in /dev. They never (in Slackware, anyway) referenced my fstab and mounted themselves to a directory. *I* did that. As a user, I've always typed "mount /dvd" and it did! Then I could umount /dvd and get my dvd back.

So, a question back to you, uselpa, why/how does kd5giv's SciLin keep mounting his memory stick to a directory?

--vonSt

Franklin 08-26-2006 04:48 PM

Quote:

So, a question back to you, uselpa, why/how does kd5giv's SciLin keep mounting his memory stick to a directory?
A quick peek at the website indicates HAL and DBUS.

vonst 08-26-2006 08:57 PM

http://wiki.kde.org/tiki-index.php?page=DBUS

That gave me a great intro into kd5giv's original question. Get HAL and DBUS for Slackware and they'll help you automount your hotplugs.

But it didn't answer my question. I attempted to google around for what Red Hat (Scientific Linux) uses for its automounter, but gave up because of jetlag. (I shouldn't have gotten online right now...)

rkelsen 08-26-2006 09:14 PM

Quote:

Originally Posted by vonst
But it didn't answer my question. I attempted to google around for what Red Hat (Scientific Linux) uses for its automounter, but gave up because of jetlag.

It uses HAL, DBUS & Gnome-volume-manager.

The "not-unmounting-when-you-tell-it-to" issue could be a permissions problem. With DBUS & HAL your user must be in the right groups in order to get full functionality. The exact names of the groups vary between distros. Debian uses a "plugdev" group, others use "messagebus" and "haldaemon" groups.

Slackware doesn't have HAL. Current versions of HAL require PAM, so it could be a while off yet. There'll be no escaping DBUS though, because KDE4 uses it in place of DCOP.

kd5giv 08-27-2006 03:54 AM

There are packages on linuxpackages.net for DBUS. I use KDE for Slackware 10.2. Should DBUS make it possible to use this memory stick? I doubt I will know what to do with fstab. It's always been a confusing subject.

vonst 08-30-2006 04:17 PM

USB hotplug mounting howto
 
Here's my own 1..2..3 on mounting a USB something-or-another (Note: I don't automount. I always mount by hand.):

1. Make sure I've compiled a kernel w/ all the USB modules in it that I have some understanding of. Alternately, the bigger pre-compiled Slackware kernels have ALL the USB modules compiled into them.

2. Start Slackware and get it all warm and happy. USB hardware at this time is unplugged and/or turned off.

3. Now that Slack is up, hotplug the USB hardware by plugging it in and/or turning it on.

4. And now the hard part... "tail /var/log/messages". (You might need to wait a little bit until the hotplug system works it magic.) In this usually root controlled log, a system message will be added saying that hotplug has started and the USB hardware is being assigned a device.

5. Time to decode the message. Look for key words. Here's an example of what I get when I hotplug my USB memory stick:
Code:

Aug 30 16:22:36 rain kernel: USB Mass Storage support registered.
Aug 30 16:22:41 rain kernel:  Vendor:          Model: USB Flash Memory  Rev: 1.04
Aug 30 16:22:41 rain kernel:  Type:  Direct-Access                      ANSI SCSI revision: 00
Aug 30 16:22:42 rain kernel: SCSI device sde: 2004992 512-byte hdwr sectors (1027 MB)
Aug 30 16:22:42 rain kernel: sde: Write Protect is off
Aug 30 16:22:42 rain kernel: SCSI device sde: 2004992 512-byte hdwr sectors (1027 MB)
Aug 30 16:22:42 rain kernel: sde: Write Protect is off
Aug 30 16:22:42 rain kernel:  sde: sde1
Aug 30 16:22:42 rain kernel: sd 4:0:0:0: Attached scsi removable disk sde
Aug 30 16:22:42 rain kernel: sd 4:0:0:0: Attached scsi generic sg4 type 0

Key words "SCSI device sde" and "sde: sde1". Why are they key words? Because I know that my memory devices look something like "/dev/hda" or "/dev/sda". It specifically tells me in the log that I have a SCSI device, so I know it'll have to look like "/dev/sda" or maybe "/dev/sda1" or in this case sde1 means "/dev/sde1".

6. If you haven't already done this, you need a mount point. Mount points are the directories that will hold your USB hardware. Off of the / directory, I created "/td" because it's a "thumb drive." (mkdir /td)

7. Quick and dirty: mount /dev/sde1 /td and there you have it. (umount /td and there you don't have it!)

8. Slow and slick: add the following line to your /etc/fstab:
Code:

/dev/sde1        /td              vfat    noauto,user,rw,exec  1  0
Decode: "vfat" is the disk partitioning scheme.
"noauto,user,rw,exec" from the man and howtos for mount: Don't automatically mount this at bootup, Allow the ordinary "user" to mount this drive, As read-write, Permit the execution of binaries from the drive.
"1 0" have to do with "dump"ing. I have no idea what that means, but I know it ought to be "1 0".

Quote:

Inserted very damning note: Since Slackware is adding your devices sequentially, if you have a couple devices that use the SCSI device scheme, your memory stick may mount as /dev/sde (which happens to be the 5th memory device after my 4 hard drives). Or it may be /dev/sdf, if, say, I hotplugged a digital camera into Linux and the camera got /dev/sde first! The digital camera could be mounted, then with mount /td. I mean, it's a device and fstab knows /dev/sde1 goes with /td. But then your memory stick, sitting at /dev/sdf1 is out of luck. Maybe automounters are smart enough to discriminate. I dunno.
9. If you have chosen the "Slow and slick" method, you will then be able to mount your drive as a user, which is awfully nice if you typically run Slack as a user.

mount /td

umount /td

10. Always, always, always remember to umount before you pull your hardware. Man, have I gotten bit by that over and over! It doesn't matter if you're on Microsoft or Linux, umounting writes something or another that closes up those files you wrote to your memory stick. Don't do it, and your last file you wrote just doesn't seem to be the right size... if you can even mount the memory stick ever again!!!

--vonSt

vonst 08-30-2006 04:38 PM

I thought I'd add another variation for completeness...

Your device might not be registered as /dev/sdx. I don't know why, but my external hard drive DVD+-RW is registered as /dev/sr0. Consequently, I have the following line in my /etc/fstab:

Code:

/dev/sr0        /dvd          iso9660 iocharset=utf8,noauto,user,ro 0 0
And unfortunately, I don't know why it's like this. It likes my DVD drive to be called sr0. The iso0660 is the standard partitioning scheme of CDROMs and DVDs, and utf8 is the characterset of Western English. But the rest of it, I included because other howtos told me to. (Sad but true.)

NB: You definitely can tell your device will be an "sr" device. Look at /var/log/messages:
Code:

Aug 30 17:18:30 rain kernel: usb 2-3: new high speed USB device using ehci_hcd and address 5
Aug 30 17:18:30 rain kernel: usb 2-3: configuration #1 chosen from 1 choice
Aug 30 17:18:30 rain kernel: scsi5 : SCSI emulation for USB Mass Storage devices
Aug 30 17:18:39 rain kernel:  Vendor: PLEXTOR  Model: DVDR  PX-716A    Rev: 1.04
Aug 30 17:18:39 rain kernel:  Type:  CD-ROM                            ANSI SCSI revision: 00
Aug 30 17:18:39 rain kernel: sr 5:0:0:0: Attached scsi generic sg5 type 5

Where as the other device said it was "sde 4:0:0:0", this one says "sr 5:0:0:0". (I still have the memory stick mounted...)

--vonSt

jimX86 08-30-2006 04:57 PM

Quote:

Originally Posted by vonst
And unfortunately, I don't know why it's like this. It likes my DVD drive to be called sr0.

sd = disks
st = tapes
sr = CDROMs, DVDs


All times are GMT -5. The time now is 02:27 PM.