Today, discussing some File system related concepts - inodes, Device Files, Superblock, Journaling etc.
Lets get started..
===
What is an inode?
-inode = stores info about a file location on disk and its attributes.
-an inode points to either:
-another inode or
-a data block
-inode contains:
-file owner
-permission
-size of file
-creation time
-last access time
-group id
-Note: inode does not have file name - this is so as to permit an inode to point to multiple inodes.
-hardlink - 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)
-softlink - two files that refer by name instead of inode. ie their inode values are different. they can span fs.
[ To remember, hard same inode = hsi ]
What are Device Files?
-Device files are special files for organizing data in Linux (and Unix) OS.
-block device files:
-device driver files 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.
-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.
Note: from experiment, mv preserves inode number, cp creates new inode.
-sync = writes disk cache to be written to disk;
What is a Superblock?
-superblock
-the first piece of info read from disk.
-it hold info about:
-location of first inode
-amount of space
-disk attributes
-without a superblock, data on disk is useless. that is why multiple copies of superblock are maintained.
Why is Journaling of FS important?
-ext3 is enhanced ext2 with journaling.
-journaling helps keep track of bad blocks. so fsck does not have to be run after every crash.
-the journal keeps track of changes like a redo log. it writes only when commit happens.
-so data is cleanly written or not written at all--thus avoiding corruptions during crash--this increases integrity and avoids fsck to be run. this saves time.
No comments:
Post a Comment