Solaris inode size
When a file system is created under the Solaris OS, data structures that contain information about files are also created. Each file has an inode and is identified by an inode number (often referred to as an "i-number" or "inode") in the file system where it resides.
Inodes store information such as user and group ownership, access mode (read, write, execute permissions) and type of file. There is a fixed number of inodes, which indicates the maximum number of files each file system can hold. Typically when a file system is created about 1% of it is devoted to inodes.
Number of Inodes (Files)
The number of bytes per inode specifies the density of inodes in the file system. The number is divided into the total size of the file system to determine the number of inodes to create. Once the inodes are allocated, you cannot change the number without re-creating the file system.
The default number of bytes per inode is 2048 bytes (2 Kbytes) if the file system is less than 1 Gbyte. If the file system is larger than 1 Gbyte, the following formula is used:
File system size | bytes per inode |
---|---|
Less than or equal to 1 Gbyte | 2048 |
Less than 2 Gbytes | 4096 |
Less than 3 Gbytes | 6144 |
3 Gbytes up to 1 Tbyte | 8192 |
Greater than 1 Tbyte or created with -T option | 1048576 |
Displaying inode information
The following table lists a number of commands available in the Solaris OS to display inode information
Command | Comments |
---|---|
df -F ufs -o i <disk-path> | Display inode utilization |
df -g <mount-point> | Display inode utilization |
ls -i | Displays the inode number information |
newfs -Nv <disk-path> | Displays the details used for creating the file system. |
mkfs -m /dev/rdsk/c0t3d0s5 | Displays more details, inclusive of nbpi (number of bytes per inode) used for creating the file system. |
Gotchas
- If you have a file system with many symbolic links, they can lower the average file size.
- If your file system is going to have many small files, you can give this parameter a lower value. Note, however, that having too many inodes is much better than running out of inodes.
- If you have too few inodes, you could reach the maximum number of files on a disk slice that is practically empty.
Examples
Using df -o -i
# df -F ufs -o i /opt Filesystem iused ifree %iused Mounted on /dev/dsk/c0t3d0s5 2506 145590 2% /opt
When using df -o i
, we would add the values from the iused
and ifree
columns to get the total number of inodes for the given filesystem (2506 + 145590 = 148096).
Using df & mkfs
# df -k /opt Filesystem kbytes used avail capacity Mounted on /dev/dsk/c0t3d0s5 288855 73739 186231 29% /opt # mkfs -m /dev/rdsk/c0t3d0s5 mkfs -F ufs -o nsect=80,ntrack=19,bsize=8192,fragsize=1024,cgsize=16,free=10,rps=90, nbpi=2066,opt=t,apc=0,gap=0,nrpos=8,maxcontig=16 /dev/rdsk/c0t3d0s5 615600
To find the number of inodes in the filesystem, divide the kbytes by nbpi: (288855 * 1024 / 2066 = 143169)
Using df -g
# df -g /tmp /tmp (swap): 4096 block size 4096 frag size 5522968 total blocks 5522896 free blocks 5522896 available 203559 total files 203348 free files 78643202 filesys id /tmp tmpfs fstype 0x00000004 flag 255 filename length
In the above example, we can simply look at the free files
field.