Linux - HardwareThis forum is for Hardware issues.
Having trouble installing a piece of hardware? Want to know if that peripheral is compatible with 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 just bought a pendrive mp3 player usb with 128Mo, I tried to plug it in with redhat 9, everything is working perfectly well. I just had to mount /dev/sda1
so here's what I did:
mkdir /mnt/pendrive
mount -t msdos -o rw /dev/sda1 /mnt/pendrive
But now, my only problem is I didn't understand how to set the permissions with mount. I'm able to write to /mnt/pendrive only when I'm root. How can I easily read and write my pendrive under my user account?
I know and I searched a lot but what works for others didn't necessarily worked for me.
I succeeded in mounting the device under root permission, I succeeded to have the device read/write for the user only when I start redhat with the flash drive already plugged in.
What I really want is to be able to hotplug it under my user account anytime I want then to be able to modify its content with read and write permissions.
In /etc/fstab I tried :
/dev/sda1 /mnt/pendrive auto defaults 0 0
/dev/sda1 /mnt/pendrive auto noauto,owner,user 0 0
Well I was so glad to make it work then really disappointed :
I can delete or copy files only once... after it says "generic error - cannot delete" or when I try to copy it says "disk is full" although it is empty.
So I tried to umount /mnt/pendrive but it says "device is busy" although it is not.
A lot of "ALTHOUGH" , this is a total nonsense .
Thanks for your help.
note : the pendrive is totally standard, it doesn't need any driver to be loaded, everything is ok under Win2K but I try to get rid of windows little by little so I absolutely have to be able to do this with redhat 9.
the thread you're talking about is very useful even if it doesn't give a lot of informations. I know at least where to search now (hotplug service).
I thought this was so simple to do in linux..I was so wrong. there's a lot of configuration to do for this device to work as it is designed to be used. I mean it is supposed to be plugged then immidiately usable by the user who could then be able to write erase data on the key without mounting/umounting each time.
So if you don't use hotplug, then you just added the appropriate line in /etc/fstab with umask and you mount/umount each time you want to add/erase files ?
I was the one asking about hotplug in the referenced thread, but I guess I forgot to post the resolution, and maybe it will help you:
In short, to get hotplug working (at least for me), I had to create a file called 'usb-storage.add' located in the '/etc/hotplug/usb' directory. That file had to look something like this:
#!/bin/bash
DEV=/dev/sda1
MNTPOINT=/mnt/flashdrive
mount -t vfat $DEV $MNTPOINT
cat <<END> $REMOVER
umount $MNTPOINT
END
chmod +x $REMOVER
Obviously, the DEV and MNTPOINT variables should be changed to fit your device. I'm still not completely sure what all it does, but my understanding is that the hotplug service will run this file when a USB storage device is added, and handle the mounting. The part starting with cat, I am not completly sure what it does, and I am still investigating that.
Next, you have to add a function to the '/etc/hotplug/hotplug.functions' file as follows. Note that I placed this at the end (between the last 'fi' and before 'done') of the file.
if [ -x $HOTPLUG_DIR/$TYPE/$MODULE.add ]: then
debug_mesg Module setup.add $MODULE for $DESCRIPTION
$HOTPLUG_DIR/$TYPE/$MODULE.add
fi
The assumption here is that when a new device is added, and hotplug detects the <device-type>.add file in the <type> directory, it will run that script.
Now, concerning the problem where you cannot umount the device because it says "device is busy"...
Assuming you are using RH, this is likely due to the fact that a service called 'fam' is still running, and hence you cannot umount the device because some program is still using it. This is apparently a bug in the Nautilus filemanager, documented on RedHat's Bugzilla site.
fam stands for File Alteration Monitor, and it monitors changes made to filesystems. Most likely you cannot umount the device because this service didn't exit quietly. To my knowledge, there is no patch for this problem yet.
The only workaround I know of now is to kill the process for fam, and then umount the drive. I'm sure someone could write a script or something, and then add it to 'hotplug.functions' file so its autmatically run on removal.
hello! Thanks a lot for posting the resolution I was about to write you an e-mail
I created the file usb-storage.add changing the DEV and MNTPOINT variables to fit my device.
I also added the function in the '/etc/hotplug/hotplug.functions' file
After a reboot, I plugged in my device and nothing happened this time (usually the usb storage is detected then I can mount it) . I thought it doesn't work so I tried to mount it manually as I've done it before but now it says "non-valid block peripheric".
I think I missed something :
I just copied the function to add in the '/etc/hotplug/hotplug.functions' did I have to modify some variables to fit my system ?
Quote:
The assumption here is that when a new device is added, and hotplug detects the <device-type>.add file in the <type> directory, it will run that script.
Did you mean I have to replace some variables by my <device-type> in the hotplug.functions file ?
Another question : After these changes, how does your '/etc/fstab' looks like?
I really appreciate your help, thank you once again!
Sorry it didn't work for you first try out. The file data I provided was from my USB Flash Drive (a Lexar 64MB JumpDrive), and as I am still pretty new to linux, I would have to assume that the '-t vfat' part of the mount command in usb-storage.add is what might be causing the 'non-valid block peripherlc' message.
What I meant by <device-type>.add in the <type> directory was this.
under '/etc/hotplug', I have a directory (RH made it) called 'USB'. USB is what I intended to be <type>.
Under the 'USB' directory, RH has a file for USB cameras (even though I never hooked one up) called 'usbcam'. Thus, when I was told to make a file called usb-storage.add', I assumed that hotplug needs a .add file or something of that nature to tell it how to handle various types of USB or other devices. So 'usb-storage' was the <device-type> I was referring to.
Presumably, though this has not been verified, hotplug could also be used for say removable hard-drives, pci/pcmcia periherals, optical media, or maybe even smart cards.
Not to confuse this any further, but I should note that in order to get an icon to appear on the desktop (I am using GNOME), I also had to add a line to '/etc/auto.misc' as follows:
flash -fstype=vfat :/dev/sda1
I got this idea from trying to determine how cd-roms got automounted, and got indications this was needed from 'man automount' and man 'auto.master', though this may not be needed since I now have hotplug functioning.
I don't know how much more help I can be, but if you would like to email me directly, please feel free to do so at plehman@siceltech.com.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.