3

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

An old headless no-X backup server I use has a small hard drive with three primary ext4 partitions: /, /home and /swap. The system is unable to run updates, as there are insufficient inodes available on the 1.5GB / partition. There is unused space available on /home.

Would resizing the / partition from a live GParted environment solve this? Would more inodes be created by this process?

This answer indicates that it is not possible to create more inodes after a filesystem has been created. I assume that this does not involve resizing the partition. This answer suggests recreating the filesystem to obtain more inodes.

SabreWolfy
  • 1,154

1 Answers1

3

While you can resize an ext partition (with eg. gparted), it would seem that you cannot adjust the number of inodes, which by implication means that the bytes-per-inode increases or decreases with resizing. Beware the fact that "bytes-per-inode" and "inode size" are not the same thing.

So: you can resize your /home partition down (decreasing the bytes-per-inode), but with regard to the root partition, you will have to reformat it if you want to increase the number of inodes.

Another option would be to resize the root partition down, create a new partition with a smaller bytes-per-inode (see the -i option in man mke2fs), and mount /usr/share (or something with a lot of small files) there.

tune2fs -l will give you the "Inode count:" and other information regarding a ext filesystem.

rsync -aE will be useful if you have to mirror/backup and resize a partition.

goldilocks
  • 87,661
  • 30
  • 204
  • 262
  • Thanks. Please explain what you mean by "mirror the partitions". Do you mean backup/copy them elsewhere, reformat, then restore? – SabreWolfy Jan 30 '13 at 08:16
  • 2
    Just copy the contents into a subdirectory of another filesystem. So you need a) another drive of sufficient size, and b) a means of copying them. rsync -aE will do this, and it can even be done over a network. But try gparted first, I'm sure if you shrink home it will lose inodes and when you grow / it will get them. You can check before and after with fsck. – goldilocks Jan 30 '13 at 08:20
  • 1
    The documentation of mke2fs explicitly states “it is not possible to expand the number of inodes on a filesystem after it is created”. tune2fs can't do it. resize2fs can't do it. So what makes you think against all odds that it is in fact possible? – Gilles 'SO- stop being evil' Jan 30 '13 at 23:02
  • 1
    @Gilles: Because other documentation states that the inode size cannot change either, and I took "inode size" as synonymous with "bytes-per-inode", which it turns out not to be, lol...but if it were, then when you resize a partition, one of those (inode size or number of inodes) must change. I tried this just now with gparted and indeed, the number of inodes does not change. So I substantially re-wrote the post to reflect this -- all apologies ;) I think my advice WRT backup and reformat was/is sound, – goldilocks Jan 31 '13 at 02:06
  • Bytes per inode isn't a filesystem feature, it's just the ratio of the number of bytes divided by the number of inodes. The inode size rarely changes, it's only useful to enlarge this to store more extended attributes. The number of inodes is fixed at filesystem creation time with ext4. resize2fs changes the number of data blocks. A data block stores a fragment of a file; with more data blocks, you can store files whose total size is larger, but you still need one inode per file so at some point you may run into the inode limit. – Gilles 'SO- stop being evil' Jan 31 '13 at 12:43
  • So the long and short of it is that if my 1.5GB ext4 partition (which has 69% inodes used) uses up all it's remaining inodes when running a system update, resizing the partition to 6 million petabytes won't create more inodes, so won't solve the problem. The only solution possible within all the realms of this universe and beyond, is to recreate the file system with mkfs on a larger partition. Does resizing the file system = resizing the partition? – SabreWolfy Feb 01 '13 at 14:39
  • 2
    goldilocks was right the first time. man mkfs.ext4, search for -i option (bytes-per-inode). "Note that resizing a filesystem changes the numer of inodes to maintain this ratio." Verified experimentally, resizing from 1G to 10G and looking at tune2fs /dev/X | grep Inode. (It's easy to experiment like this if you installed your system using LVM partitions & left yourself free space to play with :). – sourcejedi Jan 07 '16 at 13:52