Inode
Inode
TECHNOLOGY
•
What is Inode In UNIX
• UNIX is OS it uses Inode file system
• Each Inode has a number that is used in the index table. UNIX kernel
uses Inode number to access the contents of an Inode
• i.e data which is there in files and to store that data properly and
maintained in files --we use INODE
• I --index
• node---block
• Hard Disk may comprise a single file system or it may be partitioned to house several
file systems.
• Disk Space allotted to Unix file system is made up of blocks each of which are
typically of 512 bytes. Some file systems may have block of 1024 or 2048 bytes
• Block size depends upon how the file system has been implemented on a particular
installation.
• cmchk command is used to find out the block size on the file system. This command
reports the block size---- $ cmchk
• BSIZE =1024
• Inodes are used to keep track of broken up pieces of files
• Each file has inode associated with it that store which block
make up the file
• Access Permissions
• File size
Note: Inode does not include the file paths
Example Inode
Owner: hra
Group g1
Permissions -rwx-w-r-x
• Each Inode entry in the Inode table consists of 13 addresses each, which specify
where the contents of the file are stored on the disk
• First 10 addresses i.e. 0 through 9 points to first free blocks on the disk
• Example If file of size 3 KB may have its entries like this i.e. The address of 4970
signifies where the first 1 kilobyte of the file are stored. The next 1 KB chunk is at
5231 and next at 3401.These addresses may be scattered throughout the disk
Cont….
• These addresses may be scattered throughout the disk,
as files are stored in chunks wherever empty blocks of
disk are available especially with large files.
OWNER
GROUP
File Type
PERMISSIONS
ACCESS TIME
4970
MODIFICATION TIME
File Size
0 4970
5231
1 5231
2 3401
3 7654 3401
4 8765
5 9877
6 7666
7 4444
8 7665
9 8771
10 7717
11 8888
12 9999
Cont…
• Kernel’s file sybsystem regulates data flow between the
kernel and secondary storage devices.
• Each UNIX file system contains four major parts
A. boot block:
B. superblock:
C. i-node table:
D. data block: file storage
Cont…
• All the blocks belonging to the file system are logically divided into
four parts
• First Block of a File system is called “BOOT BLOCK” which is
followed by SUPER BLOCK,INODE BLOCK and DATA BLOCKS.
• An allocated block can belong to only one file in the file system
• This block cannot be used for storing any other file’s contents
unless the file to which it originally belonged is deleted
HOW DOES UNIX ACCESS FILES
• Internally a file is identified by UNIX by a unique Inode
Number associated with it.
• Inode number can be obtained by command
ls –li
$ ls –l file1
file1 12342
If several slots available in the Inode table slot no
12342 contains information about file1
LINKS—HARD Links and SOFT Link
Links
• Soft Links are similar to MS Windows shortcuts
• Hard links are just different names for the same file
ls –li test myshortcut ---It will display both the files but myshortcut->test(myshorcut is a soft link and
having two different file
myShorcut is softlink that points back to the test and soft link that is created have different inode
number and this number would be different from file test
Here myshortcut is a special file and test is a stand alone file and first letter in permissions caontain l
that means it’s a link whereas in test it’s a regular file
Test contains data and myshortcut just points to test file
Cat test
Cat myshortcut----gets same output
mv test test1
ls –li test myshortcut-----see the output
ls –li test1 myshortcut—see output
Cat myshortcut
Practical Session