The specific steps of hard disk partitioning under Linux

  

To master the partition of Linux hard disk, we must know the concept of MBR, extended partition and logical partition. Today, Xiaobian will introduce you to the detailed steps of Linux hard disk partitioning. Interested friends Let's take a look.

This article describes the process of Linux hard drive partition, partition and why this principle.

File system focus: inode (inode), block (logical block), superblock (the block at the beginning of each file system, used to store the size of the file system, empty or filled Full blocks, and their respective totals, etc.)

Physical composition of the disk:

Round disk disk

Robotic arm, with robotic arm Disk read head (rewritable data on the disk)

Spindle motor, you can rotate the disk, let the read head of the robot read and write data on the disk

The physical composition of the disk:

The sector is the smallest physical storage unit, each sector is 512bytes

The sector is formed into a circle, that is, the magnetic column, the magnetic column is The smallest unit of partition

The first sector is the most important, there are mbr (main boot area) and split table, where mbr occupies 446 bytes, and partition table occupies 64 bytes

disk partition: Specify the start and end of the partition.

The range of the column for the partition Recorded in the partition table of the first sector

Inode: Storage rights and attributes, there are:

1. The owner and group of the file (owner/group); >

2. The access mode of the file (read/write/excute);

3. The type of the file (type);

4. The file creation or status change Time (ctime), near-time reading time (atime), near-modification time (mtime);

5. The capacity of the file;

6. Flag defining the file characteristics Flag, such as SetUID. . ;

7. Pointer to the real content of the file;

Data block: store the actual data

Superblock: record the entire information of the entire file system, including inode and Total block, usage, remaining amount, etc.

Since ext2 is an indexed file system, it is usually not necessary to defragment frequently.

If the hard disk file system is as high as several hundred gb, It is a very unwise decision to put all the inodes together with the block, because the number of inodes and blocks is too large to manage, so the ext2 file system is basically divided into multiple block groups when formatting. (block group), each block group has an independent inode/block/superblock system

A file system has only one superblock; except for the first block group which will contain superblock, follow-up The block group does not necessarily contain a superblock, and if it contains a superblock, the superblock is mainly used as a backup of the superblock in the first block group, and can perform superblock rescue

Dumpe2fs /dev/hda2: View information about hda2 partition and superblock

The directory does not only occupy a block. That is to say: if there are too many files under the directory, one block cannot accommodate all the file names. When comparing the table with the inode, linux will give the directory one more block to continue recording the first data.

If the file is too discrete, you can copy all the data in the file system and then reformat the file system. Then, if you copy the data back, you can solve the problem

Log file system: ext3:

Preparation: When the system wants to write a file, it will record somewhere in the log block. The files are ready to be written

Actual write: Start writing the permissions and data at the time; Start updating the data of the metadata

End: After completing the update of the data field metadata, the log Recording the file in the recording block

After the file system is inconsistent, the system only needs to check the logging block to find the abnormal file. Then check the consistency of the file, without having to check the entire filesystem to achieve the ability to quickly repair the filesystem

Common support file systems are:

Traditional file system: ext2 , mimix, ms-dos, fat (with vfat module), iso9660 (CD), etc.

Log file system: ext3, reiserfs, windows’sntfs,ibm’s jfs,sgi’s xfs

Network File System: nfs, smbfs

The standard file system for Linux is ext2

View the file systems supported by linux: ll /lib/modules/$(uname -r)/Kernel/fs

View the supported filesystems currently loaded into memory: cat /proc/filesystems

Hard links (cannot cross filesystem, not link directories): Inodes through filesystems Link to generate a new file name instead of generating a new file

Soft link: equivalent to a shortcut under Windows

Create a link file: Ln [-sf] Source file target file

After Linux repartitioning, it is possible To restart to update the core partition table; in the case of no restart, you can also use the following command: partprobe; partprobe is the role of the high-level core must read the new partition table

When partitioning the hard disk, it is better to be safer in single-person maintenance mode. When fdisk is used, if a partition of the hard disk is still in use, it is very likely that the system core cannot reload the partition table of the hard disk. The method is to respect the partition in use to dismount, and then re-enter the fdisk again, re-write the partition table, you can succeed.

The above is a detailed description of the Linux hard disk partition, Linux system in the hard disk partitioning there are several places need special attention, follow the steps described in this article.

Copyright © Windows knowledge All Rights Reserved