1

Preface

I create a media folder structure with Python consisting of hundred of thousands symbolic links. This folder structure allows me to navigate my media files like in a complex application, e.g. Kodi, but on file system level. In order to avoid many disk write operations I create the links on a RAM drive. The disk is mounted as follows:

# sudo mount -t tmpfs -o size=100M none /mnt/mem

The Issue

After creating many links the script outputs the following error:

[Errno 28] No space left on device: '...'@78596

If I check the actual disk usage, it returns the following:

$ df -h
// ...
none            100M    1,7M   99M    2% /mnt/mem

So according to my system, only 2 % are used!

The system is:

$ uname -a
Linux myServer 3.2.0-23-generic-pae #36-Ubuntu SMP Tue Apr 10 22:19:09 UTC 2012 i686 i686 i386 GNU/Linux

After some investigation my script is able to create up to 90,000 links.

The Weird

If I try to reproduce the error on my desktop, it works flawlessly. I'm able to produce over 1,000,000 links with no issues. I don't know the actual limitation.

The system is:

$ uname -a
Linux myDesktop 4.15.0-76-generic #86-Ubuntu SMP Fri Jan 17 17:24:28 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux

The Questions

  1. What limits the number of symbolic links in linux?
  2. Can I bypass the limitation by upgrading the OS?
  3. Can I bypass the limitation by upgrading to a 64-bit architecture?

Some deep insights would be welcome!

Thanks.

  • 3
    Include `-i` in that call to `df` on both systems. This will tell you the number of available inodes. Each file (whether a symbolic link, directory, regular or other file) uses an inode. The number of allocatable inodes is determined when you create the filesystem. – Kusalananda Mar 12 '20 at 23:17
  • 1
    See [Can I run out of disk space by creating a very large number of empty files?](https://unix.stackexchange.com/q/378148/170373) which seems to explain running out of inodes. In this regard, symlinks are like small files: they need an inode but use very few data blocks. – ilkkachu Mar 12 '20 at 23:26
  • Using a ram-disk in place of the regular (persistent) disk, will probably not have the effect that you are going for. Hard/ssd/etc-disk is cached (in RAM). – ctrl-alt-delor Mar 14 '20 at 22:06
  • Kusalananda thanks for hint - there is an option to adjust the number of available inodes when mounting the RAMdisk. – DasTabernakel Mar 14 '20 at 22:40
  • ctrl-alt-delor it has the effect I want. It's a script executed on startup with reproducible results, such that it effectively acts like a hard-disk. – DasTabernakel Mar 14 '20 at 22:40

0 Answers0