Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

According to this answer it is possible to mount at least tmpfs with "infinite" inodes.

Consider this specific (numbers chosen for example purposes, I know that they're not realistic) situation:

  • The tmpfs partition is 50% used by volume
  • 90% of that data is inodes (i.e. 45% of the disk is used by inodes, and 5% is used by "real" data)
  • tmpfs was mounted with nr_inodes=1000
  • all 1000 of those inodes are taken up by the inodes currently written

This means that the tmpfs is 50% full, but also that any attempt to write to it will result in an out of space error.

It seems to me that setting nr_inodes=0 (aka infinite inodes) would make this situation go away.

  • Is there a reason that infinite inodes is not the default?
  • What reasons are there to limit the number of inodes on a filesystem?
share|improve this question
2  
tmpfs is not the default file system because it doesn't survive a reboot; it would be a very bad choice for a default FS. Other FSes don't have infinite inodes because they take up space, so a file system filled to the brim with inodes couldn't actually hold any data. –  MadHatter Jul 18 '13 at 14:45
    
I didn't know that the dynamic limit was only available to tmpfs and new filesystems. My question then becomes "why does tmpfs limit the number of inodes it can hold?" I'm going to update the question with a a rationale from my comment to @Gregg Leventhal –  quodlibetor Jul 18 '13 at 17:58
    
There is no dynamic limit with modern filesystems like ZFS and btrfs, there is just no limit at all (outside of course the physical available disk space). –  jlliagre Jul 18 '13 at 21:12
add comment

2 Answers

up vote 5 down vote accepted

Usually (ex: ext2, ext3, ext4, ufs), the number of inodes a file system can hold is set at creation time so no mount option can workaround it.

Some filesystems like xfs have the ratio of space used by inodes a tunable so it can be increased at any time.

Modern file systems like ZFS or btrfs have no hardcoded limitation on the number of files a file system can store, inodes (or their equivalent) are created on demand.


Edit: narrowing the answer to the updated question.

With tmpfs, the default number of inodes is computed to be large enough for most of the realistic use cases. The only situation where this setting wouldn't be optimal would be if a large number of empty files are created on tmpfs. If you are in that case, the best practice is to adjust the nr_inode parameter to a value large enough for all the files to fit but not use 0 (=unlimited). tmpfs documentation states this shouldn't be the default setting because of a risk of memory exhaustion by non root users:

if nr_inodes=0, inodes will not be limited.  It is generally unwise to
mount with such options, since it allows any user with write access to
use up all the memory on the machine; but enhances the scalability of
that instance in a system with many cpus making intensive use of it.

However, it is unclear how this could happen given the fact tmpfs RAM usage is by default limited to 50% of the RAM:

size:      The limit of allocated bytes for this tmpfs instance. The 
           default is half of your physical RAM without swap. If you
           oversize your tmpfs instances the machine will deadlock
           since the OOM handler will not be able to free that memory.
share|improve this answer
    
so I actually ran into this on tmpfs and didn't realize that it doesn't apply to other filesystems. Thanks. –  quodlibetor Jul 18 '13 at 18:10
add comment

Like Madhatter said, inodes take up some space, and it isn't a trivial amount when talking about using an infinite number of them.

share|improve this answer
    
They're created dynamically, though, right? It seems like refusing to write to the disk because you are writing too much metadata while you still have 30% free space is counter-productive, even if the disk is 60% inodes, if it's still only 70% full (i.e. there is only 10% data) refusing to write the remaining 20% because I have too much metadata is strange. –  quodlibetor Jul 18 '13 at 17:56
    
No, the number is frozen at file system creation time, for most file systems, as jiliagre says. –  MadHatter Jul 20 '13 at 15:45
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.