Is it possible to change Inode count on an ext4 filesystem?

14,084

Solution 1

From the mke2fs man page:

Be warned that it is not possible to expand the number of inodes on a filesystem after it is created, so be careful deciding the correct value for this parameter.

So the answer is no.

What you could do is shrink the existing ext4 volume (this requires unmounting the filesystem), use the free space to create a new ext4 volume with fewer inodes, copy the data, remove the old volume and extend the new volume to occupy all the space.

Solution 2

If you have enough space you can take tar image of the file system and back it up. Then create a new ext4 partition with a higher or lower the inode count as needed. Taking a tar image and formating your partition adds the benefit of defragmenting it as well.

I know ext4 is not supposed to need it but no matter how hard you try after so much use it will need it or at least provide a speed increase at some point. Ext4 only makes it harder to fragment your drive and would still benefit from this about every 1 - 3 years. The big problem here is that a tar image and re-format is the only way I have heard of to defragment an ext4 partition.

Share:
14,084

Related videos on Youtube

netanel
Author by

netanel

Updated on September 18, 2022

Comments

  • netanel
    netanel over 1 year

    Possible Duplicate:
    How can I increase the number of inodes in an ext4 filesystem?

    I have a homemade NAS with Debian Wheezy 64bit. It has three disks - 2x2TB and 1.5TB, pooled together using RAID1/5 and LVM. The result is a LVM Logical Volume, about 3.16TB in size, formatted as ext4 and mounted as /home. However I just found out that roughly 50GB of this capacity is used by Inodes (exact count being 212 459 520, with 256B in size or to put it in another way - one Inode per every 16k of the partition size).

    While 50GB in 3.16TB is about 1.5% of the total capacity, it's still a lot of space. Since this is a storage NAS, mostly used for multimedia, I don't ever expect the /home partition to have 212 million files in it.

    So, my question is this - is it possible to lower/change the number of Inodes without actually re-creating the whole partition? While it might be possible to do it, I'd still prefer to find a way to do so instead of moving 2TB of data around and waiting for RAID to re-sync again.

  • netanel
    netanel over 11 years
    Thank you very much, I have some free space to shuffle data around so I will follow your advice.
  • psusi
    psusi over 11 years
    If you feel like risking your data ( make a backup first! ), there is launchpad.net/e2defrag
  • Joe
    Joe over 11 years
    I knew there was something in the works and seems to be working well thanks for the tip.