7

For minimal installations of Debian, I have been using halevt to enable automounting of USB drives. Halevt is reliable and requires no configuration aside from installing the package. Now, halevt has been removed from Debian Testing and I'm looking for a replacement, but none of the alternatives seem to be as straightforward.

What utility for automounting USB drives would be the most lightweight, simple, and stable?

EDIT: I was never able to get udev working the way I wanted. The problem is that udev rules are always run as root, so media are mounted as root. It is possible to hard-code mounting as a specific user, but it seems you can't make a rule that mounts as current user. According to the documentation, it should be possible with the MODE value, but it doesn't seem to be implemented in Debian. So, if automounting is required, I still have to use halevt. Otherwise, I use pmount.

user5184
  • 685

3 Answers3

3

The disk-based features of HAL were replaced by udev and udisks.

There is a full example of how to use udev to do this on the Automounting UDisks wrappers page:

/etc/udev/rules.d/11-media-by-label-auto-mount.rules

KERNEL!="sd[a-z][0-9]", GOTO="media_by_label_auto_mount_end"

# Import FS infos
IMPORT{program}="/sbin/blkid -o udev -p %N"

# Get a label if present, otherwise specify one
ENV{ID_FS_LABEL}!="", ENV{dir_name}="%E{ID_FS_LABEL}"
ENV{ID_FS_LABEL}=="", ENV{dir_name}="usbhd-%k"

# Global mount options
ACTION=="add", ENV{mount_options}="relatime"
# Filesystem-specific mount options
ACTION=="add", ENV{ID_FS_TYPE}=="vfat|ntfs", ENV{mount_options}="$env{mount_options},utf8,gid=100,umask=002"

# Mount the device
ACTION=="add", RUN+="/bin/mkdir -p /media/%E{dir_name}", RUN+="/bin/mount -o $env{mount_options} /dev/%k /media/%E{dir_name}"

# Clean up after removal
ACTION=="remove", ENV{dir_name}!="", RUN+="/bin/umount -l /media/%E{dir_name}", RUN+="/bin/rmdir /media/%E{dir_name}"

# Exit
LABEL="media_by_label_auto_mount_end"

For more information about udev:

There are also a few options based on udisks that would be the new equivalent of halevt:

I couldn't find any of those in the testing repository, so you might have to find a third-party apt repository, or follow their instructions to compile the software on your own machine.

Mikel
  • 57,299
  • 15
  • 134
  • 153
  • I'm hoping for a simple solution like halevt, just "Install and you are done." I'll have to look at those packages. – user5184 Apr 17 '11 at 02:28
  • Copy the code above, paste it into the suggested file (/etc/udev....rules), and hopefully you're done. – Mikel Apr 17 '11 at 03:00
  • Been trying this on two Debian machines, but it doesn't work well. 1. All devices are mounted as root. 2. Auto-unmounting sometimes fails, leaving a node that is persistent through a reboot. 3. Some unpowered drives don't get mounted at all. 4. Several times failed transfer of files. I've had none of these problems with halevt. – user5184 Apr 21 '11 at 04:39
2

If you don't want to use hal, you could use a udev rule to automount your drives. The Arch Wiki has a good article on rules here:

https://wiki.archlinux.org/index.php/Udev#Auto_mounting_USB_devices

You could also look at using something like udiskie (it's in the AUR):

https://wiki.archlinux.org/index.php/Udiskie

There is also a script for integrating udiskie into your Openbox menu.

jasonwryan
  • 73,126
  • Thanks, that helps a lot! I did read the Arch documentation for Udev however it doesn't really explain how exactly to write your own rules, which annoys me a bit because I want to understand what it's doing before I just copy and paste it in. I'll try it out and see if it mounts my stuff. By the way, what's the benefit of using HAL over Udev or vice-versa? – kelinu Apr 25 '11 at 22:16
  • HAL has been deprecated and is no longer developed, so -sooner or later, you will need to move to other arrangements. The first rule on the wiki page should accomplish what you are after... – jasonwryan Apr 25 '11 at 22:20
  • OK thanks...I'll stick with Udev then and I'll get that rule working properly – kelinu Apr 25 '11 at 22:24
1

You should probably look into setting up your own udev, hal or hotplug rules to automount drives and even run commands when they connect. You could also look into pmount.

There are quite a few automounters for linux, you just have to figure out what suits your work best.

Also be aware that you can run many parts from the larger DE's like gnome without running the full thing. You should be able to use gnome-volume-manager separately from using it for your session.

Caleb
  • 70,105