In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Network Security >
Share
Shulou(Shulou.com)06/01 Report--
This paper mainly describes the detailed layout of the ext2 file system on the hard disk partition, which is popular on Linux. Ext2 file system plus log support for the next version is the ext3 file system, it and ext2 file system in the hard disk layout is the same, the only difference is that the ext3 file system on the hard disk with a special inode (can be understood as a special file), used to record file system logs, that is, the so-called journal. Since this article does not discuss log files, the content of this article applies to both ext2 and ext3. [@ more@]
Preface
The source of this article is the source code of the ext3 file system in the Linux kernel. In order to make it easier for readers to consult the source code, some of the key technical terms in this paper use the English words used in the kernel source code instead of the corresponding Chinese translation. Readers are also asked to comment on whether this method is appropriate or not.)
Go back to the top of the page
A rough description
For ext2 file systems, hard disk partitions are first divided into block. Each block on an ext2 file system is the same size, but for different ext2 file systems, the size of the block can be different. A typical block size is 1024 bytes or 4096 bytes. This size is determined when the ext2 file system is created, it can be specified by the system administrator, or the file system creation program can automatically choose a more reasonable value according to the size of the hard disk partition. These blocks are grouped together into several large block group. How many block are fixed in each block group.
Each block group corresponds to a group descriptor, and these group descriptor are grouped together at the beginning of the hard disk partition, following the super block. The so-called super block, we will talk about next. There are several important block pointers in this descriptor. The block pointer we are talking about here refers to the block number on the hard disk partition. For example, if the value of the pointer is 0, we say it points to block 0 on the hard disk partition; if the value of the pointer is 1023, we say it points to block 1023 on the hard disk partition. We notice that the block count on a hard disk partition starts at 0, and this count is global for that hard disk partition.
In the group descriptor of block group, there is a block pointer to each bit in the block bitmap,block bitmap of this block group that represents a block. If the bit is 0, there is data in the block, and if bit is 1, the block is idle. Note that the block bitmap itself is exactly the size of a block. Assuming that the block size is S bytes, only 8 block can be recorded in the block bitmap (because one byte equals 8 bits and one bit corresponds to one block). That is to say, a block group can only be as big as 8*S*S bytes at most.
In block group's group descriptor, there is another block pointer to inode bitmap. This bitmap is also exactly the size of a block, and each bit in it corresponds to an inode. An inode on the hard disk roughly corresponds to a file or directory on the file system. With regard to inode, we will talk about it further.
Another important block pointer in block group's descriptor is to the so-called inode table. This inode table is more than the size of a block. This inode table is formed by putting together all the inode gathered in this block group.
The most critical information recorded in an inode is where the user data in the inode is stored. As we mentioned earlier, an inode roughly corresponds to a file in the file system, so where to store the contents of the user file is a question that inode has to answer. An inode answers this question by providing a series of block pointers. These block pointers point to the block where the contents of the user file are stored.
2.1 Review
Now let's review. Hard disk partitions are first divided into several block. These block are grouped together and divided into several groups, namely block group. Every block group has a group descriptor. All of these descriptor are grouped together and placed at the beginning of the hard disk partition, followed by the super block. From group descriptor we can find the inode table and block bitmap of this block group through the block pointer, and so on. From the inode table, we can see the inode one by one. From an inode, we can find the block that stores the user's data through the block pointer in it. We would also like to mention that block pointers are not allowed to point everywhere. The block bitmap and inode bitmap and inode table of a block group are stored at the beginning of the block group in turn, and the block that stores the user's data is immediately following them. After one block group ends, another block group starts.
Go back to the top of the page
Detailed layout
3.1 Super Block
The so-called super block of the ext2 file system is the data from the beginning of the hard disk partition (the first byte is byte 0) starting from byte 1024. Since the minimum block size is 1024 bytes, the super block may be in block 1 (when the size of the block is exactly 1024 bytes), or it may be in block 0.
The details of the super block of the ext3 file system on the hard disk partition are as follows. Where _ U32 is the data type that represents the unsigned 32 bits of unsigned, and so on. This is the data type used in the Linux kernel. If you are developing a user space (user-space) program, you can replace it with unsigned long and so on, depending on the specific computer platform. The fragments section in the following list can be ignored, and the ext3 file system on Linux does not implement the fragments feature. In addition, it should be noted that the data of the ext3 file system on the hard disk partition is stored in Intel's Little-endian format. If you are developing ext3-related programs on a platform other than PC, you should pay special attention to this. If you are only doing development on PC, you don't need to pay special attention.
Struct ext3_super_block {/ * 00counts / _ _ u32 sroominodescounts; / * inodes counts * / _ _ u32 slots blockslists; / * blocks counts * / _ _ u32 scuttleblocks blockslists; / * reserved blocks counts * / _ u32 slots freeblocks blockscounts; / * idle blocks counts * / * 10 counts / _ _ u32 s_free_inodes_count / * idle inodes count * / _ u32 sidle firstbatch data block; / * first data block * / _ u32 sidle log blocksize blocksize; / * size of block * / _ s32 slots logically fragmented size; / * can be ignored * / / * 20percent / _ _ u32 s_blocks_per_group / * number of block per block group * / _ u32 sroomfragsfragments perpendicular group; / * ignore * / _ u32 inode per block group; / * number of sroomes per block group * / _ u32 sroommtime; / * Mount time * / / * 30 cycles / _ _ u32 s_wtime / * Write time * / _ _ u16 sroommntcounter; / * Mount count * / _ _ s16 sroommntcounter; / * Maximal mount count * / _ _ u16 slotmagic; / * Magic signature * / _ _ u16 s_errors; / * File system state * / _ _ U16 s_errors / * Behaviour when detecting errors * / _ u16 stempering revolution level; / * minor revision level * / / * 40 minutes / _ _ U32 sprinter lastcheck; / * time of lastcheck * / _ _ u32 slots checkinterval. / * max. Time between checks * / _ u32 swatches creatorships; / * ignore * / _ u32 swatches revolutionized levels; / * Revision level * / * 50 levels / _ u16 swatches defective resuid; / * Default uid for reserved blocks * / _ u16 sacks defensible resgid; / * Default gid for reserved blocks * / _ _ U32 s_first_ino / * First non-reserved inode * / _ _ u16 sroominoderoomsize; / * size of inode structure * / _ _ u16 sblockblockblockblockblockblockblockblockblockblockblockblockblockblockblockblockblockgrouproomcompat; / * block group # of this superblock * / _ _ u32 sfeaturepacking s_feature_ro_compat; / * compatible feature set * / / * 60requests / _ _ u32 sfeatureroomcompat./ * incompatible feature set * / _ _ U32 / * readonly-compatible feature set * / / * 68mm / _ U8 s_uuid [16]; / * 128-bit uuid for volume * / * 78levels / char s_volume_name [16]; / * volume name * / / * 88levels / char s_last_mounted [64]; / * directory where last mounted * / / * C8legs / _ _ U32 slotted _ U8 s_prealloc_blocks maps; / * ignore * / _ U8 s_prealloc_blocks / * you can ignore * / _ U8 swatches prelocutionary dirt blocks; / * you can ignore * / _ u16 swatches s_journal_uuid adding1; / * you can ignore * / / * D0 blocks / _ U8 s_journal_inum [16]; / * uuid of journal superblock * / * E0 blocks / _ _ U32 blocks / * inode number of the log file * / _ u32 slog journalism devs; / * device number of the log file * / _ u32 s_reserved; / * start of list of inodes to delete * / / * EC*/ _ U32 log [197]; / * can be ignored * /}
As we can see, the super block is as big as 1024 bytes. In super block, the first field we care about is the magic signature, which should have exactly the same value as 0xEF53 for ext2 and ext3 file systems. If not, then this hard disk partition is definitely not a normal ext2 or ext3 file system. From here, we can also estimate that the compatibility between ext2 and ext3 must be very strong, otherwise, the developers of the Linux kernel should choose another magic signature for the ext3 file system.
Another important field in super block is s_log_block_size. From this field, we can get the size of the real block. Let's write down the size of the real block as Bline B = 1.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.