disk usage issue with rsync and --link-dest
When you ran rsync -avh --link-dest=full orig/ orig_1
, you ignored this error message (it's more obvious if you remove -v
):
--link-dest arg does not exist: full
If we then take a look at man rsync
under --link-dest
, we find:
If DIR is a relative path, it is relative to the destination directory.
And there it is. full
is relative to the current directory. Relative to the destination directory, it would be ../full
.
If you try again with rsync -avh --link-dest=../full orig/ orig_1
, you get what you expect:
$ du -sh *149M full149M orig232K orig_1$ du -sh .298M .
Note that, when counted individually, the directories still appear take up the full space:
$ du -sh orig_1 149M orig_1
This is because du
keeps track of files it's already seen, and avoids counting them twice.
Standard Unix filesystems do not allow hard links to directories, except for the special .
and ..
links. --link-dest
only creates hard links for files, the rest of the directory structure is recreated as real directories.
And even if hard links were allowed to directories, du
would still show the full size of each link. When using hard links, there's no distinction between the original and the link, they're each just names that refer to a particular inode, and du
would scan them equivalently.