Answers to: HOW TO USE ALL INODES IN MY SYSTEMhttp://linuxexchange.org/questions/3447/how-to-use-all-inodes-in-my-system<p>MY UBUNTU PC HAS THE FREE INODES I WANT TO USE ALL OF THEM WITH A AUTOMATIC SHELL SCRIPT. HERE ONE THING I DON'T WANT TO CREATE ANY FILE THAT MEANS WITHOUT CREATING ANY FILE I HAVE TO USE ALL FREE INODES IS THERE ANY COMMAND ? OR SCRIPT?</p>enThu, 05 Mar 2015 08:13:33 -0500Answer by LINUXKIDAhttp://linuxexchange.org/questions/3447/how-to-use-all-inodes-in-my-system/3498<p>Thanks Jesse for correcting me. I appreciate.</p> <p>Regards, LINUXKIDA</p>LINUXKIDAThu, 05 Mar 2015 08:13:33 -0500http://linuxexchange.org/questions/3447/how-to-use-all-inodes-in-my-system/3498Answer by Jesse Pollardhttp://linuxexchange.org/questions/3447/how-to-use-all-inodes-in-my-system/3492<p>You can't do it by creating hard links - that doesn't use an inode.</p> <p>A hard link is a file name that is associated with a pre-existing file the inode.</p> <p>Now what you want can be done - sort of.</p> <p>It will take a bit C code to do it right. The procedure is to do the following:</p> <ol> <li>create a file (easy enough, just do an open/create) and will allocate an inode.</li> <li>unlink the file (this removes it from the directory, and the file will be deleted when the program exits... This step isn't necessary IF you use the "open" with a flags value of O_TMPFILE. A directory path for the name is needed though ("/tmp" if that is the filesystem you are going to attack).</li> <li>repeat for 1021 times. Note: this allocates 1021 inodes (why 1021? because there is a default files open for stdin/stdout/stderr)</li> <li>don't exit... (either a very long sleep or suspend yourself- see the manpage on signal) One way to try this is fork, and exec the program again, then wait for child to exit.</li> </ol> <p>step 4 is also a fork bomb. It will keep creating new processes until it fails... and then it cleans up for itself (you could then wait for terminal input on stdin though...)</p> <p>Now this doesn't exhaust the inode list - you can check the actual limits with "ulimit -n". But what you can THEN do is run the program in the background... Up to the process limits ("ulimit -u"). In my case, the number of files is limited to 1024, and the number of processes is limited to 4096. That means the total number of files that can be created this way would be 4096*1024 or 4,194,304 inodes.</p> <p>This may not use up ALL the inodes (depends on previous usage). The total number of inodes that you could allocate this way can be checked using "df -i". This will list the number of inodes that you can use - so pick the filesystem with fewest number available that you can use. (this is likely to be /tmp).</p> <p>On my system /home is a 300GB disk with ext4 used for the filesystem. There are a total of 30,531,584 inodes, with 29,773,826 free - so I can't use up all the inodes this way even if I wanted to. /tmp on the other hand has only 1,021,909 inodes...</p> <p>WARNING - don't do this on a filesystem using xfs. You can't exhaust the inodes because xfs will just allocate another disk block for inodes.</p>Jesse PollardTue, 03 Mar 2015 18:36:25 -0500http://linuxexchange.org/questions/3447/how-to-use-all-inodes-in-my-system/3492Answer by LINUXKIDAhttp://linuxexchange.org/questions/3447/how-to-use-all-inodes-in-my-system/3460<p>Hi,</p> <p>Create Hard link, so in this way you will utilize all your inodes without breaching the limiting condition stated by your friend. When you create a hard link, it just created a new name in the table, along with the inode, without moving the file</p> <p>Disclaimer : All the suggestions given over here to resolve the issue or to help the person who has asked questioned. If system behaves abnormally or become dead or questioner lost any data I will not be responsible for it.</p> <p>Regards, LINUXKIDA</p>LINUXKIDAMon, 17 Nov 2014 08:54:26 -0500http://linuxexchange.org/questions/3447/how-to-use-all-inodes-in-my-system/3460Answer by LINUXKIDAhttp://linuxexchange.org/questions/3447/how-to-use-all-inodes-in-my-system/3459<p>Hi,</p> <p>Create Hard links, so in this way you will utilize all your inodes without breaching the limiting condition stated by your friend. When you create a hard link, it just created a new name in the table, along with the inode, without moving the file</p> <p>Disclaimer : All the suggestions given over here to resolve the issue or to help the person who has asked questioned. If system behaves abnormally or become dead or questioner lost any data I will not be responsible for it.</p> <p>Regards, LINUXKIDA</p>LINUXKIDAMon, 17 Nov 2014 08:54:02 -0500http://linuxexchange.org/questions/3447/how-to-use-all-inodes-in-my-system/3459Answer by stevendupuishttp://linuxexchange.org/questions/3447/how-to-use-all-inodes-in-my-system/3456<p>So you want to search directly from the inodes - the only way I can think of is 1) search the internet for software already written, if it exists, or 2) go thru the development docs about processing the file system and write your own code. The major scripting languages have system calls to do low-level hacking. There isn't anything that comes to mind from the linux utilities. There are thousands to research and its not me who wants to do this ...</p> <p>Have you found anything yet?</p> <p>Regards, Steve</p>stevendupuisSat, 15 Nov 2014 11:13:26 -0500http://linuxexchange.org/questions/3447/how-to-use-all-inodes-in-my-system/3456