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.

I have a filesystem that has lots of small files. Currently about 80% of inodes are used (I checked with df -i), however only 60% of disk space is used. How can I 'increase' the number of inodes? If it was just disk space, I know that I could just increase the size of the disk (this disk is on LVM). If I increase the size of the disk, will that make me have more inodes?

I'm willing to grow the filesystem this disk is on, if that'd help.

share|improve this question

5 Answers 5

up vote 10 down vote accepted

man mke2fs

You will see a -N for number of inodes

So you can spec it when you format a new partition. Not so helpful right now, huh?

tune2fs, which tunes the filesystem, doesn't seem to have a way to add more inodes.

But maybe ext3 or 4 does this, and someone else knows....?

So now you have an option: backup, reformat partition, restore.

share|improve this answer
1  
yeah, it's good, but not because it's reiserfs, but because it's support dynamic inode allocations (supported by every decently new filesystem) –  user29686 Feb 14 '10 at 16:25
1  
Reiser is excellent for tons of tiny little files. I'd go with that. –  Xorlev Feb 14 '10 at 16:29
    
I would however make sure you have backups when using Reiser. I (myself) and other have lost data due to reiserFS in the earlier years. I don't trust it anymore since. –  Anony-Mousse Sep 25 '12 at 11:41
    
ext3 seems to have no way for it –  kagali-san Oct 28 at 13:08

To answer the original question, even though it is probably late for the questioner - yes, increasing EXT2/3 on LVM2 will also increase the inodes limit.

Just had a partition of 1G size with 65k inodes limit. After

lvextend -L+1G /dev/vg/var
umount /var
resize2fs /dev/vg/var
mount /var

... my inodes limit is now 128k.

share|improve this answer
1  
Wow, I was almost desperate, but found your answer and decided to try, and it worked. This should definitely be the accepted answer! Works for LVM as well as for virtual machines :) –  vadipp Feb 24 '13 at 16:20

If you were knowing that small files will eat your disk space, you should have used a FS with dynamic inode allocation, like ReiserFS or any new modern FS (XFS, JFS) instead of EXT2/3/4 (which I assume you are using, you not said that).

A filesystem migration is probably a good choice in your situation.

share|improve this answer

As a stopgap, mount a new filesystem, and cp/rm/ln-s some of your fs hierarchy there. Now you have a few spare inodes! You can't mv files between the two fses, so beware breaking things that need to do that, but for many apps this can be transparent.

Then make a new fs, per Paul's advice, and migrate onto that.

share|improve this answer
1  
Of course you can mv files between the two filesystems - a mv is effectively semantic sugar for cp+rm. You can't hardlink between two filesystems. Did you mean something else? –  Daniel Lawson Jul 24 '11 at 20:53
    
@Daniel: I mean the rename() system call, and I think it is sloppy practice to use mv as sugar for cp/rm, because of the issue with the semantics around symlinks. I should edit this answer - there's a few places it isn't beautifully clear. –  Charles Stewart Jul 25 '11 at 0:30

Ext4 suffers the same problem, if you create a small partition and have a ton of small files you will run out of inodes, and if you have flex_bg in features you can't use tune2fs to increase inodes.

Personally I would go with ext4 over any version of ricerfs, just do the following when formatting:

mkfs.ext4 -I 512 /dev/foo tune2fs -i0 -c0 -o journal_data_writeback /dev/foo

Formatting this way will give you 33160 inodes on a 512M boot partition.

I say this as someone who used reiserfs for years, the kernel support isn't as good as ext*, and the filesystem gets fragmented over time and gets slow.

share|improve this answer

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.