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.

link|improve this question

79% accept rate
feedback

5 Answers

up vote 7 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.

link|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
feedback

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.

link|improve this answer
feedback

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.

link|improve this answer
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
feedback

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.

link|improve this answer
feedback

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.

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

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