Too Many Links
Production Risk
Rare outside backup and deduplication tools.
EMLINK (errno 31) is returned when creating a hard link would exceed the maximum link count for a file (typically 65535 on ext4), or when creating a directory would exceed the maximum number of subdirectories a parent directory can have.
- 1Creating more than 65535 hard links to a single file on ext4
- 2Creating more than 65000 subdirectories in a single directory on ext4 (the parent's link count would overflow)
- 3Backup tools that create large numbers of hard links for deduplication
Hard-link based backup tools creating too many links.
// C: link() returns EMLINK
link("source.txt", "hardlink65536.txt");
// Returns -1, errno = EMLINKexpected output
link: Too many links (EMLINK)
Fix
Split large hard-link sets across multiple directories
WHEN When backup or dedup tools create too many hard links
# Structure backup data across multiple directories: /backup/2024-01/ → links to pool /backup/2024-02/ → links to pool (different pool dir if needed)
Why this works
Spread hard links across multiple directories to stay within the per-inode link count limit. For very large datasets, consider filesystems with higher limits like XFS or btrfs.
Maximum hard link count per inode is 65000 (soft) to 65535 (hard).
Content generated with AI assistance and reviewed for accuracy. Found an error? hello@errcodes.dev