INTRODUCTION
ext3 is a Journalizing file system for Linux. It was written by Dr Stephen C. Tweedie for 2.2 kernels. The filesystem was ported to 2.4 kernels by Peter Braam, Andreas Dilger and Andrew Morton , with much valuable assistance from Stephen Tweedie. . Now ext3 is merged into Linux kernel code from Kernel 2.4.15 onwards.
In Red Hat Linux 7.2, Red Hat provides its first officially supported journaling file system: ext3. The ext3 file system is a set of incremental enhancements to the robust ext2 file system that provide several advantages. ext3 does not require a file system check, even after an unclean system shutdown, except for certain rare hardware failure cases (e.g. hard drive failures). This is because the data is written to disk in such a way that the file system is always consistent. The time to recover an ext3 file system after an unclean system shutdown does not depend on the size of the file system or the number of files; rather, it depends on the size of the "journal" used to maintain consistency. The default journal size takes about a second to recover (depending on the speed of the hardware). Advanced users may choose to tune the file system and I/O system for performance.
PREPARING THE PARTITION
A partition is formatted using the third extended file system format for storing data- so we have to use the
mke2fs –j command:
mke2fs –j/dev/hdaXX.
If we wish to make our floppy usable from DOS, we will have to format it in a way which DOS can understand (DOS uses File Allocation Table for maintaining file system information)- we can use the mkdosfs –j command:
mkdosfs –j/dev/hdaXX.
Depending on whether the file system is created on a floppy or a hard disk partition, there will be some minor variations in the data structure created on the disk.
EXT3 FILE SYSTEM ORGANISATION
Contains the following structures:
1. Boot record
2. Super block
3. Group descriptor block
4. Block bitmap
5. Inode bitmap
6. Inode table
7. Data blocks
BOOT RECORD
ext3 file system reserves the first block for the boot record.
Boot block contains the boot loader program.
SUPERBLOCK
The superblock is the structure on an ext3 disk containing the very basic information about the file system properties. Superblock contains the following fields:
s_inodes_count
32bit value indicating the total number of inodes, both used and free, in the file system.
s_blocks_count
32bit value indicating the total number of blocks, both used and free, in the file system.
s_r_blocks_count
32bit value indicating the total number of blocks reserved for the usage of the super user.
s_free_blocks_count
32bit value indicating the total number of free blocks, including the number of reserved .This is a sum of all free blocks of all the block groups.
s_free_inodes_count
32bit value indicating the total number of free inodes. This is a sum of all free inodes of all the block groups.
s_first_data_block
32bit value identifying the first data block, in other word the id of the block containing the superblock structure.
s_log_block_size
The block size is computed using this 32bit value as the number of bits to shift left the value 1024. This value may only be positive.
block size = 1024 <<>
s_log_frag_size
The fragment size is computed using this 32bit value as the number of bits to shift left the value 1024. Note that a negative value would shift the bit right rather than left.
if( positive )
fragmnet size = 1024 <<>
else
framgnet size = 1024 >>s_log_frag_size;
s_blocks_per_group
32bit value indicating the total number of blocks per group. This value in combination with s_first_data_block can be used to determine the block groups boundaries.
s_frags_per_group
32bit value indicating the total number of fragments per group. It is also used to determine the size of the
block bitmap of each block group.
s_inodes_per_group
32bit value indicating the total number of inodes per group. This is also used to determine the size of the
inode bitmap of each block group.
s_mtime
Unix time, as defined by POSIX, of the last time the file system was mounted.
s_wtime
Unix time, as defined by POSIX, of the last write access to the file system.
s_mnt_count
32bit value indicating how many time the file system was mounted since the last time it was fully verified.
s_max_mnt_count
32bit value indicating the maximum number of times that the file system may be mounted before a full check is performed.
s_magic
16bit value identifying the file system as Ext2. The value is currently fixed to 0xEF53.
s_state
16bit value indicating the file system state.
s_errors
16bit value indicating what the file system driver should do when an error is detected.
s_minor_rev_level
16bit value identifying the minor revision level within its revision level.
s_lastcheck
Unix time, as defined by POSIX, of the last file system check.
s_checkinterval
Maximum Unix time interval, as defined by POSIX, allowed between file system checks.
s_creator_os
32bit identifier of the os that created the file system.
s_rev_level
32bit revision level value.
s_def_resuid
16bit value used as the default user id for reserved blocks.
s_def_resgid
16bit value used as the default group id for reserved blocks.
s_first_ino
32bit value used as index to the first inode useable for standard files.
s_inode_size
16bit value indicating the size of the inode structure.
s_block_group_nr
16bit value used to indicate the block group number hosting this superblock structure. This can be used to rebuild the file system from any superblock backup.
s_feature_compat
32bit bitmask of compatible features. The file system implementation is free to support them or not
without risk of damaging the meta-data.
s_feature_incompat
32bit bitmask of incompatible features. The file system implementation should refuse to mount the file system if any of the indicated feature is unsupported.
s_feature_ro_compat
32bit bitmask of “read-only” features. The file system implementation should mount as read-only if any of the indicated feature is unsupported.
s_uuid
128bit value used as the volume id. This should, as much as possible, be unique for each file system formatted.
s_volume_name
16 bytes volume name, mostly unusued. A valid volume name would consist of only ISO-Latin-1 characters and be 0 terminated.
s_last_mounted
64 bytes directory path where the file system was last mounted.
s_algo_bitmap
32bit value used by compression algorithms to determine the methods used.
GROUP DESCRIPTOR
The group descriptors is an array of the group_desc structure, each describing a “block group”, giving the location of its inode table, blocks and inodes bitmaps, and some other useful informations. The group descriptors are located on the first block following the block containing the superblock Structure.
For each group in the file system, a group_desc is created. Each represent a single “block group” within the file system and the information within any one of them is pertinent only to the group it is describing. Every “Group Descriptor Table” contains all the information about all the groups.
bg_block_bitmap
32bit block id of the first block of the “block bitmap” for the group represented.
bg_inode_bitmap
32bit block id of the first block of the “inode bitmap” for the group represented.
bg_inode_table
32bit block id of the first block of the “inode table” for the group represented.
bg_free_blocks_count
16bit value indicating the total number of free blocks for the represented group.
bg_free_inodes_count
16bit value indicating the total number of free inodes for the represented group.
bg_used_dirs_count
16bit value indicating the number of inodes allocated to directories for the represented group.
bg_pad
16bit value used for padding the structure on a 32bit boundary.
bg_reserved
3 successive 32bit values reserved for future implementations.
BLOCK BITMAP
The “Block Bitmap” is normally located at the first block, or second block if a superblock backup is present, of the block group. Its official location can be determined by reading the “bg_block_bitmap” in its associated group descriptor. Each bit represent the current state of a block within that group, where 1 means “used” and 0 “free/available”. The first block of this block group is represented by bit 0 of byte 0, the second by bit 1 of byte 0. The 8th block is represented by bit 7 (most significant bit) of byte 0 while the 9th block is represented by bit 0 (least significant bit) of byte 1.
INODE BITMAP
The “Inode Bitmap” works in a similar way as the “Block Bitmap”, difference being in each bit representing an inode in the “Inode Table” rather than a block. There is one inode bitmap per group and its location may be determined by reading the “bg_inode_bitmap” in its associated group descriptor. When the inode table is created, all the reserved inodes are marked as used. For the “Good Old Revision” this means the first 11 bits of the inode bitmap.
INODE TABLE
The “Inode Table” is used to keep track of every file; their location, size, type and access rights are all stored in inodes. The filename is not stored in there though, within the inode tables all files are referenced by their inode number. There is one inode table per group and it can be located by reading the “bg_inode_table” in its associated group descriptor. There are s_inodes_per_group inodes per table. Each inode contain the information about a single physical file on the system. A file can be a directory, a socket, a buffer, character or block device, symbolic link or a regular file. So an inode can be seen as a block of information related to an entity, describing its location on disk, its size and its owner. Inode contains the following fields:
i_mode
16bit value used to indicate the format of the described file and the access rights.
i_uid
16bit user id associated with the file.
i_size
32bit value indicating the size of the file in bytes.
i_atime
32bit value representing the number of seconds since
i_ctime
32bit value representing the number of seconds since
i_mtime
32bit value representing the number of seconds since
i_dtime
32bit value representing the number of seconds since
i_gid
16bit value of the group having access to this file.
i_links_count
16bit value indicating how many times this particular inode is linked.
i_blocks
32bit value indicating the amount of blocks reserved for the associated file data. This includes both currently in used and currently reserved blocks in case the file grows in size.
i_flags
32bit value indicating how the ext2 implementation should behave when accessing the data for this inode.
i_osd1
32bit OS dependant value.
· Hurd
32bit value labeled as “translator”.
· Linux
32bit value currently reserved.
· Masix
32bit value currently reserved.
i_block
Array used to locate the blocks the particular file is stored on. Each entry is a 32bit block number. The first 12 entries in this array are block numbers, which can be used to fetch the first 12 blocks associated with the file. The 13th entry is an indirect block number. Which means that at the specified data block, you will find an array of direct block numbers. The 14th entry is an bi-indirect block number. Which means that at the specified data block, you will find an array of indirect block number, which in turn contains an array of block numbers that can be accessed directly. The 15th entry is an tri-indirect block number. It is a block number which contains an array of bi-indirect block number, etc. Each indirect/bi-indirect/tri-indirect block array contains as many entries of 32bit block numbers as possible (to fill one entire block).
i_generation
32bit value used to indicate the file version (used by NFS).
i_file_acl
32bit value indicating the block number containing the extended attributes. In previous revisions this value was always 0.
i_dir_acl
32bit value used to indicate the “high size” of the file. In previous revisions this value was always 0.
i_faddr
32bit value indicating the location of the last file fragment.
i_osd2
96bit OS dependant structure.
Hurd
· h_i_frag
8bit fragment number.
· h_i_fsize
8bit fragment size.
· h_i_mode_high
· h_i_uid_high
High 16bit of user id.
· h_i_gid_high
High 16bit of group id.
· h_i_author
No comments:
Post a Comment