[Host planning and disk partitioning] disk partitioning MBR and disk partitioning mbr

Source: Internet
Author: User

[Host planning and disk partitioning] disk partitioning MBR and disk partitioning mbr
Relationship between the disk connection method and the device file name

The mainstream disk interfaces areSATA interface.
SATA, USB, SCSI, and other disk interfaces are all driven by the SCSI module.Therefore, the disk device file names of these interfaces are/Dev/sd [a-p]Format. The order depends on the order in which the Linux kernel detects the disk.

For example, there are two SATA disks and one USB disk on the PC, and six SATA slots on the motherboard. These two SATA disks are separately inserted inSATA1 SATA5Interface. What is the device file name of these three disks in Linux?
1. Name of the file/dev/sda on the SATA1 slot
2. Name of the file/dev/sdb in the SATA2 slot
3. USB disk (identified by the system only after boot)/dev/sdc

Disk composition review

The disk data is actually written on the disk. The disk can be subdivided into two units: Sector and Cylinder. Each of these units is as large as bytes.

The first sector of each disk is particularly important because it records two important information about the entire disk:
① Master Boot Record MBR: where the Boot loader can be installed, there are 446 bytes
② Partition table: records the status of the entire hard disk partition, with 64 bytes

MBR is very important, because the system will take the initiative to read the content of this block during the boot, so that the system will know where your program is put and how to start it. If you want to install the multi-boot system MBR, it is very important to manage this block.
The partition table records the disk partition information, which is described below.

Partition table)

The cylinder is the smallest unit of the file system, that is, the smallest unit of the partition.We use the cylindrical number for processing.64 bytesCapacity, dividedFour groupsRecord area. Each record area records the start and end cylindrical numbers of the segment.

If the above hard disk device file name is/dev/hda, the device file names of the four partitions in Linux are as follows:
P1:/dev/hda1
P2:/dev/hda2
P3:/dev/hda3
P4:/dev/hda4

Due to the capacity limit of partition tables, a maximum of four partitions can be accommodated. These four partitions are called Primary or Extended partitions.
Note the following information:
① In fact, the so-called "partition" is only for the 64 bytes partition table.
② By default, the partition table of the hard disk can only write information about four partitions.
③ The information of the four groups is called the Primary and Extended partitions.
④ The smallest unit of a partition is cylinder ).

When the system needs to write data to a disk, it must refer to the disk partition table to process data for a partition.

Why "partition "?
Cause 1: Data Security
Cause ②: System Performance Considerations

Although a partition table can only record four partitions, it does not mean that we can only partition up to four partitions.Since the partition table where the first slice is located can only record four data records, you can use the additional slice to record more partition information.
The purpose of an extended partition is to use additional slices to Record Partition information. The extended partition itself cannot be formatted. However, we can continue to record partitions by extending the partition pointing to that block.

The partition that is split from the extended partition is calledLogical partition). Because logical partitions are partitioned by extended partitionsThe cylindrical range that can be used is the range set by the extended partition.
Note that 1-4 files are always retained regardless of the four records in the partition table. Even if only one primary partition is used, the extended partition starts from 5.

Note the following information:
① A maximum of four primary and extended partitions can be created (Hard Disk restrictions ).
② A maximum of one extended partition can be created (Operating System Restrictions ).
③ Logical partitions are the partitions continuously cut out by extended partitions.
④ Partitions that can be formatted and accessed as data are the primary partition and logical partition. Extended partitions cannot be formatted.
⑤ The number of logical partitions varies with the operating system. In Linux, a sata hard drive can have a maximum of 11 logical partitions (numbers 5 to 15)

Note:If the extended partition is damaged, all logical partitions will be deleted. Because the information of the logical partition is recorded in the extended partition.

Therefore, if the first sector of a hard disk (that is, the sector where MBR and partition table are located) Physically breaks down, the hard disk will probably be useless.

For example

Suppose there are two hard disks on the PC and six available partitions are separated from the second hard disk (sdb). What is the file name of each partition in the Linux system?

Method 1:P + E Environment(The fourth partition is an extended partition, and the extended partition is divided into three logical partitions)
Available partitions:/dev/sdb)

Method 2:P + E Environment
Available partitions:/dev/sdb)

Boot Process and primary boot partition (MBR) Boot Process

CMOS: record various hardware parameters and switch to the memory on the motherboard
BIOS: A firmware written to the motherboard.

BIOS is the first program automatically executed by the computer when it is started.
Then, the BIOS analyzes the storage devices in the computer and reads the MBR location of the first sector from the hard disk.MBR, which has only 446bytes of hard disk capacity, contains the most basic boot loader.Next, MBRIdentify the file system format in the hard disk and boot the Kernel FileTo enter the operating system.

Simply put, the boot process is as follows:
① BIOS: indicates the firmware that is automatically executed during startup. the first device that can be started will be known.
② MBR: The primary boot partition in the first sector of the device that can be started, including the boot loader.
③ Boot loader: a software that can read kernel files for execution.
④ Kernel File: Start the operating system function.

Primary boot partition (MBR)

Boot loader is a set of software installed on MBR in the operating system. This program is small and perfect. The main tasks of this boot loader are as follows:
① Menu provided: users can choose different boot options, which is also an important function of Multi-boot.
② Load the Kernel File: directly point to the boot program segment to start the operating system.
③ Transfer another loader: transfers the bootstrap load function to other loaders. (Multiple systems)

In addition to MBR, the boot loader can also be installed on the boot sector of each partition)

Note the following information:
① Each partition has its own boot sector (boot sector)
② The kernel files that can be turned on are placed in each partition.
③ Loader only recognizes the boot kernel files in its system partition and other loaders.
④ Loader can direct or indirectly forward management rights to another management program.

The windows Installer overwrites the MBR and the startup sector of the partition.So if you have two systems, you 'd better install windows before installing linux.
(Otherwise, you can use the Linux rescue mode to save MBR)

Selection of disk partitions in Linux installation mode (very important)Directory tree structure

The most important part of Linux isDirectory treeStructure. The so-called directory tree structure refersThe root directory (/) is the main structure, and then a file structure of the branch directory structure is displayed downward.All files are related to the directory tree.

How to combine the directory tree architecture and data in the disk involves "mounting.

Relationship between the file system and the directory tree

Use a directory as the entry point to store the data in the disk partition. That is to say, you can read the meaning of the partition by entering the directory.
This operation is calledMountThe directory that enters the vertex is calledMount point.

The root directory must be mounted to a partition.

For example

Partition1 is mounted to the root directory, and partition2 is mounted to the/home directory. That is to say, when my data is stored in the directories in/home, the data is stored in partition2. If the directory is not in/home, the data will be placed in partition1.

Plan the mount point and disk partition when installing distributions

Select custom installation (Expert Installation) when installing Linux ).

Custom installation "Custom"

First linux: Just partition "/" and "swap"
Recommended Partitioning Method: reserve a spare disk capacity.

Select the default hard disk partitioning method provided by the Linux Installer

Do not select the Default Server Installation option when installing linux.

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.