I am quite confused about the i-nodes. They say delete files to reduce the i-nodes but I have deleted 100s of log files from different cpanels on my server but inode count is still the same.

  • Where are you getting the 'inode count' from? Is that info definitely up-to-date? – sendmoreinfo May 6 '13 at 8:49
  • have you checked df -i – Rahul Patil May 6 '13 at 8:53
  • yaa I am trying df -i – Fahad May 6 '13 at 8:56
  • 4
    Maybe these files were hardlinked? What is the output of ls -l for the kind of files you delete? "-rw-r--r-- 1 hl hauke 0 Dec 31 2011" Is the second field a 1 or a higher number? Is your inode usage at 100%? – Hauke Laging May 6 '13 at 9:12
  • 1
    fwiw you can locate all hard links to a particular inode via the -inode option in for the find utility. You can get a file's inode via ls -li and then feed this to find so you know what files you have to delete to get that i-node free. The filesystem will only free the inode once there are no more hard links to it and all programs with an open file handle to it have exited or closed the file handle. – Bratchley May 6 '13 at 12:24

You can determine the breakdown of your inodes on a given file system using the tune2fs command.

You typically call tune2fs with the -l switch and the device you'd like to query, typically /dev/sda1 or /dev/sdb1. For my example I have a RAID device, /dev/md0.


$ tune2fs -l /dev/md0 | grep -i inode

Filesystem features:      has_journal ext_attr resize_inode dir_index filetype needs_recovery extent 64bit flex_bg sparse_super large_file huge_file uninit_bg dir_nlink extra_isize
Inode count:              22872064
Free inodes:              6270088
Inodes per group:         128
Inode blocks per group:   8
First inode:              11
Inode size:               256
Journal inode:            8
Journal backup:           inode blocks

The above command shows the total number of inodes along with the number available.

You can use the blkid command to get a list of your devices if you're not sure what you have.

$ blkid 
/dev/mapper/VolGroup00-LogVol01: TYPE="swap" 
/dev/mapper/VolGroup00-LogVol02: UUID="3130f689-814a-436d-8c0a-feb271c06245" SEC_TYPE="ext2" TYPE="ext3" 
/dev/mapper/VolGroup00-LogVol00: UUID="7a2a5b5b-8c20-4925-a359-c6574d9bc1fd" TYPE="ext3" 
/dev/sda1: LABEL="/boot" UUID="ed298397-2e7e-4e18-80c3-4ecd00e4cab9" TYPE="ext3" 
/dev/VolGroup00/LogVol00: UUID="7a2a5b5b-8c20-4925-a359-c6574d9bc1fd" TYPE="ext3" 
/dev/VolGroup00/LogVol01: TYPE="swap" 
/dev/sr0: LABEL="CentOS_5.6_Final" TYPE="iso9660" 
  • While this is good information for learning more about how the filesystem has allocated inodes, the submitter is already using "df -i", which is arguably a better way to find the free inode usage for his filesystem than parsing it out of tune2fs. – Johnny May 6 '13 at 21:19
  • Here's a real reason why you should arguably know how to use both df and tune2fs. We recently purchased a Thecus NAS and the version of df included is the one provided by Busybox. This version of df doesn't include the switch -i. The utility tune2fs was however included on this NAS. You can also use the stat -f . command if you cd to the top of a mounted directory too. – slm May 8 '13 at 3:40
  • I didn't say it wasn't useful information, but I think you're answering a question that wasn't asked -- the the original submitter already said he used "df -i" to see the free inodes, so he probably doesn't need to see the same information formatted differently by tune2fs. – Johnny May 8 '13 at 5:53

In general, you're right - if you delete all references to the files (which could be > 0 if the files are hardlinked), the inodes should be freeed up when you delete the files.

However, if some process has the file open (like whatever process is writing to the log files), the inodes won't be freed up until that process(es) closes the files. Just as disk space used by the files isn't freed up until the files are closed.

Before deleting the files, you could have used the lsof command on the files to see if some process had the files open. Now that you've deleted the files, you could still use lsof to look at all open files on the system and search for the files that you've deleted.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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