4

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?

1

2 Answers 2

4

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:

  • if the new symlink would be created in a different directory, that new directory might not have space for the new directory entry, and if there are no free data blocks, the directory can't be extended.
  • similarly, if the new symlink would be created in the same directory but with a longer name, the directory might run out of space
  • if the old symlink was short enough to be stored entirely in the inode, but the new link would be long enough to require a data block, the new symlink can't be created if there are no free data blocks on the filesystems.

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.

0

The new link was larger than the old one.

ls -l will show how many bytes that symlink is and the longer the path, the more bytes are needed.

It's roughly the number of bytes in the full path to the target file/directory. A link to "/var/www/html" is 13 bytes using ext4 on debian 10. Depends on the file system.

You could also be out of inodes.

1
  • 5
    ls -l shows the size of a file or the length of a symlink in bytes, but most filesystems don't allocate space by bytes, but in larger blocks.
    – ilkkachu
    Apr 16 at 20:45

You must log in to answer this question.

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