6

I plan to keep all my movies in one giant folder, and then create other folders for the genres, while creating links for all the movies in the genre folder. This way I can organize movies into multiple genres without unnecessarily copying them.

I've been planning to use hard links in this endeavor in order to create a more robust system in which I may be able to move files around without breaking links. However, I'm wondering if hard links will take more storage space than symbolic links and bloat my machine. I've created soft and hard links to files to test this, but they both show the original file size when I look at file size under preferences in Thunar.

Which file takes more hard drive space, Symbolic Links, or Hard Links?

On a semi-unrelated side note, does xbmc / kodi recognize links to videos as actual videos?

2
  • 1
    Strictly this is going to depend on the file system you're using (so edit with details), but they are likely to be the same size. Jun 26, 2015 at 2:06
  • A symbolic link is a file. A hard link is a dentry that points to a file. Weird how they call it kodi now. I still have my first soft-modded xbox. It maybe you would discover a little more on this subject if you ventured a little more than a Thunar lookup, though. That's just a gentle nudge. It's a good question.
    – mikeserv
    Jun 26, 2015 at 2:20

2 Answers 2

4

Symbolic link files take more space. Hard linked files share the same inode; but a symbolic file is a pointer to the original (location).

Despite that, there are two caveats for hard links:

  • Not all file system support hard links.
  • Hard links cannot be applied for folders.

I guess you do not need to consider about the storage issue since in most of the cases they are trivial. In addition, there might be some tools helping you organize genres virtually (they may take advantages of virtual file systems).

3
  • 1
    Thank you. Is there a way to view exactly how big the link file is? Like I said, it always shows the original file size. Also, I don't want to use tools because I don't want my organization systems to be reliant on the installation of a certain program, if I reinstall or remove it I want to be able to keep my stuff, but thanks for the suggestion!
    – Max Hanson
    Jun 26, 2015 at 2:27
  • For symlink files, on my Linux, ls -l sym_file_name displays the symlink size, ls -lHd sym_file_name for original file size. I suspect there is a way to get the size of the hard link file (actually they both are originals). Jun 26, 2015 at 3:53
  • So, for me in ext4, a symlink is 1 byte. Is it possible to quantify the space taken up by a hard link?
    – Sparhawk
    Jun 27, 2015 at 13:27
4

The difference is negligible and irrelevant. Creating a hard link or a symbolic link only takes up a few bytes. A hard link costs one directory entry: space to store the name and the inode number in the directory. A symbolic link also costs one directory entry, plus space to store some metadata about the symbolic link; depending on the filesystem, this information can be stored in the directory entry or require a separate inode. A symbolic link uses a few more bytes, around the order of 100 or so, which is negligible — less than 1/1000 of the files you're storing.

If you had very small files, and you had so many files and so many links per target that adding hundreds bytes per target was relevant, then a proper database would be more appropriate to store your data. But to make links just to classify files, that's irrelevant.

Disk usage tools won't tell you the size consumed by an extra hard link or symbolic link because they only show the size of the file content, not of the metadata, and a symlink is all metadata, as is an extra hard link to an existing file. (Technically, the “size of a hard link” is the size of the file. After all, every file that has a name has a hard link, and the content is the same regardless of whether there is a single hard link or more.) Beware that some unsophisticated tools may count the size of a file twice if they see it from different paths; du and most graphical file managers do count files only once.

Usually symbolic links are easier to manipulate. They let you clearly identify which is the original and which is the target, whereas with hard links, all the names are equivalent. Another point about symbolic links is that if you edit the original, the symbolic links aren't affected, whereas editing a file that has multiple hard links may break the links, depending on how the editor works (overwrite with the new version vs. write a new file and move it into place).

If you want to be able to move files around in the primary classification, then you need to use hard links, because symbolic links are purely textual, they don't follow their target around.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .