Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is there a limit of number of hardlinks for one file? Is it specified anywhere? What are safe limits for Linux? And what for other POSIX systems?

share|improve this question
up vote 11 down vote accepted

Posix requires that the operating system understand the concept of hard links but not that hard links can actually be used in any particular circumstance. You can find out how many hard links are permitted at a particular location (this can vary by filesystem type) by calling pathconf(filename, _PC_LINK_MAX). The minimum limit (_POSIX_LINK_MAX) is 8, but this is rather meaningless as link() can report many other errors anyway (permission denied, disk full, …).

The stat structure stores the link count in a field of type nlink_t, so the type of this field gives an upper limit on your system. But there's a good chance you'll never be able to reach that far: it's common to have a 32-bit nlink_t but only 16 bits in many filesystems (a quick grep in the Linux source shows that ext[234], NTFS, UFS and XFS use 16-bit link counts in the kernel data structures).

share|improve this answer
As a supplement: BTRFS seems to use 8 bit link count. – Maciej Piechotka Jan 3 '12 at 17:15
@Rather, 8-bit link count for hard links in the same directory, but 32-bit count in total, according to this blog post/ – Gilles Jul 15 at 14:00

Looking at the ext3 inode structure disk format in the linux kernel sources (*include/linux/ext3_fs.h*) that lists the links count as being a 16 bit number

struct ext3_inode {
    ... snip ...
    __le16  i_links_count;  /* Links count */


I guess that means that an ext3 filesystem can have up to 65535 links.

I haven't checked the values for other filesystems.

share|improve this answer

This is file system dependent.

ext2/3/4 limit is 65k links

ext4 source line 643, struct ext4_inode -> __le16 i_links_count

share|improve this answer
The actual limit is 65534. The last counter entry is used for a transient in the rename() system call. – Joshua Jan 11 '11 at 0:03
Even less (found in same ext4.h): /* Maximal count of links to a file */ #define EXT4_LINK_MAX 65000 – PoltoS Apr 23 '12 at 22:02

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.