[Nix-dev] Automount for usb thumb drives / other external drives

Eelco Dolstra eelco.dolstra at logicblox.com
Thu Jul 16 13:58:29 CEST 2015


Hi,

On 15/07/15 23:22, Paul Koerbitz wrote:

> I would like to automatically mount usb sticks that I plug into my
> laptop. I haven't been able to figure out how to do this in NixOS,
> what's the easiest option?

The standard mechanism used for dealing with removable media is udisks, used by
desktop environments like KDE and Xfce to allow non-root users to mount disks.
It can also be used from the command-line, e.g.

  $ udisksctl mount -b /dev/sdb1
  Mounted /dev/sdb1 at /run/media/eelco/USBSTICK.

Udisks doesn't mount disks automatically on insertion, but this could be done by
having a script that listens for the D-Bus messages sent by udisks and then asks
udisks to do the mount. In fact, there already is a package that does this:

  https://github.com/fernandotcl/udisks-glue

but it's not in Nixpkgs yet.

-- 
Eelco Dolstra | LogicBlox, Inc. | http://nixos.org/~eelco/


More information about the nix-dev mailing list