I have a large directory structure that has many hard links from the first hard link which lives in a different directory structure. For example
dir1 has the following structure :
[dir1]$ tree . ├── dir_inside │ ├── file1 │ └── file2 └── other_dir ├── file1 └── file2
Now lets suppose
dir2 exists outside
dir1 and all files in
file2 are hard links of files that primarily existed in
dir2 i.e. files in
dir2 existed before
dir1 was created.
When calculating the size of
dir1 I would go for the command
du -sh dir1 since
du will only count hard-links only once. Ok so far so good, but by counting only once this means that I am actually counting not from the first hard link which lives in
dir2. So let's say
du -sh dir2 is
2G in size.
dir1 will also be
2G in size since the hard link will be counted once in that directory structure. As far as my knowledge in hard-links concern I believe hard-links do not actually have the same file size as the first
inode created right ? I would really enjoy getting some clarification on getting the directory size of hard-link files that live in different directories, thus getting an estimation of the real disk space the hard-links are occupying.