LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   How to change /etc/auto.master to mount USB (https://www.linuxquestions.org/questions/linux-newbie-8/how-to-change-etc-auto-master-to-mount-usb-504477/)

cnm 11-24-2006 09:18 AM

How to change /etc/auto.master to mount USB
 
How to change /etc/auto.master to automatically mount USB pen drive soon after connecting to USB.

jschiwal 11-25-2006 01:55 AM

The auto.master file has its own manpage: man 5 auto.master.

cnm 11-25-2006 02:08 AM

I found a way. Tell me if there is another better way to do it.

Add the following line to /etc/auto.master (can use "vi")

/anyDirectory/anySubDirectory /etc/auto.anyname

*above "/anyDirectory/anySubDirectory" should be created.(can use "mkdir")
And add the following line to /etc/auto.anyname (you may have to create this file)

anyNameForDevice -fstype=vfat,rw :/dev/sda1


then restart autofs (can use "service autofs restart")

USB will be mounted to "/anyDirectory/anySubDirectory/anyNameForDevice" directory automatically when its pluged. this sub directory anyNameForDevice exsists only when the USB is pluged.

jschiwal 11-25-2006 02:12 AM

One thing to check is if your distro uses udev rather than autofs. Try "ps -u root | grep udev" and "sudo /sbin/chkconfig autofs".

AdaHacker 11-25-2006 04:23 PM

Quote:

Originally Posted by cnm
USB will be mounted to "/anyDirectory/anySubDirectory/anyNameForDevice" directory automatically when its pluged.

Actually, no, that's not how autofs works. The device will be mounted when you access the mount point, not when you plug it in. Autofs mounts filesystems on demand and then automatically unmounts them after a certain period of inactivity. It doesn't know about USB hotplug events and will not respond to them. For your purposes, the difference is probably academic, but it is there.

Quote:

Originally Posted by jschiwal
One thing to check is if your distro uses udev rather than autofs.

That statement makes no sense. Udev handles dynamic creation and destruction of device nodes and is installed on every reasonably up-to-date Linux system. Autofs handles mounting local and network filesystems. One is not a substitute for the other.

jschiwal 11-26-2006 06:42 AM

I should have said udev and subfs.


All times are GMT -5. The time now is 03:29 AM.