Traditional Culture Encyclopedia - Traditional culture - Detailed description of disk partition

Detailed description of disk partition

Before installing a brand-new hard disk in the system, it must be partitioned. There are two main formats for initializing hard disk partition: traditional MBR (master boot record) and new GPT( GUID partition table). The latter is more powerful and solves many limitations of MBR.

MBR was put forward as early as 1983 in IBM PC DOS 2.0. It is called "master boot record" because it is located in the master boot sector at the beginning of the drive, which is the first sector of the hard disk. It consists of three parts: boot loader, hard disk partition table DPT and end flag word.

The partition mentioned above is the main partition. There can only be four bootable primary partitions on a disk or RAID volume. If the MBR partition scheme needs to use more than four partitions, at least one main partition should be used as an extended partition, and then several logical partitions should be established on the extended partition. An extended partition can be regarded as a container for accommodating logical partitions. There can only be 1 extended partitions on the hard disk (limited by the operating system), which cannot be formatted by itself. It can only be used after being divided into logical partitions, but there is no limit to the number of logical partitions in the extended partitions. The extended partition is also regarded as the main partition, so only three more main partitions can be built when there are extended partitions (three main partitions plus 1 extended partitions that can contain multiple logical partitions).

The boot record of the logical drive in the extended partition is linked. Each logical partition has an extended boot record (EBR), which is similar in structure to MBR. The first entry of the partition table points to the boot sector of the logical partition itself, the second entry points to the EBR of the next logical drive, and the third and fourth entries of the partition table are not used.

BIOS (Basic Input-Output System) is the basic input-output system, and it is the first software loaded when a personal computer is started. In fact, it is a program stored on the BOIS chip of the computer motherboard, in which the most important basic input and output programs, power-on self-test (POST) and system startup programs of the computer are stored.

Generally, when the computer is started, press F2 or Delete to enter the BIOS program for setting (for some special models, press F 1, Esc, F 12 for setting). Its main function is to provide the lowest and most direct hardware setting and control for the computer.

The full name of UEFI is Unified Extensible Firmware Interface, which means Unified Extensible Firmware Interface. It is developed on the basis of EFI 1. 10 standard. It is worth noting that before UEFI was formally established, Intel began to actively promote the upgrade scheme of traditional BIOS. Finally, the EFI standard of transition scheme is formulated. Until 2007, Intel handed over the improvement and perfection of EFI standard to the unified EFI Form, and the EFI standard was officially renamed UEFI. UEFI is actually a kind of program with BIOS, which is an upgraded version of BIOS with the development of hardware, and is regarded as the successor of Legacy)BIOS with a history of nearly 20 years. UEFI generally refers to the UEFI BIOS environment, while BOIS refers to the traditional BIOS environment compared with UEFI.

UEFI has some advantages over BIOS:

Compared with traditional BIOS, UEFI also provides file system support, which can directly read files in FAT and FAT32 partitions. For example, motherboards such as ASUS and Huaqing can directly read the BIOS and other files in the U disk by updating the BIOS in UEFI environment. In addition, the new UEFI motherboards basically provide screen capture function, and these screen capture pictures can be saved in a USB flash drive.

Another important feature of Uefi is to run applications under Uefi, which usually ends with EFI. With UEFI, you can directly identify files in the FAT partition, and you can also directly run applications in it. We can make Windows installer an efi-type application, and then put it into any FAT partition to run directly.

Of course, because UEFI is mainly written in high-level language (C language), compared with the assembly language of traditional BIOS, UEFI BIOS is weaker in security protection and more vulnerable to virus attacks, and its security needs to be further improved. However, in the face of graphical interface and application expansion, UEFI BIOS is still very successful.

Now, in order to be compatible with MBR partition table, most motherboards generally provide Legacy BIOS and UEFI BIOS boot mode options. If you want to install the operating system in UEFI mode, UEFI mode must be turned on. UEFI mode can be switched back to BIOS mode, but it cannot be switched to UEFI mode only in BIOS mode.

At present, 64-bit Windows Vista, 7, 8, 8. 1 and 10 all support GPT partition tables, while Windows 8, 8. 1 0 all natively support UEFI. When installing these systems, as long as the hard disk is set to GPT partition table and the motherboard is set to UEFI, the operating system can be installed directly. Since the release of Win8, all newly-built computers pre-installed with Win8/Win8. 1 have started the operating system in UEFI mode by default.

For Windows Vista and 7 systems, UEFI support needs to be added manually. We can find an installation image of Windows 8 or 10, extract the Bootmgfw.efi file from the installation file and rename it BOOTX64. EFI, copy it to the \EFI\Boot\ of the Win7 installation file, and create a new one if there is no boot folder.

The full name of GPT is the globally unique identifier partition table, which means GUID partition table. UEFI BOIS will gradually replace the traditional BOIS, and GPT will gradually replace MBR. UEFI and GPT complement each other and are indispensable. If you want to use GPT partition table, you must use UEFI BIOS environment.

Compared with MBR partition table, GPT partition table can support the largest 2T disk and RAID volume and the largest 4 main partitions, while GPT partition table can support the largest 18 EB(Exabytes) disk and RAID volume. Moreover, there is no upper limit on the number of partitions of disks and RAID volumes, which is only limited by the operating system (because the partition table itself needs to occupy a certain space, when the hard disk partition is initially planned, the space left for the partition table determines the maximum number of partitions). For example, on Windows system, GPT can only support 128 disk partitions at most, which can basically meet the storage needs of all users. On each partition, this identifier is a randomly generated string, which can ensure that every GPT partition on the earth is assigned a completely unique identifier.

In terms of security, GPT partition table has also been improved in all aspects. On early MBR disks, partition and startup information were kept together. If this part of the data is overwritten or destroyed, things will be in trouble. In contrast, GPT keeps multiple copies of this information on the whole disk, so it is more robust and can recover damaged information. GPT also keeps a Cyclic Redundancy Check Code (CRC) for this information to ensure its completeness and correctness-if the data is corrupted, GPT will find these corruptions and recover them from other locations on the disk.

GPT has many advantages over MBR, which was born in MS-DOS era. Before making a choice, you need to consider the following points:

The following is a list of GPT supported by mainstream operating systems.

For a more detailed support list, please refer to Wikipedia.

For new platform users (after Intel 6 series /AMD 900 series and A series), it is strongly recommended to use GPT partition table format. At present, Win Vista, Win7, Win8, Win8. 1 and Win 10 all support reading and using GPT partition tables. For users who use Win8, Win8. 1 and Win 10, the startup speed can be further significantly improved after switching to GPT.

Because the new computers that have just come out are basically UEFI+GPT, if you want to replace the system, you must install it in the form of GPT partition format +UEFI boot. However, if you want to install with the previous MBR method (such as installing a Ghost system), you can only convert the partition format of the hard disk into MBR, change the system boot mode to Legacy, and re-partition before installing.

If you forget to change the previous MBR partition format to GPT when installing a newer Windows system on the hard disk with MBR partition format, and then you cannot continue when choosing the installation location of Windows, as shown in the following figure.

At this time, it is necessary to change the hard disk partition format to GPT, change the system boot mode to UEFI, and re-partition before installation.

Method one

If you know the relationship between GPT and UEFI startup, then you may know that Windows must start in UEFI mode if it wants to start from GPT hard disk (otherwise it will be invalid). In disk management (->-click on the computer shortcut on the desktop->; Management-> disk management), right-click a disk, click the Properties menu item, and then select the Volumes tab to view the partition type. If it is GPT, then the computer must be started by UEFI.

Method 2

This method is suitable for Windows systems with Win 8 and higher versions. Press Win+R to start running, enter msinfo32, and press enter to view system information. If "Traditional" is displayed in BIOS mode, it means that the system startup mode is Legacy BIOS;; If it is UEFI, UEFI is displayed.

Method one

You can judge whether it is UEFI boot mode by checking whether there is a /sys/firmware/efi directory.

Method 2

You can also check whether the Linux system supports UEFI boot mode by installing the efibootmgr program and then executing the sudo efibootmgr command.

Here is a view and modification method that is suitable for any operating system.

Press the hotkey (usually Del, F2, etc. ) enter the BIOS before the system starts to load. Generally, this function is located under the startup-related menu, and the computer operation method is similar for different motherboards. As shown in the figure below, you can view the current boot mode or modify the boot mode.

The capacity and number of partitions depend on the number, capacity, type and usage habits of hard disks. The partition capacity is small and the number is large, so it will be very troublesome to transfer files between partitions. Large partition capacity and small number will increase the risk of file loss (such as frequent direct power failure instead of normal shutdown or hard disk failure caused by other reasons). If a single partition is damaged, all files in that partition will be lost.

If your hard disk is large enough, such as 1 TB, or even multiple hard disks of 1TB, you can set the partition of Windows system to 100 GB, and the remaining space can be divided into partitions with appropriate capacity and quantity according to software installation, media storage, document office, file backup and other purposes. If the combined mode of 128 GB or 256 GB SSD+HDD is adopted, the whole SSD can be divided into one partition, and Windows and application software can be installed on the whole SSD partition to speed up the startup and application software startup.

If the Windows system uses MBR partition format, generally only one main partition is assigned to the system, and all the others are assigned to extended partitions.

This method does not need any third-party tools and belongs to the most basic method. The advantage is that the operation is simple and intuitive, but the disadvantage is that the command is not easy to remember, and the whole hard disk needs all formats and cannot retain data. Therefore, before the operation, you must back up the important data on the hard disk to other storage devices in advance.

In fact, only motherboards that conform to UEFI specification can start Windows installation program according to efi/boot/bootx64.efi path, and most motherboards follow this specification. If you don't follow this specification, you need to manually choose to start from this file, or you need to start bootx64.efi by command in UEFI Shell.

Many experienced users are familiar with this tool, and it is also common in some revised PE systems in China. Of course, there are other powerful hard disk operating tools in these systems. For all functions and usage of this software, please refer to its help information in official website.

If you are creating a new partition for SSD, you should check "Align to an integer multiple of the following sectors" and select "4096" in the "Number of sectors" drop-down menu (as shown above), so as to meet the so-called "4K alignment" condition and give full play to the performance advantages of SSD (the original system disk installer will automatically set "4K alignment" when partitioning without manual setting). You can check whether SSD is aligned at 4K through the menu item "Partition 4K Sector Alignment Monitoring" in DiskGenius' tool menu (the last column shows "Y" for alignment).

Compared with GPT, this partition table has some differences in partition mode, which is explained in detail below:

When installing a dual system of Windows and Linux, the boot loader installed later may overwrite the boot loader of the previous system, so that the previously installed system cannot be loaded. CentOS 7 (the latest Ubuntu) uses GRUB2 as the boot loader. The boot loader is the first program that runs after the computer is started, and it is responsible for the loading and transmission control of the operating system. GRUB2 is compatible with all operating systems, and at the same time, chain loading can be used to transfer control to other operating systems in unsupported operating systems. If you install Windows first, and then install Linux booted with GRUB2, the dual system will boot with GRUB2. If you install Linux first and then Windows, all versions of Windows except Win 10 will overwrite the installed Linux bootloader. In this case, you can use EasyBCD software to modify the boot loader under Windows.

First, you must create a partition on the storage device to accommodate the file system. The partition can be the whole hard disk or a part of the hard disk to accommodate a part of the virtual directory. In Linux system, the common name format of hard disk partition is as follows:

The letters in brackets indicate the detection order of drives, the first drive is A, the second drive is B, and so on. N stands for partition number. In the hard disk of MBR partition, 1-4 is the main partition (or extended partition), and the logical partition number can only start from partition 5. Traditionally, the main partitions sda 1 to sda3 are created first (three main partitions can be created at most), and then an extended partition sda4 (after three main partitions are created, only extended partitions can be created by default) and subsequent partitions sda5 are established.

When installing CentOS 7, select "Install CentOS 7", then press "Tab" and enter a space after "quiet" at the bottom of the screen with "inst.gpt" to use the gpt partition. Otherwise, MBR partition is selected by default.

The fdisk tool is used to create MBR partitions on storage devices. It is an interactive program that allows you to enter commands to complete the hard disk partition operation step by step. The usage of this command is as follows:

The available options are as follows:

You can use the -l option without specifying a device name to view all current disk partitions and mapped logical volumes. You can also specify the device name to view the partition list of the specified disk.

After shutting down the virtual machine in VMware, you can "edit virtual machine settings", click Hard Disk and select "Expand" to expand the original hard disk, or select "Add" to add a new hard disk. Let's demonstrate that the original hard disk of the virtual machine has been expanded by about 20 GB, and a new hard disk with a capacity of about 20 GB has been added.

As can be seen from the above execution results, after expanding the original hard disk and adding a new hard disk, the original capacity of /dev/sda is increased, and a new unpartitioned disk of /dev/sdb is added.

After using the fdisk command, you can directly specify the device name of the storage device to be partitioned (super user is required) to enter the interactive operation mode of the fdisk tool. The following shows the usage scenario of this command in the CentOS distribution. If this is the first time you partition a storage device, fdisk will prompt you that there is no recognizable partition table on the device.

When prompted, enter the m command to view the available interactive commands.

These commands are interpreted as follows:

In fact, only a few basic commands are used in daily work. You can use the p command to display the details of the storage device.

The output shows that this storage device has about 2 1.5 GB of space. The storage device details list lists all partitions of the device. The output in this example does not show any partitions, so the device has not been partitioned yet. Next, you can use the n command to create a new partition on the storage device when prompted. To use the n command, you need to specify the partition type to be created (p stands for main partition and e stands for extended partition), then specify the partition number, and finally specify the starting cylinder and the ending cylinder of the partition respectively (you can also specify the increased number of cylinders or the increased capacity according to the prompt).