Traditional Culture Encyclopedia - Photography major - Notes on linux Private Kitchen-Chapter 7-Linux Disk and File System Management

Notes on linux Private Kitchen-Chapter 7-Linux Disk and File System Management

Focus: inode, block (data block) and superblock (superblock)

Disk structure

GPT and MBR

differentiate

Disks are represented as files.

All devices in linux are represented as files in /dev, such as /dev/sd[a-p physical ][ 1- 128 partition].

File System: Boot+Group+Group ...

Group: information data of information nodes

Restrictions:

Disadvantages:

Large: Small files waste more space.

Small block: inode has poor reading and writing performance.

It takes 4B to record a block pointer, and an inode contains 12 direct, 1 indirect, 1 double indirect, and 1 triple indirect, so the maximum size of the next file in a block is12+256+256 256.

How to view this information?

Output: Super Block Information+Block Group Information

shop

take

Inconsistent data

asynchronous processing

When a file is modified, it is read into memory and marked clean. After modification, it is marked as dirty, but it will not be written to the hard disk immediately. You need to call to synchronize.

Abnormal shutdown will lead to disk verification.

File system and directory tree

Mount: File system is combined with directory tree, such as mount/to device /dev/sda 1.

The inode of different file system directories of the same file system type is the same, and the inode values of files of different file systems may be repeated, and the inode of the same file system corresponds to files one by one.

Linux supports various file systems, including traditional, log and network. You can query the following commands.

VFS (Virtual File System Switching) is a system call at the kernel level, which helps to read different file systems.

Ext4 is not good: all inode are pre-allocated and have a slow format, which is not suitable for large-capacity disks.

XFS is good: suitable for large-capacity disks and large files.

Lsattr and chattr can change hidden attributes, but xfs does not support partial hidden attributes.

Xfs is divided into data part, file system activity log part and real-time part.

data field

Like ext, it is divided into super block, management of remaining space, allocation and tracking of inode. But inode is dynamically allocated and quick format's. And you can customize the data block (the kernel above 4K is not allowed to be mounted) and the inode size (256B-2M).

File system active login area

Similar to the log area, all file modifications are recorded here, and verification is deleted only after writing. You can specify an external disk as a zone.

Real-time running area

First find several disk blocks in this section, put the files in these blocks, and then write them into inode and blocks in the data area after allocation.

Xfs file system viewing information

Note: If you use /boot, you can see that /dev/sda2 points to a physical device, but if you use/,you can see that it points to /dev/mapper/centos-root. This is because when installing the system, the device partition uses LVM instead of standard partition, and linux will automatically create a space pool for you, and you can take as much as you want.

Contains the size, number, total number of inodes, block size, number and information related to array stripes.

df

1kblock, used and free in /proc are all 0, because this directory is mounted in memory.

/dev/shm/ is virtual disk space with memory.

I don't know the mount point of a directory/file, but I also want to know how many things can be stored in this partition.

Du (surname)

Hard link

Symbolic link

Process: partition-> Format->; Check (optional)-> Mount (Linux feature)

See UUID (globally unique identifier): lsblk-f or blkid.

Partition process: lsblk or blkid view partition->; Gdisk or fdisk follow the prompts.

Blocks and sectors: blocks are used for file systems and sectors are used for physical hard disks.

Linux will not be able to update the partition table without processing the active partition (mount partition).

Adding partitions By default, partitions are numbered by serial number, and the default starting sector starts with the first unoccupied sector.

Function: Use file system formatting software to format the disk partition.

Command: mkfs.xfsmkfs.ext4mkfs