Learning Log---linux disk formatting

Source: Internet
Author: User
Tags uuid

linux:ext2,3,4 These file systems are supported by most Linux


After partitioning the disk, the kernel recognizes the disk partition through the KPARTX and Partx directives, and then formats the disk area, which is to create the file system:

One of the formatting operations is to create a metadata area and data area for the partition, the metadata area is the inode, each inode is an entry, a file, the Inode has a file in the data area corresponding to the number of blocks, the data area a lot of block, each block is 512 bytes, Used with 2 of the N-Square as the unit to use, each partition unified with a few blocks as a minimum unit to store data.

File repair and detection refers to whether the file information in the Inode in the metadata area is compared to the block in the corresponding data area, and if the difference is treated as an error file, delete the Inode and the corresponding block.

When the file system is created, it also divides the partition of the disk into a log area, storing the log records, for example, in the write operation, the creation of the file information Inode is created in the log area, if the write is completed and then transferred to the metadata area, if the middle power loss, then the write failed, then for file repair and detection, Detects if the inode in the log area and the corresponding file data information are consistent.

Each partition is also a super block, storage blocks group information, what blocks in the group, called Block groups, the Super Block is also a block, the existence of the data area, but the block is a block of metadata, stored in the group information. In many block groups, there are super blocks, numbered 0 Super block as the use, the other block group of Super Block play back role.

In the metadata area, in addition to the inode of the file, there is an inode bitmap and a block bitmap for viewing the idle Inode and block. The information for these bitmaps is present in the Super block.

The Super Block records important basic information about the entire partition, such as grouping information, block size, bitmap, idle size, and so on.


MKFS: Creating File System directives

-T Fstype/dev/somedevice


# mkfs-t Ext2/dev/sda3 to Sda3 this partition uses ext2 this file system to manage

# MKFS.EXT2

# MKE2FS

-T


Ext4:mkfs-t Ext4 = MKFS.EXT4 = mke2fs-t EXT4 These operations commands are equivalent

Ext3:mkfs-t ext3 = Mkfs.ext3 = mke2fs-t ext3 = mke2fs-j

EXT2:

Which area of the disk device file is later added to


Format the instructions used to create the file system in detail

MKE2FS: This command is more powerful than the others, so use this command to create a partitioned file system

Configuration file:/etc/mke2fs.conf, this file is the configuration file for this directive, and some default properties of the file system created by the directive are configured

Mke2fs-t-ext4/dev/sda3

-t {EXT2|EXT3|EXT4} choose which file system

-j: Equivalent to-t ext3

-L Label: Volume label

-B {1024|2048|4096}: Specify block size

-I #: #个字节给预留一个inode

-N #: Specify the number of inode reserved directly

-I #:inode size

-M #: Percentage of space reserved for administrators, default is 5, enter numbers directly


-o: Specify partition attributes


/ETC/MKE2FS.CONF has the default attribute of the MKE2FS instruction, block size, inode ratio

[Email protected] ~]# cat/etc/mke2fs.conf

[Defaults]

Base_features = sparse_super,filetype,resize_inode,dir_index,ext_attr

BlockSize = 4096

Inode_size = 256

Inode_ratio = 16384


setting and viewing volume labels

E2label

E2label/dev/somedevice: View Volume label

E2label/dev/somedevice Label: Setting the volume label


View property directives for a disk partition

Blkid/dev/somedevice: View device properties, UUID, and type

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

/dev/sda1:uuid= "1769b47d-20c1-4803-bf94-2710e7e5bb0a" type= "Ext4"


The super block holds the key information for the entire partition, such as size, grouping, and so on, as follows:

[[email protected] ~]# DUMPE2FS/DEV/SDA1 will show the basic information of the Super block and the information of each block group

Here is the basic information about the Super block:

DUMPE2FS 1.41.12 (17-may-2010)

Filesystem Volume Name: <none>

Last mounted on:/boot

Filesystem uuid:1769b47d-20c1-4803-bf94-2710e7e5bb0a The UUID of the partition, which is used to mount the identified

Filesystem Magic number:0xef53

Filesystem Revision #: 1 (dynamic)

Features supported by this partition can be adjusted using the tune2fs o option

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

Filesystem State:clean

Errors behavior:continue

Filesystem OS Type:linux

Inode count:128016

Block count:512000

Reserved Block count:25600

Free blocks:465017

Free inodes:127978

First Block:1

Block size

Block size:1024

Fragment size:1024

Reserved GDT blocks:256

Blocks per group:8192

Fragments per group:8192

Inodes per group:2032

Inode blocks per group:254

Flex Block Group Size:16

Filesystem CREATED:FRI Oct 2 11:34:24 2015

Last Mount Time:fri Oct 2 12:21:12 2015

Last Write Time:fri Oct 2 12:21:12 2015

Mount Count:3

Maximum Mount Count: 1

Last Checked:fri Oct 2 11:34:24 2015

Check interval:0 (<none>)

Lifetime writes:24 MB

Reserved blocks uid:0 (user root)

Reserved blocks gid:0 (group root)

First Inode:11

Inode size:128

Journal Inode:8

Default Directory HASH:HALF_MD4

Directory Hash seed:7718dfbb-c3fb-4f24-826c-47309b6d5d96

Journal Backup:inode Blocks

Journal Features: (none)

Journal size:8m

Journal length:8192

Journal sequence:0x00000015

Journal start:1

The following are information for each block group:

Group 5: (Blocks 40961-49152) [Inode_uninit, itable_zeroed]

Checksum 0x1a56, unused inodes 2032

Backup superblock at 40961, Group descriptors at 40962-40963

Reserved GDT blocks at 40964-41219

A bitmap of blocks and inode that is used to query space, indicating which block the information is in

A bitmap block can represent the usage information for all blocks in a block group

Block bitmap at 265, Inode bitmap at 281

Inode table at 1562-1815

7933 free blocks, 2032 free inodes, 0 directories, 2032 unused inodes

What are the free blocks?

Free blocks:41220-49152

What are the idle Inode

Free inodes:10161-12192

Group 6: (Blocks 49153-57344) [Inode_uninit, Block_uninit, itable_zeroed]

Checksum 0xe2c5, unused inodes 2032

Block bitmap at 266, Inode bitmap at 282

Inode table at 1816-2069

8192 free blocks, 2032 free inodes, 0 directories, 2032 unused inodes

Free blocks:49153-57344

Free inodes:12193-14224

Dumpe2fs

-H: View only the information stored in the Super block, which is the top information


Instructions for adjusting the Mke2fs property: Mke2fs After formatting the partition, the information in addition to the block and inode size cannot be modified, and the rest is basically:

Which partition device is behind TUNE2FS

-L: View information in the Super block

-L Label: Set Volume label

-m: Percentage of space reserved for administrators, default is 5

-j: If the original file system is ext2,-j can promote it to ext3

-O [^]mount-options[,...] : Set its default mount options

-O [^]feature[,...]: Adjust partition characteristics

You can see the function of the option


After setting or clearing Sparse_super, UNINIT_BG, filetype, or resize_inode filesystem features, E2FSCK (8) must is run The filesystem to return the filesystem to a consistent state.


File System Detection:

Fsck:

-T Fstype

Fsck-t Ext4/dev/sda3

-A: Auto fix error

-r: Interactive fix error


E2fsck

-F: Force detection

-y: Automatic answer to question Yes


Swap partition:

Virtual memory, required on Linux must be separate partitions


Mkswap to format the partition, creating the partition as a swap partition

-L Label


Swapon +/dev/somesd This is enable swap partition

-A: Start all make swap partition

-P #: Specify Priority #是个数字


Swapoff

-A


Cat/proc/meminfo This instruction is to view the current memory usage information, where the swapcached is the swap partition size of the current kernel


Gpt


Dma:direct Memory Access


Summary: fdisk, MKE2FS, Mkfs, Blkid, E2label, DUMPE2FS, TUNE2FS, fsck, E2fsck, Mkswap, Swapon, Swapoff


Learning Log---linux disk formatting

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.