Too many links Error in the Nix storeSymptom: when building something, you get an error message such as
...
mkdir: cannot create directory `/nix/store/name': Too many linksThis is usually because you have more than 32,000 subdirectories
in /nix/store, as can be seen using ls
-l:
$ ls -ld /nix/store
drwxrwxrwt 32000 nix nix 4620288 Sep 8 15:08 store
The ext2 file system is limited to an inode link
count of 32,000 (each subdirectory increasing the count by one).
Furthermore, the st_nlink field of the
stat system call is a 16-bit value.This only happens on very large Nix installations (such as build
machines).Quick solution: run the garbage collector. You may want to use
the option.Real solution: put the Nix store on a file system that supports
more than 32,000 subdirectories per directory, such as ext4. (This
doesn’t solve the st_nlink limit, but ext4 lies to
the kernel by reporting a link count of 1 if it exceeds the
limit.)