Introduction of Linux File system

Source: Internet
Author: User
Tags uuid inode usage

Write in front: when the partition needs to be formatted, the operating system can use the partition. will be formatted according to the file attributes/permissions set by the operating system as supported by the operating system.

The cousin Linux book says that the file system is a data that can be mounted

The operation of the file system is related to the operating system's file data. such as the Linux file data has attributes, permissions, actual data, so the file system put the file attributes and permissions in the Inode, the actual data or data in the directory is placed in the block, Super Block super blocks is to record the entire file system information, such as: Inode, Block usage Amount Remaining amount, group number.

    1. EXT2 Disk data structure:

1. Boot sector: Each file system has a boot sector at the front to install the bootstrapper. This allows the different boot programs to be installed in different file systems. Instead of overwriting the disk's unique MBR, this allows for a multi-boot environment.

2, block group: The format will be partitioned into multiple block groups, each block group has a separate super block, Inode, block and other blocks.

1.superblock: is a place to record information about the entire file system, mainly

      1. Block vs. Inode Total

      2. Unused block and inode number used

      3. Inode and block size, Inode is 128bytes,block is 1024, 2048, 4096bytes

      4. File system mount time, last write data time, check disk Time

      5. A validbit value, mounted as 0, not mounted as 1

      6. Each block group may have a super block, and block 0 must have a superblock, which the user replicates to the other block groups and is repaired for use. The same other block groups have Superblock, can also rescue block group 0.

2. Group description: The main record of each blockgroup start and end block number, as well as superblock, data Block bitmap, index block bitmap, inode table, block number block blocks.

3. Block Bitmap: Bitmap is a sequence of bits, using a binary record block, 0 indicates that the corresponding block is idle, and 1 indicates that the corresponding block is occupied. When you create a file, you will find empty block blocks to record the contents of the file, delete the file, in fact, the block bitmap and Inode bitmap related location to empty, equivalent to not be occupied, note: The data is still, the next time you create a file, overwrite the original empty block bitmap and inode bitmap file data.

4. Index node bitmap: Bitmap is a sequence of bits, using binary record inode usage, 0 indicates that the corresponding block is idle, 1 indicates that the corresponding block is occupied.

5. Index node table: The attribute permission of the record file and the block in which the actual data of the file is placed, the Inode table record is at least as follows

      1. Access mode for this file (Read/write/excute)

      2. The owner and group of the file

      3. The size of the file

      4. The time the file was created, the last time it was read, the last time it was modified

      5. The file really points to

      6. Each inode has 128bytes

      7. Each file occupies only one inode

      8. When the system reads the file, it needs to find the inode and analyze whether the permissions recorded by the inode are in accordance with the user, and if it matches the actual block content starting to read

    The Inode table needs to record a lot of things, and each inode size is 128bytes. If each block is 4096bytes, only 32 inode is recorded per block. If a file is 500M, it takes 4bytes to record the block. About 130,000 of the block number needs to be recorded, the system defines the area of the Inode record block number 12 direct, an indirect, 1 double introduction, a three indirect record area.

    6. Data BLOCK: The contents of the actual data/directory used to place the file. The supported sizes are 1K, 2K, 4K

      1. Block size and quantity cannot be changed after formatting (unless reformatted)

      2. Only 1 file data can be stored in each block

      3. When the file data is larger than the block size, it consumes more than one block

      4. Disk space can be wasted when the file data is in the size of a rain block

    Use the DUMPE2FS command to view file system Information, Dumpe2fs-dump EXT2/EXT3/EXT4 filesystem information

    Syntax: DUMPE2FS [-BFHIXV] [-O superblock=superblock] [-O blocksize=blocksize] Device

    Options:

    -B: Print bad blocks in the file system

    -F: Force display of all information

    -H: Show only Super block information

    Instance:

    [Email protected] ~]# df-h

    Filesystem Size used Avail use% mounted on

    /dev/sda5 8.0G 2.1G 5.5G 28%/

    Tmpfs 937M 0 937M 0%/dev/shm

    /DEV/SDA1 194M 27M 158M 15%/boot

    /dev/sda2 9.7G 1.5G 7.7G 16%/usr

    /DEV/SDC4 99M 23M 72M 24%/Home

    [Email protected] ~]# dumpe2fs/dev/sda1

    DUMPE2FS 1.41.12 (17-may-2010)

    Filesystem volume Name: <none> Lists the name of the file system <label>,/etc/fstab the device name can use this. I'm here none. There is no defined name, and you can use E2label to set the label.

    Last mounted on:/boot mount point

    Filesystem uuid:2f2da85e-f8c6-450b-bd82-99217ddc1ca4 Device Uuid,/etc/fstab can also use this Mount

    Filesystem Magic number:0xef53

    Filesystem Revision #: 1 (dynamic)

    Filesystem features:has_journal ext_attr resize_inode dir_index filetype needs_recovery extent FLEX_BG Sparse_super Huge_file UNINIT_BG Dir_nlink extra_isize

    Filesystem Flags:signed_directory_hash

    Default mount options:user_xattr ACL defaults mount parameters

    Filesystem State:clean This file system is no problem.

    Errors behavior:continue

    Filesystem OS Type:linux

    Inode count:51200 inode Total

    Block count:204800 Block Total

    Reserved block count:10240 reserved blocks Total

    Free blocks:171502 idle block Total

    Free inodes:51162 idle inodes total

    First Block:1

    Block size:1024

    Fragment size:1024

    Reserved GDT blocks:256

    Blocks per group:8192

    Fragments per group:8192

    Inodes per group:2048

    Inode blocks per group:256

    Flex Block Group Size:16

    Filesystem Created:thu Nov 9 23:11:17 2017

    Last Mount Time:sat Mar 3 05:57:03 2018

    Last Write Time:sat Mar 3 05:57:03 2018

    Mount count:26

    Maximum Mount Count: 1

    Last Checked:thu Nov 9 23:11:17 2017

    Check interval:0 (<none>)

    Lifetime writes:32 MB

    Reserved blocks uid:0 (user root)

    Reserved blocks gid:0 (group root)

    First Inode:11

    Inode size:128 the size of each inode

    Journal inode:8 log inode number

    Default Directory HASH:HALF_MD4

    Directory Hash seed:0ccc6f7e-bdae-45d8-9a92-6b72b940045c

    Journal Backup:inode Blocks

    Journal Features:journal_incompat_revoke

    Log size: 4096k

    Journal length:4096

    Journal sequence:0x0000005c

    Journal start:1



    Group 0: (Blocks 1-8192) [Itable_zeroed] first block group

    Checksum 0x746b,2008 a unused inode

    primary Superblock at 1, Group descriptors at 2-2

    Reserved GDT blocks are located at 3-258

    Block Bitmap at 259 (+258), Inode bitmap at 275 (+274)

    Inode table at 291-546 (+290)

    3785 free blocks, inodes, 6 directories, 2008 unused Inodes

    Number of blocks available: 4408-8192

    Number of Inode available: 39-2048

    Group 1: (Blocks 8193-16384) [Inode_uninit, itable_zeroed]

    Checksum 0x2a64,2048 a unused inode

    backup superblock at 8193, Group descriptors at 8194-8194

    Reserved GDT blocks are located at 8195-8450

    Block Bitmap at 260 (+4294959363), Inode bitmap at 276 (+4294959379)

    Inode table at 547-802 (+4294959650)

    642 Free blocks, 2048 free inodes, 0 directories, 2048 unused inodes

    Number of blocks available: 15743-16384

    Number of Inode available: 2049-4096

    Group 2: (Blocks 16385-24576) [Inode_uninit, Itable_zeroed] block Group 2 does not have superblock.

    Checksum 0xd123,2048 a unused inode

    Block Bitmap at 261 (+4294951172), Inode bitmap at 277 (+4294951188)

    Inode table at 803-1058 (+4294951714)

    2048 free blocks, 2048 free inodes, 0 directories, 2048 unused inodes

    Number of blocks available: 22529-24576

    Number of Inode available: 4097-6144

    Group 3: (Blocks 24577-32768) [Inode_uninit, itable_zeroed]

    Checksum 0x4d3e,2048 a unused inode

    Backup superblock at 24577, Group descriptors at 24578-24578

    Reserved GDT blocks are located at 24579-24834

    Block bitmap at 262 (+4294942981), Inode bitmap at 278 (+4294942997)

    Inode table at 1059-1314 (+4294943778)

    188 Free blocks, 2048 free inodes, 0 directories, 2048 unused inodes

    Number of blocks available: 32581-32768

    Number of Inode available: 6145-8192

    Only 3 Blockgroup block groups are shown.

    By the way, the next E2label command

    Mane2label after: E2label-change the label on an EXT2/EXT3/EXT4 filesystem

    Usage: E2label device label

    Instance:

    Introduction to Linux file system

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.