IBM Support

Unable to create a directory due to too many links.

Troubleshooting


Problem

When customers attempt to create a directory, they get the error message below: # mkdir mydir mkdir: 0653-358 Cannot create mydir. mydir: There are too many links to a file.

Cause


This is a limitation for AIX of 32767 sub-directories in a single directory. If we check the file /usr/include/sys/limits.h we can see the definition:

#define LINK_MAX SHRT_MAX /* max of a file's ilink counts, >= 8 */

Therefore, the symbol (SHRT_MAX) defines the number that the LINK_MAX can hold.

If we also search in the same file, we will find that the SHRT_MAX is defined with that number:

#define SHRT_MAX (32767)

Based on that, the LINK_MAX value = the value of SHRT_MAX = 32767 sub-directories in a single parent directory.

For more information on this, please refer to the IBM reference for the limits.h file:

https://www.ibm.com/support/knowledgecenter/en/ssw_aix_61/com.ibm.aix.files/limits.h.htm

Diagnosing The Problem


We can check that with that command:

# ls -1 | wc -l

If your directory has hit this limit, you will not be able to create files or directories in it. You are running across a limitation of sub-directories (links) that one directory can hold.

Resolving The Problem


At this point, there is no way to change that value because this is an architectural limitation imposed on the filesystem. It is not simply an issue of a kernel limitation; this file (limits.h) may be used by any command or application wishing to use these limits in their code. Changing this file would require a complete rebuild of AIX and any application compiled using this file.

However, there are 2 possible workarounds for this problem:

1) Move some directories to another parent directory.

OR

2) Create the directories in another parent directory and create links to these directories in the target directory

In the future, we would advise breaking up these sub-directories into a more tree-like
fashion.

So instead of a flat subdirectory structure like this one:

/myfs
    /dir1
    /dir2
    /dir3
    /dir4

Use a more nested tree approach:

/myfs
   /topdir1
      /dir1
      /dir2
   /topdir2
      /dir3
      /dir4

If you need any further assistance, please feel free to contact IBM Software Support team.

[{"Product":{"code":"SWG10","label":"AIX"},"Business Unit":{"code":"BU058","label":"IBM Infrastructure w\/TPS"},"Component":"Not Applicable","Platform":[{"code":"PF002","label":"AIX"}],"Version":"Not Applicable","Edition":"","Line of Business":{"code":"LOB08","label":"Cognitive Systems"}}]

Document Information

More support for:
AIX

Software version:
Not Applicable

Operating system(s):
AIX

Document number:
631019

Modified date:
17 June 2018

UID

isg3T1025137

Manage My Notification Subscriptions