What is an inode?
An inode is a system generated unique number assigned to a file. It stores info about a file location on disk and its attributes. So every file in the system has an inode. Usually, every filesystem has a upper-limit to the number of inodes it can generate. This means, there is an upper-limit to how many distinct files can be created on that file system. Therefore it is advisable to set it to a reasonably high number to avoid running out of inodes on your filesystem (and thereby be prevented from creating new files). Also, regular deletion of old and redundant files to keep the inode usage under check (eg: regular deletion of old log files is a good starting point). More about 'inodes' here.
The simplest way to get the inode number for a file is via the command 'ls -i'
Note: from experiment, mv preserves inode number, cp creates new inode
What is a Link?
A Link is another name for a file. Its simply another address pointer for a file on disk. There are two types of links possible - hard links or soft links. Links are created using the command 'ln' .
-hard link - two files with same inode; their names may be different but they point to same disk location. cant span fs (as different fs have separate inodes). Hard links are created by default using 'ln' command.
eg: # ln fileA fileB -- creates fileB as a hard link to fileA
-soft link - two files that refer by name instead of inode. ie their inode values are different. they can span fs. Also called as symbolic link or symlink. Soft links are created by using 'ln -s' command. They show 'l' as the first character in ls -l output.
eg: # ln -s fileA fileB -- creates fileB as a soft link to file A
[Mnemonic: hard same inode = hsi ]
What are device driver files?
-Device driver files are special files that allow to interface with devices in blocks of data.
-Their first char is 'b' in ls -l (eg ls -l /dev/sda1)
- block device files have two numbers - major and minor.
-major block device file number - points to the driver
-minor block device file number - points to the interface.
-eg: if /dev/sda1 and /dev/sda2 have different interface ports but share the same driver, then they will have same major number but diff minor number.
Other device driver files:
-character device files:
. device driver files to interface with devices as one char of data at a time. Their first char is 'c' in ls -l (eg ls -l /dev/tty1)
. they too have a major and minor number like block files.
Note: from man pages, mknod cmd is used to create block or char device driver files.
No comments:
Post a Comment