Solaris : Let’s discuss about the relationship between inodes and a filesystem
Files are stored in blocks. The block sizes of a disk vary depending on kernel parameters and parameters set with the newfs command.
If a block is 8192 bytes (the default), and you have a file (A) which is 200 bytes and a file B which is 10000 bytes you end up with the following
Block 1: Block 2:
AAAAABBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB BBBBBBBBBBBBB
200 B/__________________ 7992 B ______________________/ ___ 2008B __/
The full 200 bytes can be stored in Block 1 since it will all fit. However to keep space from being wasted, you can still store 7992 bytes (8192 bytes – 200 bytes (file A)= 7992) of info in block 1. So when you write the File B, which is greater than 7992 bytes, it splits the file up. It will store the first 7992 bytes in the remainder of block 1 and then put the rest in the next available space (in this case ..block 2).
In block 2 there will now be 6172 bytes free. For the kernel to keep track of where the remainder of the file is, it uses inodes. It will have all the inodes associated with a file in a table kept at the beginning of the file system. These inodes tell the kernel that to find this file go to inode such and such to get the first part and then to inode such and such to get the second part and so on and so on.
Every time you write a file, the inode the file is stored at gets written to this table to reflect the changes. You can check to see what file a inode belongs to via the icheck command. This is basically how inodes are used to keep track of all the files on a disk and to keep track of all parts of a file.
File and Inode Association :
There are a couple of ways to do this:
If you have a ufsrestore tape of the filesystem involved, load it into the drive (if ufsrestore for the filesystem spanned more than one tape, use the first tape) and issue the command:
# ufsrestore -tvf /dev/rmt/0 | grep wxyz (where wxyz is the inode number)
Another command you could use is:
#ff /dev/dsk/c0t0d0s0 | grep wxyz (where c0t0d0s0 is the filesystem involved)
Lastly you could also use:
# ncheck -i wxyz /dev/dsk/c0t0d0s0 (where c0t0d0s0 is the filesystem involved)
The above commands are of particular use if you need to interactively restore a file removed during fsck.