How do I increase the number of inodes on my disk?

Linode Staff

My disk has plenty of space, and I am got an error that tells me I have no space left on the device. I learned that I have run out of 'inodes' or Index Nodes. How do I get more?

2 Replies

What is an inode?

An inode or index node is like an index card to a file or directory on your disk. All ext3/ext4 disks (like those used by your Linode) have a fixed number of inodes that were created at the time your disk was created. The number of inodes cannot be increased without reformatting your disk.

How can I see how much of my inodes are in use?

You can use the command df -ih which will show your inode usage.

In this example, you can see that your root (/) filesystem on /dev/sda has 4.9 Million inodes and is using 100% of them:

Filesystem  Inodes  IUsed  IFree  IUse%  Mounted         on
udev        489K    374    489K   1%     /dev
tmpfs       494K    989    493K   1%     /run
/dev/sda    4.9M    4.9M   0      100%   /
tmpfs       494K    1      494K   1%     /dev/shm
tmpfs       494K    8      494K   1%     /run/lock
tmpfs       494K    16     494K   1%     /sys/fs/cgroup

What are my options?

You can move your data to a new disk that was created with more inodes.

The basic steps to do this involve:

  1. If necessary, resizing your existing disk down or temporarily increasing the size of your Linode Plan to accommodate another disk on which we will create a filesystem with the number of needed inodes.
  2. Create a new disk of type ext4 for the Linode in the space we created in the previous step.
  3. Boot into Rescue Mode
  4. Use the following command replacing NUMBER_OF_INODES and DEVICE_OF_NEW_DISK as appropriate. The maximum number of inodes allowed is 4294967295 (2^32)-1
mkfs -t ext4 -N NUMBER_OF_INODES /dev/DEVICE_OF_NEW_DISK
  1. Mount both your old disk and your new disk.
  2. Use cp -xa /media/DEVICE_OF_OLD_DISK/* /media/DEVICE_OF_NEW_DISK
  3. Boot your Linode using the new disk to ensure that it is working properly
  4. Remove your old disk.
  5. Resize your new disk as desired to give it additional space.

You can remove files to free up inodes on your existing disk.

The following command will help you locate directories with lots of files:

find / -xdev -printf '%h\n' | sort | uniq -c | sort -k 1 -n

How can I keep from running out of inodes?

You may be interested in looking into a tool called tmpwatch which recursively removes files that have not been used or accessed in a certain amount of time.

More information can be found here: https://linux.die.net/man/8/tmpwatch

Could you please elaborate on how to "mount both your old disk and your new disk"?

Should this be done from Glish in rescue mode? I've found a similar instruction but don't understand how the values of mount /dev/disk/by-id/scsi-0Linode_Volume_CommunitySiteVolume /mnt/CommunitySiteVolume should be populated.

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct