how inode works

HI,

Just another dummies questions:
How i can determine what number of inode to use when creating filesystem?

Thanks

There are a LOT of rules of thumb about this.

If you are going to have one or two gigantic database files you want few inodes, like say, less than 500, because inodes require space on the disk and you want as much disk available as possible.

If it is general use, probably about 1 inode per every two blocks (of whatever physical size the blocks are). So if you have 1000 blocks (dumb example, extra small disk) then you would want maybe 500 inodes. In the worst case this will waste disk space on unused inodes. The other way, if you have too few inodes then you get the 'too many files' error. Then the disk cannot be written to, even though it has free space.

If you are storing only media files which are large, maybe 1 inode for every 500 or 1000 blocks.

Other people will give other estimates, so ask around.

Jim is absolutely correct, just to explain where all these "rules of thumb" come from:

For every file you need exactly one inode, which contains the information the filesystem has about the file. In this data structure, for instance, the information which "ls" displays is stored. It doesn't matter how big or small the file is, even if it contains nothing at all it still needs an i-node. Links, btw., are just inodes, which point to another inode. So links also need one inode.

That means: the number of inodes you need depends on the size of the disk and your estimation about how big the average file (in fs blocks) in it is going to be. Jim has already mentioned databases, because they have usually a few very big files. A multi-terabyte Oracle database might consist of, say, a hundred files, thats all. On the other side of the spectrum are log directories of tools which produce many very small logfiles. Most filesystems are somewhere in between these extremes.

Run a "find" command over the various filesystems on some machines and calculate the average file size and the number of the files to get some empirical data to build on your experience.

If in doubt between two variants, opt for the bigger number of inodes. The space wasted this way is not that much and certainly not as big as the space wasted if the filesystem runs out of inodes.

I hope this helps.

bakunin

Thank you very much for both of you. It's great answers.

ooo i've had some nighmares about inodes!!

you may want to leave your default inode (number of bytes per inode = nbpi) for now until you have a good idea what EXACTLY is going on this server. wrongly configured and you could waste space or run out of inodes rather quickly.

take a look at this link and it will show you some general calculations: Number of Inodes (Files) (System Administration Guide: Devices and File Systems) - Sun Microsystems

few more things. newfs (i assume you are looking at a ufs fs) will allow you to change your nbpi. growfs i believe will also change the number of inodes as the filesystem grows.

if you are curious, use `df -F ufs -o i` to see current free v. used inodes on a system.

output from my x86 box.

-bash-3.00# df -F ufs -o i
Filesystem             iused   ifree  %iused  Mounted on
/dev/dsk/c2d0s0        24035 2404573     1%   /
/dev/dsk/c2d0s6       151478 8345738     2%   /usr
/dev/dsk/c2d0s1        20052 2408556     1%   /var
/dev/dsk/c2d0s5        10358 7269642     0%   /opt
/dev/md/dsk/d0         74978 28503390     0%   /data
/dev/dsk/c2d0s7           67 8054525     0%   /export/home