I'm not sure how I ended up using an obscure GNU/Linux distro such as Void - after finally managing to install Arch with XFCE, and realizing that all the hard work was only beginning, I deleted and kept using MX Linux for a few months more. Then winter holidays came, and thought it was finally time to stop admiring all those wonderful setups from r/unixporn and make my own!

Having already used Void before on a VM and a cheap netbook, I felt it was the right choice for my main OS - something simple to install and use on a dialy basis, with up-to-date packages, and that had a minimalistic design. After using it for several months (and breaking it dozens of times), I've come to understand its ways and quirks, and thought a handy guide to setting things up would be useful.

I'd like to begin with something I usually forget how to do:

Automounting

Sooner or later you come to realize that plugging a USB drive doesn't exactly work out of the box on such a barebones distro, and can be a little tricky - many posts I've seen about people desperately seeking for a solution, so here's one!

First we have to understand how things normally work: there's a little program called udisks that basically manages storage devices of all kind via a daemon (background process). However, on it's own, it doesn't automount anything, so there comes the need for another little program that does that for us, called udiskie.

# xbps-install -S udiskie

Now all we need to do is put udiskie & on our .xinitrc and it should work perfectly when we boot into X, right? Not yet - this would only work with root permission! Following the documentation, it just consists of creating a new policy rule file like this:

# vim /etc/polkit-1/rules.d/50-udiskie.rules

Inside it, paste the following:

polkit.addRule(function(action, subject) {
  var YES = polkit.Result.YES;
  // NOTE: there must be a comma at the end of each line except for the last:
  var permission = {
    // required for udisks1:
    "org.freedesktop.udisks.filesystem-mount": YES,
    "org.freedesktop.udisks.luks-unlock": YES,
    "org.freedesktop.udisks.drive-eject": YES,
    "org.freedesktop.udisks.drive-detach": YES,
    // required for udisks2:
    "org.freedesktop.udisks2.filesystem-mount": YES,
    "org.freedesktop.udisks2.encrypted-unlock": YES,
    "org.freedesktop.udisks2.eject-media": YES,
    "org.freedesktop.udisks2.power-off-drive": YES,
    // required for udisks2 if using udiskie from another seat (e.g. systemd):
    "org.freedesktop.udisks2.filesystem-mount-other-seat": YES,
    "org.freedesktop.udisks2.filesystem-unmount-others": YES,
    "org.freedesktop.udisks2.encrypted-unlock-other-seat": YES,
    "org.freedesktop.udisks2.eject-media-other-seat": YES,
    "org.freedesktop.udisks2.power-off-drive-other-seat": YES
  };
  if (subject.isInGroup("storage")) {
    return permission[action.id];
  }
});

Set the right permissions:

# chmod 644 /etc/polkit-1/rules.d/50-udiskie.rules

Finally, make sure your user is in the storage group:

# usermod -aG storage <YOUR_USER>

And that's it! Now we should be able to plug any USB drive without hassle and call udiskie as a user without root permissions. We'll receive notifications whenever you plug something in:

Hello Friend

and when we unplug it with udiskie-umount /dev/sdX:

Hello Friend

Mounting to /media/

By default, since udiskie is just a frontend for udisks, it will mount things on /run/media/$USER/. Since I'm used to mounting on /media/, and the only user on my computer, there's a way to go back to that.

First, let's create a new rule

# vim /etc/udev/rules.d/99-udisks2.rules

Inside it, paste the following:

# UDISKS_FILESYSTEM_SHARED
# ==1: mount filesystem to a shared directory (/media/VolumeName)
# ==0: mount filesystem to a private directory (/run/media/$USER/VolumeName)
# See udisks(8)
ENV{ID_FS_USAGE}=="filesystem|other|crypto", ENV{UDISKS_FILESYSTEM_SHARED}="1"

Finally, since /media/ doesn't delete the folders it creates, we can work around that by making it a temporary file system, which will wipe out anything each time we reboot the system. Let's add the following to /etc/fstab:

tmpfs /media tmpfs nodev,nosuid,size=1M 0 0

We're done! Now we have a functional and working automounting system.