When I create a hard link to a 2 KB file (called fun), Nautilus shows this hard link (called fun-hard) as a file with the same size. These two files are pointing to same inode so their combined properties should display only 2 KB as well. But Nautilus instead says their total size is 4 KB. Why?

  • 1
    What software is displaying their combined size as 4 kB? – Eliah Kagan Aug 6 '14 at 5:20
  • I am just Selecting file,hard link and looking into properties. – hunch Aug 7 '14 at 5:18
  • Is this in Nautilus (the file browser)? – Eliah Kagan Aug 7 '14 at 10:28
  • Sorry for delay in response... i am using Nautilus.. and link, information shared by Malte helped me understanding the issue...Thanks for your information sharing. – hunch Oct 4 '14 at 7:09
  • If you understand the issue now please edit and clarify your question or even better use the answer option to write the answer to your question in detail. – v2r Oct 4 '14 at 10:23

Of course, if you create a hard link to a file, then both the original file and the hard link point to the same inode. In fact, both are equivalent - for the system there is no such thing as "the original" and "the link". They are simply two access points to the same inode. Consequently, they take up no more space together than if you had only one access point (except for the tiniest bit of information in the filesystem, where two pointers to some inode are stored instead of only one).

You can easily confirm this when you use a low-level filesystem utility such as, for instance, du. For example, here I have a directory with a single song (FOSS Yeaaaah!, an awesome song about Ubuntu by Ben Kerensa) of about 2.1 MB:

$ ls -li 
total 2124
6424897 -rw-rw-r-- 1 malte malte 2162937 Aug  7 12:53 FOSS Yeaaaah!.mp3
$ du -ch * # display size of all files, and total size
2.1M    FOSS Yeaaaah!.mp3
2.1M    total
$ du -h . # display size of current directory
2.1M    .

When I create a hard link, say Link.mp3, to the file, du actually recognizes that both filenames point to the same file and only displays one of both:

$ ln FOSS\ Yeaaaah\!.mp3 Link.mp3
$ ls -li
total 4248
6424897 -rw-rw-r-- 2 malte malte 2162937 Aug  7 12:53 FOSS Yeaaaah!.mp3
6424897 -rw-rw-r-- 2 malte malte 2162937 Aug  7 12:53 Link.mp3
$ du -ch *
2.1M    FOSS Yeaaaah!.mp3
2.1M    total
$ du -h .
2.1M    .

(It's displaying only the one that comes first in alphabetical order - had I named the hardlink A.mp3, then du would have displayed that one).

The behavior you're experiencing is most probably a bug or inaccuracy in whatever software you are using to display file sizes. If it's Nautilus (the standard file browser in a typical Ubuntu installation), then I can confirm that behavior. See this bug report:


It may just be "a feature, not a bug" - as Nautilus is trying to keep things simple for the average user, it simply ignores hard links. Which may not always be the best idea. Quoting from the bug report:

Nautilus tries to keep things simple. That's why it does not offer a way to make hardlinks. But if things are already complicated - if hardlinks are already present - just ignoring them can lead to problems of its own.

In summary, if you're working with hard links, better rely on a terminal instead of some file browsing application.

  • 2
    ...and remember that the granularity of du is 4K (at least in a default-formatted ext4 filesystem). So du will report 4K for a file of 2K length... – Rmano Aug 7 '14 at 11:33
  • To be precise, the granularity of du is that of the underlying file system (unless you specify --apparent-size), which is 4 KiB for ext4 by default for typical use cases (at least in Ubuntu). It's 64 KiB for my FAT32-formatted mobile music player with a 80 GB disk. – David Foerster Oct 5 '14 at 13:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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