Number of i-nodes

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
User avatar
ManOfSteel
Member
Member
Posts: 60
Joined: Tue Feb 01, 2005 12:00 am

Number of i-nodes

Post by ManOfSteel »

Hello,

I would like to know how a utility like mkfs decides how many i-nodes should be set by default for a specific disk? Is it calculated depending on the disk size? What would the formula be for that?

Thanks in advance.
User avatar
Brynet-Inc
Member
Member
Posts: 2426
Joined: Tue Oct 17, 2006 9:29 pm
Libera.chat IRC: brynet
Location: Canada
Contact:

Post by Brynet-Inc »

I'm going to assume you're using Ext2/3... ;)

Have you considered looking over the source and any associated documentation? :?

Some relevant 'mke2fs' information:

Code: Select all

-b block-size - Specify the size of blocks in bytes. Valid block size vales are 1024, 2048 and 4096 bytes per block. If omitted, mke2fs block-size is determined by the file system size and the expected usage of the filesystem (see the -T option).
.....
-i bytes-per-inode - Specify the bytes/inode ratio. mke2fs creates an inode for every bytes-per-inode bytes of space on the disk. The larger the bytes-per-inode ratio, the fewer inodes will be created. This value generally shouldn't be smaller than the blocksize of the filesystem, since then too many inodes will be made. Be warned that is not possible to expand the number of inodes on a filesystem after it is created, so be careful deciding the correct value for this parameter.
.....
-N number-of-inodes - Overrides the default calculation of the number of inodes that should be reserved for the filesystem (which is based on the number of blocks and the bytes-per-inode ratio). This allows the user to specify the number of desired inodes directly.
Image
Twitter: @canadianbryan. Award by smcerm, I stole it. Original was larger.
User avatar
ManOfSteel
Member
Member
Posts: 60
Joined: Tue Feb 01, 2005 12:00 am

Post by ManOfSteel »

I'm going to assume you're using Ext2/3...
I'm developping a custom version of an i-node file system. So anything related specifically to Linux or Unix/BSD is good!
Have you considered looking over the source and any associated documentation?
I've always programmed in asm and my knowledge of c is quite limited.
I already have some documentation about this type of file system, but I've not found what I'm looking for so far.
Some relevant 'mke2fs' information:
I've already seen something like this in FBSD's man. What I'm looking for is the default number of i-node, not the user-custom number (specified with -N). What I would like to know is how the following is calculated:
the default calculation of the number of inodes that should be reserved for the filesystem (which is based on the number of blocks and the bytes-per-inode ratio)
User avatar
JamesM
Member
Member
Posts: 2935
Joined: Tue Jul 10, 2007 5:27 am
Location: York, United Kingdom
Contact:

Post by JamesM »

I suggest you download the source and look at it. The info you want will be by the 'getopts' call, I'm pretty sure.
frank
Member
Member
Posts: 729
Joined: Sat Dec 30, 2006 2:31 pm
Location: East Coast, USA

Post by frank »

From what I have read in various places mke2fs seems to create 1 inode per 4096 bytes of filesystem space.
Each inode takes up 128 bytes in the filesystem. By default, mke2fs reserves an inode for each 4096 bytes
of the filesystem space
-i: Specify bytes/inode value: create one inode for each chunk of this many bytes. The default value of 4096 usually creates more than you'll ever need, but probably isn't worth changing.
User avatar
ManOfSteel
Member
Member
Posts: 60
Joined: Tue Feb 01, 2005 12:00 am

Post by ManOfSteel »

@JamesM:
As I said, my knowledge of c is limited. What is a 'getopts' call?
I searched for it at http://lxr.linux.no/source/ and it gave me more than 20 results.
It seems none is related to ExtFS.


@frank:
Ok, thanks. I've read a similar thing in "A Fast File System for UNIX":
The default policy is to allocate one inode for each 2048 bytes of
space in the cylinder group
One more thing, do you know what's the (default) block size used by mke2fs?
Last edited by ManOfSteel on Mon Nov 05, 2007 7:12 am, edited 1 time in total.
User avatar
Solar
Member
Member
Posts: 7615
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

Post by Solar »

getopts() is a canon name used for the function that parses ("gets") the command line options a program was started with. Usually, that function (or some subfunction thereof) is where default values are set, too, so it is a good guess that mke2fs has a getopts() function and that somewhere in there you will find what the inodes option defaults to.

Try it. Be bold.
Every good solution is obvious once you've found it.
Post Reply