This is an example of automounting an mp3 player (Creative Zen xfi) running Rockbox in a Gentoo system.
I did this in 2 stages.
Since the device name of the mp3 player will vary (could be /dev/sdd1 /dev/sdf1 etc.) the first stage is to ensure the device name is always the same. This is a useful site with good examples of how to do this. I created a file as shown on this site called /etc/udev/rules.d/65-stick.rules containing:
# # Rockbox device
KERNEL=="sd*", SUBSYSTEMS=="usb", ENV{ID_VENDOR}=="Rockbox", \ ENV{ID_SERIAL}=="Rockbox_Internal_Storage*", SYMLINK+="zen%n", GOTO="stick_end"
LABEL="stick_end"
This rule uses unique information about the device which you can gather through a couple of commands. First, dmesg, which in this case allows you to identify the device name. Here is an extract from the dmesg output:
[1203747.956962] usb 4-1: New USB device found, idVendor=041e, idProduct=4162
[1203747.956965] usb 4-1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[1203747.956967] usb 4-1: Product: Rockbox media player
[1203747.956969] usb 4-1: Manufacturer: Rockbox.org
[...]
[1203748.988809] sd 243:0:0:1: [sdf] 31291392 512-byte logical blocks: (16.0 GB/14.9 GiB)
[1203748.992059] sd 243:0:0:0: [sdb] Write Protect is off
[1203748.992064] sd 243:0:0:0: [sdb] Mode Sense: 0b 00 00 08
[1203748.994794] sd 243:0:0:1: [sdf] Write Protect is off
[...]
[1203749.040790] sdb: sdb1
[1203749.047790] sdf: sdf1
[1203749.088771] sd 243:0:0:0: [sdb] Attached SCSI removable disk
[1203749.091768] sd 243:0:0:1: [sdf] Attached SCSI removable disk
From this I can tell that the device's internal drive is /dev/sdb1 and that the SD memory card in the device's memory slot is /dev/sdf1.
The command udevadm info /dev/sdb1 shows some further information about the device including the following lines:
The ID_SERIAL and ID_VENDOR values are now used to uniquely identify the device in the udev rule shown above.
The udev rule ensures that symoblic links is created for the Creative Zen device. The device names are always zen and zen1.
The following command ensures that any new udev dule is active:
udevadm control --reload-rules
The following command ensures that any new udev dule is active:
udevadm control --reload-rules
Now to autofs for which I found this Gentoo wiki page the most useful. I emerged autofs and then ensured it was enabled and started in systemd:
systemctl enable autofs.service
systemctl start autofs.service
Next I edited the /etc/autofs/auto.master file to include:
/media /etc/autofs/auto.misc --timeout=15 --ghost
This means that the mount instructions in auto.misc will mean that the filesystem is mounted under /media.
My /etc/auto.misc has the following line:
zen -fstype=vfat,rw,uid=1000,gid=100 :/dev/zen1
This means that a mountpoint /media/zen will be created for the device /dev/zen1 and that the filesystem is writeable by the user.