(Last Updated On: June 19, 2018)

In this blog post, we will cover how to automount removable media devices from your Linux system using my favorite tool – udiskie. For those new to this tool, udiskie is a udisks2 front-end that allows you to manage removable media devices such as CDs or flash drives from userspace.

Features of udiskie

  • Automount removable media
  • Notifications on device mount/unmount
  • It provides a tray icon for easy management
  • Has command line tools for manual un-/mounting
  • Has support for LUKS encrypted devices
  • You can unlock with keyfiles (requires udisks 2.6.4)
  • Supports loop devices (mounting iso archives)
  • Supports password caching (requires python keyutils 0.3)

How to Install udiskie on Ubuntu / Debian

Run the following commands to get udiskie installed on your Ubuntu or Debian system:

sudo apt-get install python-setuptools udisks2 python-pip python-gobject python-yaml libgio2.0 gobject-introspection libgtk2.0-0 libnotify4 gettext gir1.2-notify-0.7

Then download the latest release of udiskie using pip

$ sudo pip install udiskie
Configure PolicyKit:

Edit the policy kit authorization file:

$ sudo vim  /etc/polkit-1/localauthority/50-local.d/consolekit.pkla

Add content below:

[udiskie]
Identity=unix-group:plugdev
Action=org.freedesktop.udisks.*
ResultAny=yes

Add your user to plugdev group:

$ sudo usermod -a -G plugdev $USER

How to Install udiskie on Arch Linux

For Arch Linux users, you can install udiskie from upstream repositories using pacman package manager:

$ sudo pacman -S udiskie

How to Install udiskie on Fedora

Use Fedora’s package manager dnf to install udiskie,

$ sudo dnf install python3-udiskie

After the installation is complete, proceed to udiskie usage section,

Using udiskie to Automount External devices on Linux

After having installed udiskie, try starting udiskie from a terminal to check if there are any errors:

$ udiskie

This will start udiskie in the foreground. If no errors are shown, you are good to proceed. The process can be stopped by hitting <Ctrl>+C.

To start udiskie as a background program in a stand-alone window manager add the following line to your ~/.xinitrc:

udiskie &

& means that the program will run in the background. To stop udiskie, just type

$ pkill udiskie

Manual device management with udiskie

To mount a specific device manually, use the syntax:

udiskie-mount /dev/sdb1

To unmount a specific device manually:

udiskie-umount /dev/sdb1

To recursively unmount and stop a device:

udiskie-umount /dev/sdb1 --force --detach

Thanks for reading the guide. I hope it was helpful.