2

I have a raspberry Pi and using Raspbian (without the GUI) and need USB pen drives to be mounted to /media/usb and cdrom drive to be mounted to /media/cdrom.

I have set up a script using autofs

/etc/auto.master

/media /etc/auto.media --timeout=2

/etc/auto.media

cdrom   -fstype=iso9660,ro,nosuid,nodev  :/dev/cdrom
usb     -fstype=vfat,rw,nosuid,nodev     :/dev/sda1

However it doesn't seem to be working, what would be the best method to have these auto mount? Or is there just something wrong with my scripts?

The pen drive is always /dev/sda1 or at least /dev/sda but for my purposes it will always be the first partition, the memory card in a pi is /dev/mmcblk0p1

I have also checked that autofs is running.

Seems the respective folder in /media is not being created, and if i try to create it myself i get permission denied even as root.

/media permissions are:

drwxr-xr-x  2  root root 0
  • Is your useb drive always /dev/sda1? In fact, is it ever? That is usually the name of the 1st HDD, the memory card in a Pi I guess. – terdon Jun 10 '13 at 16:24
  • it is always /dev/sda1 or at least /dev/sda but for my purpose it will always be the first partition, the memory card in a pi is /dev/mmcblk0p1 – Zac Powell Jun 10 '13 at 17:45
  • OK, is the autofs service running? Check with service autofs status. – terdon Jun 10 '13 at 17:47
  • yes autofs is running – Zac Powell Jun 10 '13 at 17:50
  • Seems the respective folder in /media is not being created, and if i try to create it myself i get permission denied even as root – Zac Powell Jun 10 '13 at 18:16
0

autofs doesn't actually attempt to mount media unless the mount point is accessed; you want something that will listen to attach notifications such as halevt or udevil.

  • 1
    could you expand on this? – Zac Powell Jun 10 '13 at 19:55
  • In what way? autofs doesn't automatically mount, so find something that does. – Ignacio Vazquez-Abrams Jun 10 '13 at 19:55
  • Sorry, I just met do you have any experience with either halevt or udevil, and how I would set one of these up for what I require – Zac Powell Jun 10 '13 at 19:57
  • I haven't used either, since I run X (along with the listener/mounter in the DE) on mine. – Ignacio Vazquez-Abrams Jun 10 '13 at 19:58
0

Check udevil, it allows you to mount devices without need a password, also it comes with devmon wich is a daemon that watch for new devices beign plugged.

I'm using it with xmonad, and it's pretty cool, the best (only) and easy way that i found to do this.

So, for use udevil you just need to put as normal user:

udevil mount /dev/sb2

And for use devmon, wich is what you need something like:

devmon&

Also you can tell devmon what to do when something is mounted or unmounted:

devmon --exec-on-drive     "spacefm %d" \
   --exec-on-disc          "spacefm %d" \
   --exec-on-video         "vlc --verbose=-1 dvd://%f" \
   --exec-on-audio         "vlc --verbose=-1 cdda://%f" \
   --exec-on-unmount       "notify-send Device %f %l has been unmounted" \
   --exec-on-remove        "notify-send Device %f has been removed"

The devmon reference.

The udevil reference.

This guy has done a pretty awesome job, and there's spacefm wich is his FM.

Also there's another device mounter "ldm" it's not so fancy but is very light, just a 19.35kb of a c file, the repo is: LemonBoy/ldm (i can't put more than two links).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.