I have a server which contains 1 TB of space. I filled it to capacity; then I wanted to make a symlink. I removed a different symlink, but the server still wasn't happy – it said I didn't have any space available. Didn't I just clear enough space by removing the last symlink…?
How much space does a filesystem need in order to recognize that there's enough space to create a symlink?
Best Answer
It depends. Most filesystems allocate data in blocks of some kilobytes, so one might imagine any symlink fits in a single block. But then there's the question of other filesystem metadata, which depends on the filesystem.
On ext4 (and similar filesystems) specifically:
A small file requires an inode, a data block, and space for the directory entry in the directory containing the file. Short symlinks may be stored entirely within the inode, so they might not need a data block at all. (IIRC the limit is around 60 bytes or so.)
Removing a symlink releases the inode and frees the space used by the directory entry as well as the data block if one was used. There are a few cases where that might not be enough for a new symlink:
Running out of inodes should not be an issue, as the deleted symlink would have necessarily used exactly one inode, and a new symlink will require exactly one inode.