USB storage devices
Auto-mounting with udisks
udiskie, a udisks2 front-end that allows to manage removable media can be used. To enable automounting, first enable udisks2:
services.udisks2.enable = true;
Next enable udiskie via Home Manager:
services.udiskie = {
enable = true;
settings = {
# workaround for
# https://github.com/nix-community/home-manager/issues/632
program_options = {
# replace with your favorite file manager
file_manager = "${pkgs.nemo-with-extensions}/bin/nemo";
};
};
};
Once the configurations are reflected, USB storage devices will be instantly recognized when inserted without any additional operations needed.
Mounting at boot
= Troubleshooting
While booting you might get a timeout error, caused by missing kernel modules in your initrd. Error message: [ TIME ] Timed out waiting for device /dev/disk/by-partlabel/disk-<name>-<partition>
To fix this simply add the missing kernel module to your initrd.
{
boot.initrd.availableKernelModules = [
"uas" # USB Attached SCSI driver
];
}
You can find the missing kernel modules by plugging in your external storage device and comparing the outputs of the following two commands:
# Modules available on booted system:
lsmod# Modules available at boot:
nix eval --file '<nixpkgs/nixos>' -A config.boot.initrd.availableKernelModules
For other solutions, please refer to udisks - ArchWiki or USB storage devices - ArchWiki.