LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (http://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   fstab, automount usb flash (http://www.linuxquestions.org/questions/linux-newbie-8/fstab-automount-usb-flash-449377/)

HPB 05-28-2006 03:34 PM

fstab, automount usb flash
 
System info

OS: SUSE 10.1 (DVD.iso)

Current FSTAB

/dev/hda2 / reiserfs acl,user_xattr 1 1
/dev/hda3 /home reiserfs acl,user_xattr 1 2
/dev/hda4 /local vfat users,gid=users,umask=0002,utf8=true 0 0
/dev/hda1 swap swap defaults 0 0
proc /proc proc defaults 0 0
sysfs /sys sysfs noauto 0 0
debugfs /sys/kernel/debug debugfs noauto 0 0
usbfs /proc/bus/usb usbfs noauto 0 0
devpts /dev/pts devpts mode=0620,gid=5 0 0
/dev/sda1 /mnt/usbflash vfat defaults,umask=0222,utf8=true 0 0

The last line, I have put in. The USB flash is formatted with FAT.

After restart of computer, the USB flash is not availeble. If I go to terminal and log in as root, and follow it up by typing "mount -t vfat /dev/sda1 /mnt/usbflash", I can afterwards open my USB flash.

Could a friendly soul please help me, what to alter in the last line of FSTAB.

THX

drkstr 05-28-2006 03:50 PM

add 'users' to your mount options to allow non-root users to mount the drive. Also make sure the permissions are set correctly on the '/mnt/usbflash' folder. Also, were you wanting to mount this read-only? Your umask options are set for this.

Try it like this if you want a specific user to write to this drive:
Code:

/dev/sda1 /mnt/usbflash vfat defaults,users,uid=<username>,gid=users,umask=022, 0 0
Make sure to do this before mounting the drive:
Code:

#chown username.users /mnt/usbflash
#chmod 755 /mnt/usbflash

regards,
...drkstr

HPB 05-28-2006 04:14 PM

FSTAB, automount USB flash, 2.
 
Quote:

Originally Posted by drkstr
add 'users' to your mount options to allow non-root users to mount the drive. Also make sure the permissions are set correctly on the '/mnt/usbflash' folder. Also, were you wanting to mount this read-only? Your umask options are set for this.

Try it like this if you want a specific user to write to this drive:
Code:

/dev/sda1 /mnt/usbflash vfat defaults,users,uid=<username>,gid=users,umask=022, 0 0
Make sure to do this before mounting the drive:
Code:

#chown username.users /mnt/usbflash
#chmod 755 /mnt/usbflash

regards,
...drkstr

The "chmod 755 /mnt/usbflash" went OK

The "chown username.users /mnt/usbflash" reported something like "operation not allowed". The folowing reported the same, "chown hp.users /mnt/usbflash" and "chmod hp.users /mnt/usbflash"

New FSTAB

/dev/hda2 / reiserfs acl,user_xattr 1 1
/dev/hda3 /home reiserfs acl,user_xattr 1 2
/dev/hda4 /local vfat users,gid=users,umask=0002,utf8=true 0 0
/dev/hda1 swap swap defaults 0 0
proc /proc proc defaults 0 0
sysfs /sys sysfs noauto 0 0
debugfs /sys/kernel/debug debugfs noauto 0 0
usbfs /proc/bus/usb usbfs noauto 0 0
devpts /dev/pts devpts mode=0620,gid=5 0 0
/dev/sda1 /mnt/usbflash vfat defaults,users,uid=hp,gid=users,umask=022 0 0

After reboot, no succes. Help again, please.

drkstr 05-28-2006 06:06 PM

Quote:

The "chmod 755 /mnt/usbflash" went OK

The "chown username.users /mnt/usbflash" reported something like "operation not allowed". The folowing reported the same, "chown hp.users /mnt/usbflash" and "chmod hp.users /mnt/usbflash"
The '#' before the command indicates that it must be run as root. Is that what you did? You also need to make sure this is done before mounting. Switch over to root with 'su' then run
Code:

#umount /mnt/usbfash
#chown hp.users /mnt/usbflash

I am assuming hp is your username?

If it still does not work, please list the output of 'ls -l /mnt'

regards,
...drkstr

_gnomm 05-30-2006 03:21 PM

ok thanks!!it mounts my flash drive!!
for the first time
but!!!

when i'm plugging it out end then plugging in back can't read it!!

here what i've got:

root@gnom: /home/gnom# umount /mnt/usbflash
umount: /mnt/usbflash: device is busy
umount: /mnt/usbflash: device is busy
root@gnom:/home/gnom# mount -a -t vfat /dev/sda1 /mnt/usbflash -o user,exec,dev,suid,rw,umask=000
mount: special device /dev/sda1 does not exist
root@gnom:/home/gnom#

can you help me??

tnanx!!

drkstr 05-30-2006 05:06 PM

Well first off, make sure you ‘unmount’ the device before pulling it out or your Linux box will hate you for it.

Quote:

root@gnom: /home/gnom# umount /mnt/usbflash
umount: /mnt/usbflash: device is busy
umount: /mnt/usbflash: device is busy
If you did not already pull the device out and you still get this error, it means you have a file or directory on the device open. ‘fuser –k /mnt/usbflash’ should take care of that. Once you killed any processes using the device, umount it like normal then remove the device.


Quote:

root@gnom:/home/gnom# mount -a -t vfat /dev/sda1 /mnt/usbflash -o user,exec,dev,suid,rw,umask=000
mount: special device /dev/sda1 does not exist
root@gnom:/home/gnom#
A couple things may cause this. The problem with removable devices is the system device that points to it could change based on what else you have plugged into your usb ports. For instance, if you take your flash device out, then plug something in like an ipod, then plug in your flash device back in; the ipod will get /dev/sda1 and the and the flash device will get the next available /dev/sda2.

If you are using udev with a 2.6 kernel to handle the device creation, most of this stuff should be handled pretty automatically. All you need to do is A) make sure you un-mount before pulling out the device, and b) plug things in the same order and location (usb port) that you did when you created the /etc/fstab. This way it should create the same device name every time.

Regards,
…drkstr

_gnomm 05-31-2006 05:35 AM

ok thanks for reply!!i'll try it,
but where is the sense of automount if i need to type command for unmounting?is there any way not to type comands and to make my linux box to do it automatically?? automount and auto unmount??

drkstr 05-31-2006 09:40 AM

yes, you could write a bash script that automatically mounts the drive when it detects the device file is created by udev, and automatically destroys the device file when the flash drive is removed. Although I wouldn't recommend doing the later unless you really know what you're doing. It would be better just to do 'umount /mnt/usbflash' when you are done using it.

regards,
...drkstr

_gnomm 05-31-2006 10:23 AM

ok, thank you for reply!!!

bathory 05-31-2006 05:47 PM

You can use autofs to auto-mount your usb stick. So there is no need to manually (or via /etc/fstab) mount it and you cat unplug it when you want without the need to unmount it first. Take a look here for details.

Regards

drkstr 05-31-2006 06:35 PM

Good advice bathory. I've never used this before, I should look into it myself.

regards,
...drkstr


All times are GMT -5. The time now is 04:57 AM.