Solved UFS2: inodes

Hi,

I don't understand exactly in newfs(8) :
-i bytes

Specify the density of inodes in the file system. The default is to create an inode for every (4 * frag-size) bytes of data space. If fewer inodes are desired, a larger number should be used; to create more inodes a smaller number should be given. One inode is required for each distinct file, so this value effectively specifies the average file size on the file system.

Here, he speaks about the size of an inode? Or the size of all inodes? Or other may be?
 
It means the upper limit for the number of inodes that can be used on a single UFS filesystem. The limit is a static one after the filesystem is created and can not be changed.
 
So, -i 80 means 80 inodes at maximum in the file system? It's very strange, the description doesn't explain this as your answer.
 
So, -i 80 means 80 inodes at maximum in the file system? It's very strange, the description doesn't explain this as your answer.

It means a density of inodes, the -i 80 option would create an inode for every 80 bytes of storage on the filesystem. In other words the filesystem created like that would be prepared for files that are on average 80 bytes in size. This is an unrealisticly low number though. The default is 4*fragsize where fragsize is 4096 bytes resulting in an inode for every 16KBs of storage space on the filesystem, that's the same if you used -i 16384 option.
 
Ok, I think this setting is strange seriously. I read inode contains informations about a file, so why ask a setting for a number of bytes and not for group of files (for example) ? Excepted if, the "file" what I read, is the fragment size of the file system ? Or it's really a file like a video ?
 
Ok, I think this setting is strange seriously. I read inode contains informations about a file, so why ask a setting for a number of bytes and not for group of files (for example) ? Excepted if, the "file" what I read, is the fragment size of the file system ? Or it's really a file like a video ?

UFS dates back to a time when the properties of the filesystem such as inode density had to be decided before creating the filesystem. That's why the setting is there so that in the unlikely case your collection of files is such that the defaults are not suitable you can change it. More modern filesystem have dynamic blocksizes and they can use better strategies for allocating blocks and reserving a suitable number of "inodes" (in quotes because the inode is an UFS concept, other filesystem might do something very different but the VFS level representation is still an inode).
 
Hum, I think we can find files without inodes, so it's a bad thinking. I assume so, - i xxxxxxxxxxx means inodes can use xxxxxxxxxx bytes, no more. When xxxxxxxxxx are used, I can't create files. I'm thinking good ?
 
You're misunderstanding what an inode is. It's the identity of a file, there's an inode for every single file on the filesystem. Running out of space is one problem you can have on a filesystem but you can also run out of inodes. The maximum number of inodes is the hard limit for the number of files on the filesystem, that's what the -i option sets effectively.
 
Ok so.
If fewer inodes are desired, a larger number should be used; to create more inodes a smaller number should be given.
With your answers, have you a great example with this setting ? At the moment, I still don't understand this setting.
in an inode for every 16KBs of storage space on the filesystem
Only one inode for 16KB of files. So one inode for a group of files which takes 16KB ? But you say there is an inode by file?
 
Ok so.

With your answers, have you a great example with this setting ? At the moment, I still don't understand this setting.

Only one inode for 16KB of files. So one inode for a group of files which takes 16KB ? But you say there is an inode by file ?

There's only one inode per file regardless of the size of the file. When the filesystem is created the -i option or the default of 16KBs is used for reserving certain amount of space for the inodes and the maximum number of inodes that can be used is set in stone at that time.
 
So, the size for -i option is a space, before every file (for example) reserved for an inode ? If it's right, I should understand better this :
If fewer inodes are desired, a larger number should be used; to create more inodes a smaller number should be given.
(Even if it would be a special idea to want reserved a space which may be bigger than the size by default for an inode.) -> it's only an idea that I thought
 
I checked and results :
- higher is the number for -i option, lower is the lost of free space in partition, lower is the number of inodes ;
- lower is the number for -i option, higher is the lost of free space in partition, higher is the number of inodes.

So questions :
- This option affects ONLY the number of inodes in a partition and there is an inode per file ? It's an obligation ? Or it may have many files without inodes ?
The default is to create an inode for every (4 * frag-size) bytes of data space.
This, it's only an indication to "make a good choice" or it's real and many files won't inodes ?
 
...and there is an inode per file ? It's an obligation ?
Yes.
So, the size for -i option is a space, before every file (for example) reserved for an inode ?
Yes, but the space is not before each single file, but is reserved in one large area of a partition, and the size of that area is what the -i option defines. This space is reserved before any files are allowed to be saved on a partition, and is part of what the newfs command does.

(size of partition in bytes) / (-i option) = maximum number of files that can be stored in this partition
 
newfs(8) accepts 4096 for min value = 1226624 inodes and 7406705 for max value = 128 inodes, it doesn't care about the size of the partition (excepted if the partition is really low like 50 bytes, but it's totally useless to create an UFS partition like this).

With your operation : 90GB / -i 4096 = 21972656,25

EDIT : Once FreeBSD launched, df(1) tell me : inodes (free + used) = 23666430

So, your operation is true (may be few things is missing for a perfect result, but it's coherent).

I think df(1) give us better number of inodes that I saw. When I create a folder, one inode is used (df(1) printed me). And, newfs(8) tell me the number of inodes (but I think it's false, excepted if I don't understand something with newfs(8)) only when the file system is created.

At the end, with the minimal value possible, I obtain 3062 inodes so 3062 files or folders. It's really nice for a minimal value ! (for a stockage of musics / videos)
 
Ok I can put solved even if I don't know if I really a bad comprehension of the description of the -i option or if it's the description which is the cause.
 
Back
Top