Jump to content

USB storage devices: Difference between revisions

From Official NixOS Wiki
34j (talk | contribs)
Add workaround for https://github.com/nix-community/home-manager/issues/632
Fix heading
 
(One intermediate revision by the same user not shown)
Line 22: Line 22:


Once the configurations are reflected, USB storage devices will be instantly recognized when inserted without any additional operations needed.
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.
{{File|3={
  boot.initrd.availableKernelModules = [
    "uas" # USB Attached SCSI driver
  ];
}|name=/etc/nixos/configuration.nix|lang=nix}}
You can find the missing kernel modules by plugging in your external storage device and comparing the outputs of the following two commands:
<syntaxHighlight>
# Modules available on booted system:
lsmod
</syntaxHighlight>
<syntaxHighlight>
# Modules available at boot:
nix eval --file '<nixpkgs/nixos>' -A config.boot.initrd.availableKernelModules
</syntaxHighlight>


For other solutions, please refer to [https://wiki.archlinux.org/title/Udisks#Mount_helpers udisks - ArchWiki] or [https://wiki.archlinux.org/title/USB_storage_devices USB storage devices - ArchWiki].
For other solutions, please refer to [https://wiki.archlinux.org/title/Udisks#Mount_helpers udisks - ArchWiki] or [https://wiki.archlinux.org/title/USB_storage_devices USB storage devices - ArchWiki].


[[Category:Hardware]]
[[Category:Hardware]]

Latest revision as of 16:02, 30 October 2026

Auto-mounting with udisks

udiskie, a udisks2 front-end that allows to manage removable media can be used. To enable automounting, first enable udisks2:

❄︎ /etc/nixos/configuration.nix
services.udisks2.enable = true;

Next enable udiskie via Home Manager:

❄︎ ~/.config/home-manager/home.nix
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.

❄︎ /etc/nixos/configuration.nix
{
  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.