Jump to content

USB storage devices: Difference between revisions

From Official NixOS Wiki
34j (talk | contribs)
Created page with "== Auto-mounting with udisks == [https://github.com/coldfix/udiskie/wiki/Usage udiskie], a udisks2 front-end that allows to manage removable media can be used. To enable automounting, first enable udisks2: {{file|/etc/nixos/configuration.nix|nix|3=services.udisks2.enable = true;}} Next enable udiskie via Home Manager: {{file|~/.config/home-manager/home.nix|nix|3= services.udiskie.enable = true; # services.udiskie.automount = true; # true by default}} For other s..."
 
Fix heading
 
(5 intermediate revisions by 2 users not shown)
Line 1: Line 1:
== Auto-mounting with udisks ==
== Auto-mounting with udisks ==


[https://github.com/coldfix/udiskie/wiki/Usage udiskie], a udisks2 front-end that allows to manage removable media can be used. To enable automounting, first enable udisks2:
[https://github.com/coldfix/udiskie udiskie], a {{nixos:option|udisks2}} front-end that allows to manage removable media can be used. To enable automounting, first enable udisks2:


{{file|/etc/nixos/configuration.nix|nix|3=services.udisks2.enable = true;}}
{{file|/etc/nixos/configuration.nix|nix|3=services.udisks2.enable = true;}}
Line 8: Line 8:


{{file|~/.config/home-manager/home.nix|nix|3=
{{file|~/.config/home-manager/home.nix|nix|3=
services.udiskie.enable = true;
services.udiskie = {
# services.udiskie.automount = true; # true by default}}
    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";
        };
    };
};
}}


For other solutions, please refer to [https://wiki.archlinux.org/title/Udisks#Mount_helpers udisks - ArchWiki].
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].
 
[[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.