LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Debian (http://www.linuxquestions.org/questions/debian-26/)
-   -   Auto-mount usb flash without any DE (http://www.linuxquestions.org/questions/debian-26/auto-mount-usb-flash-without-any-de-688116/)

TweeKane 12-03-2008 03:45 PM

Auto-mount usb flash without any DE
 
I tried two ways:
  1. /etc/udev/rules.d/00.my.rules
    Code:

    ATTRS{model}=="USB MP3                ", NAME="explay"
    /etc/auto.master
    Code:

    /var/autofs/explay          /etc/auto.misc -timeout=2
    /etc/auto.misc
    Code:

    explay                  -fstype=vfat,users,rw,umask=0002,codepage=866,iocharset=utf8,gid=users,sync        :/dev/explay
  2. /etc/udev/rules.d/00.my.rules
    Code:

    ATTRS{model}=="USB MP3                ", NAME="explay", RUN+="/bin/mount -t auto /dev/explay"
    /etc/fstab
    Code:

    /dev/explay        /media/explay  vfat users,rw,umask=0002,codepage=866,iocharset=utf8,gid=users,sync 0 0

After connecting my usb flash, it appears in /dev as /dev/explay but it's not mounts automaticly, nevertheless i can mount it manualy.

I'm using Debian Lenny.

bathory 12-03-2008 04:58 PM

Make sure that automount is running:
Code:

ps -ef|grepa automount
Note also that you should create the /var/autofs directory, while the /var/autofs/explay is created automatically when you connect the flash drive. So connect the flash drive in the usb port and the run
Code:

ls /var/autofs/explay
to see if it's mounted automatically by listing its contents.
If this is not working running dmesg could show you what's wrong.

Regards

TweeKane 12-04-2008 04:30 AM

Autofs works:
Code:

$ sudo /etc/init.d/autofs status
Configured Mount Points:
------------------------
/usr/sbin/automount --timeout=300 /var/autofs/explay file /etc/auto.misc
/usr/sbin/automount --timeout=300 /var/autofs/flash file /etc/auto.misc

Active Mount Points:
--------------------
/usr/sbin/automount --pid-file=/var/run/autofs/_var_autofs_explay.pid --timeout=300 /var/autofs/explay file /etc/auto.misc
/usr/sbin/automount --pid-file=/var/run/autofs/_var_autofs_flash.pid --timeout=300 /var/autofs/flash file /etc/auto.misc

Code:

$ ps -ef|grep automount
root      2386    1  0 13:04 ?        00:00:00 /usr/sbin/automount --pid-file=/var/run/autofs/_var_autofs_explay.pid --timeout=300 /var/autofs/explay file /etc/auto.misc
root      2428    1  0 13:04 ?        00:00:00 /usr/sbin/automount --pid-file=/var/run/autofs/_var_autofs_flash.pid --timeout=300 /var/autofs/flash file /etc/auto.misc
sergey    3074  2884  0 13:10 pts/1    00:00:00 grep automount

Device created:
Code:

$ ls /dev/flash
/dev/flash

Code:

$ sudo mount | grep flash
automount(pid2428) on /var/autofs/flash type autofs (rw,fd=4,pgrp=2428,minproto=2,maxproto=4)

But where is no files in /var/autofs/flash/ directory:
Code:

$ sudo ls -l /var/autofs/flash/
итого 0

And it's not mounted:
Code:

$ sudo umount /dev/flash
umount: /dev/flash: not mounted


But i can mount my flash manualy:
Code:

$ sudo mount -t vfat /dev/flash /mnt/flash/
$ ls /mnt/flash/
casper  isolinux  ldlinux.sys  md5sum.txt  preseed  syslinux.cfg  ubnfilel.txt  ubninit  ubnkern  ubnpathl.txt  vesamenu.c32

I'm not understand why it is happening :(

bathory 12-04-2008 06:26 AM

According to /etc/auto.misc your usb stick it's automounted on /var/autofs/explay and not on /var/autofs/flash. Now you have to edit /etc/auto.master like this:
Code:

/var/autofs  /etc/auto.misc
If you want to use the timeout option you should add "--timeout=2" (note there are 2 dashes in front) to the above line.

TweeKane 12-04-2008 06:52 AM

Quote:

Originally Posted by bathory (Post 3364129)
According to /etc/auto.misc your usb stick it's automounted on /var/autofs/explay and not on /var/autofs/flash.

This is just another flash stick, it has it's own strings in config files

Quote:

Originally Posted by bathory (Post 3364129)
Code:

/var/autofs  /etc/auto.misc
If you want to use the timeout option you should add "--timeout=2" (note there are 2 dashes in front) to the above line.

There is no such file in my /etc catalog, i create it manualy. And nothing happens after plug-in my device…

bathory 12-04-2008 07:14 AM

Quote:

There is no such file in my /etc catalog, i create it manualy. And nothing happens after plug-in my device…
Ok, this is my fault. I've forgotten the dot in the filename. The correct is /etc/auto.master. You should have something like the following:
/etc/auto.master
Code:

/var/autofs  /etc/auto.misc
/etc/auto.misc
Code:

explay                  -fstype=vfat,users,rw,umask=0002,codepage=866,iocharset=utf8,gid=users,sync        :/dev/explay
You can connect the usb device in the computer and watch the dmesg output to find the correct device name (in my system the usb stick is /dev/sda1) and replace explay with it in /etc/auto.misc.
Of course you need to restart autofs.

TweeKane 12-04-2008 08:38 AM

Oh... I remove all lines from udev config… According dmesg outputs, my flash name is /dev/sda1
I have only one string in /etc/auto.master:
Code:

/var/autofs/    /etc/auto.misc --timeout=2
And only one string in /etc/auto.misc:
Code:

explay          -fstype=vfat,users,rw,umask=0002,codepage=866,iocharset=utf8,gid=users,sync    :/dev/sda1
And it works. Thank you very much :)

And one more question: need i use "sync" mounting option with "--timeout=2" at my /etc/auto.master file? I think that "synk" makes writing slower…

bathory 12-04-2008 09:41 AM

Glad to see it worked.
You don't need the sync option with such a short timeout.

Regards

TweeKane 12-04-2008 10:22 AM

Thanks a lot


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