quarta-feira, 27 de julho de 2011

Linux: Automount USB external drive with autofs

To avoid any confusion with the base name of your USB block device, make alias using udev manager:

Making udev device name alias

Edit the file /etc/default/autofs and enable BROWSE and LOGGING:

-BROWSE_MODE="no"
+BROWSE_MODE="yes"

-#LOGGING="none"
+LOGGING="verbose"

Edit the file /etc/auto.master and comment all lines what are not commented.
Add to the end of /etc/auto.master this line:
/mnt /etc/auto.usbdrive --timeout=2

Create the file /etc/auto.usbdrive:
kingston -fstype=vfat,rw,uid=1000,gid=100,fmask=133,dmask=022,user :/dev/kingston1

Start autofs daemon:
$ (chmod +x /etc/rc.d/rc.autofs ; sh /etc/rc.d/rc.autofs start)

Plug-in the pendrive and see /var/log/messages:

Jul 27 13:29:46 keyra kernel: [17339.948942] sd 9:0:0:0: [sdb] Attached SCSI removable disk
Jul 27 13:30:00 keyra automount[5766]: attempting to mount entry /mnt/kingston
Jul 27 13:30:00 keyra automount[5766]: mount(generic): mounted /dev/kingston1 type vfat on /mnt/kingston
Jul 27 13:30:00 keyra automount[5766]: mounted /mnt/kingston
Jul 27 13:30:01 keyra automount[5766]: 1 remaining in /mnt

Unplug the device:

Jul 27 13:42:35 keyra automount[5766]: expiring path /mnt/kingston
Jul 27 13:42:35 keyra automount[5766]: unmounting dir = /mnt/kingston
Jul 27 13:42:35 keyra automount[5766]: expired /mnt/kingston
Jul 27 13:42:41 keyra kernel: [18115.356920] usb 2-2: USB disconnect, address 9

Nenhum comentário:

Postar um comentário

Drunk Penguins

Drunk Penguins
Drunk Penguins