LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware
User Name
Password
Linux - Hardware This forum is for Hardware issues.
Having trouble installing a piece of hardware? Want to know if that peripheral is compatible with Linux?

Notices

Reply
 
Search this Thread
Old 07-16-2003, 06:04 PM   #1
tyiooo
Member
 
Registered: Jul 2003
Location: Liège (Belgium)
Distribution: Debian
Posts: 34

Rep: Reputation: 15
usb flash drive


Hello,

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?

Thanks for your help!

Bye

tyiooo
 
Old 07-16-2003, 06:55 PM   #2
michaelk
Moderator
 
Registered: Aug 2002
Posts: 12,143

Rep: Reputation: 783Reputation: 783Reputation: 783Reputation: 783Reputation: 783Reputation: 783Reputation: 783
Its the same thing as read / write permissions on a vfat i.e. fat32 partition.

There are tons of posts on the site you can search for on the above subject.

Hint: You want to add an entry to your /etc/fstab file and use the options noauto and umask=000.
 
Old 07-17-2003, 05:45 AM   #3
tyiooo
Member
 
Registered: Jul 2003
Location: Liège (Belgium)
Distribution: Debian
Posts: 34

Original Poster
Rep: Reputation: 15
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

/dev/sda1 /mnt/pendrive msdos user,kudzu 0 0

/dev/sda1 /mnt/pendrive msdos umask=000,defaults 0 0

/dev/sda1 /mnt/pendrive auto noauto,owner,kudzu,ro 0 0

/dev/sda1 /mnt/pendrive auto noauto,owner,user,kudzu,ro 0 0

/dev/sda1 /mnt/pendrive auto noauto,user,kudzu,ro 0 0

And so on and so on ...and nothing worked...
 
Old 07-17-2003, 05:54 AM   #4
tyiooo
Member
 
Registered: Jul 2003
Location: Liège (Belgium)
Distribution: Debian
Posts: 34

Original Poster
Rep: Reputation: 15
OKAY !!! I'm posting the good combination :

in /etc/fstab :

/dev/sda1 /mnt/pendrive auto noauto,owner,user 0 0


I can hotplug it whenever I want , there's even an icon appearing on my desktop with redhat 9 !
 
Old 07-17-2003, 06:18 AM   #5
tyiooo
Member
 
Registered: Jul 2003
Location: Liège (Belgium)
Distribution: Debian
Posts: 34

Original Poster
Rep: Reputation: 15
false alarm

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.
 
Old 07-17-2003, 12:07 PM   #6
michaelk
Moderator
 
Registered: Aug 2002
Posts: 12,143

Rep: Reputation: 783Reputation: 783Reputation: 783Reputation: 783Reputation: 783Reputation: 783Reputation: 783
I don't use hotplug but this might help.

http://www.linuxquestions.org/questi...+drive+hotplug

Adding the umask option will allow all users to read / write:

/dev/sda1 /mnt/pendrive auto noauto,owner,user,umask=000 0 0
 
Old 07-18-2003, 07:24 AM   #7
tyiooo
Member
 
Registered: Jul 2003
Location: Liège (Belgium)
Distribution: Debian
Posts: 34

Original Poster
Rep: Reputation: 15
okay thanks for your help, I'll try with umask

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 ?
 
Old 07-18-2003, 08:18 AM   #8
plehman
LQ Newbie
 
Registered: Jul 2003
Location: Durham, NC
Distribution: Fedora Core 2
Posts: 23

Rep: Reputation: 15
Hi,

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.

Hope that helps.
 
Old 07-18-2003, 10:21 AM   #9
tyiooo
Member
 
Registered: Jul 2003
Location: Liège (Belgium)
Distribution: Debian
Posts: 34

Original Poster
Rep: Reputation: 15
Thumbs up

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!
 
Old 07-18-2003, 10:53 AM   #10
plehman
LQ Newbie
 
Registered: Jul 2003
Location: Durham, NC
Distribution: Fedora Core 2
Posts: 23

Rep: Reputation: 15
Hi,

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.

as far as my '/etc/fstab' file goes, here it is:

LABEL=/ / ext3 defaults 1 1
LABEL=/boot /boot ext3 defaults 1 2
none /dev/pts devpts gid=5,mode=620 0 0
none /proc proc defaults 0 0
none /dev/shm tmpfs defaults 0 0
/dev/hda6 swap swap defaults 0 0
/dev/sda1 /mnt/flash vfat noauto,user,rw 0 0
/dev/cdrom /mnt/cdrom udf,iso9660 noauto,owner,kudzu,ro 0 0

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.
 
Old 07-31-2003, 04:50 AM   #11
toblo
LQ Newbie
 
Registered: Jul 2003
Posts: 1

Rep: Reputation: 0
Anybody knows how to do this in Mandrake 9.1? I can't find /dev/sda1. Thanks.
 
Old 08-09-2003, 02:05 AM   #12
mobileMike
LQ Newbie
 
Registered: Jul 2003
Location: Finland
Distribution: Currently: RedHat 9 (Future: Debian)
Posts: 5

Rep: Reputation: 0
This is what I did to get my flash drive working with Redhat 9.

http://www.connecteduser.com/forum/v....php?p=250#250

I show 3 methods: direct mounting, fstab, and hotplug

- mike

Last edited by mobileMike; 08-09-2003 at 06:50 AM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
USB flash drive bsmntbombdood Linux - Hardware 3 10-19-2005 05:54 PM
USB Flash drive trainee Slackware 3 05-18-2005 02:50 PM
usb flash drive 1337_n00b Amigo 1 02-13-2005 01:25 AM
USB flash drive crazyking Linux - Newbie 1 05-17-2004 12:25 PM
USB 2.0 Flash Drive fusee Linux - Hardware 3 04-16-2004 06:46 PM


All times are GMT -5. The time now is 11:37 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration