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.
Number of i-nodes
- Brynet-Inc
- Member
- Posts: 2426
- Joined: Tue Oct 17, 2006 9:29 pm
- Libera.chat IRC: brynet
- Location: Canada
- Contact:
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:
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.
- ManOfSteel
- Member
- Posts: 60
- Joined: Tue Feb 01, 2005 12:00 am
I'm developping a custom version of an i-node file system. So anything related specifically to Linux or Unix/BSD is good!I'm going to assume you're using Ext2/3...
I've always programmed in asm and my knowledge of c is quite limited.Have you considered looking over the source and any associated documentation?
I already have some documentation about this type of file system, but I've not found what I'm looking for so far.
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:Some relevant 'mke2fs' information:
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)
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.
- ManOfSteel
- Member
- Posts: 60
- Joined: Tue Feb 01, 2005 12:00 am
@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":
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":
One more thing, do you know what's the (default) block size used by mke2fs?The default policy is to allocate one inode for each 2048 bytes of
space in the cylinder group
Last edited by ManOfSteel on Mon Nov 05, 2007 7:12 am, edited 1 time in total.
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.
Try it. Be bold.
Every good solution is obvious once you've found it.