机文章

MBR GPT conversion to GPT: MBR and GPT are too crazy

 

The internet has become a part of our daily livesabsencePossible or lackingonePart of it brings many surprises and changes. Today, let's focus on the recent developments in the internet fieldoneExplore this limitless possibility together on some exciting eventsThe world.

For example, device/device:oneBlock disk isoneA device device is usually/dev/sda. Device names such as/dev/sdb refer to the absence of libata (Linux kernel) on the entire diskTop useLegacy systems that support ATA host controllers and devices will result in IDE and SCSI disks havingabsenceSame as.

In this case, the device name will be/dev/hd * (IDE) or/dev/sd * (SCSI). The mechanical hard disk is made of hard metal material and coated with magnetic media. Both sides of the disk are called the disk face or sector face, which can record information and be operated by the magnetic head (if you haveA bad hard drive can be disassembled by hand.

Hmm?WhyWorn out? Good use may cost money...)oneThe use of magnetic head numbers to distinguish structural characteristics determines that if a mechanical hard drive is subjected to severe impact (such as falling to the ground or being diligent enough to disassemble and learn), the magnetic headtakeEven a slight impact on the disk may cause it to be scrapped. Continuing with the principle: Assuming a magnetic headabsenceMove, rotate the hard disk, and the magnetic head will be drawn on the surface of the diskoneA circular trajectory is magnetized, and the data is stored in these magnetized regions, called magnetic tracks. Each track is segmented,oneAn arc segment isoneSectors.

oneA hard drive can contain multiple sectors, which are coaxial and overlapped. Each disk has the same number of tracks and has the same circumference, forming a cylinder called a cylinder. The number of cylinderstakeThe number of magnetic tracks is equal as shown in the following figure

With this understanding, we can proceed with the initial hard drive address management approach1Understanding at the level of principles: The initial addressing method was called CHS, and in LBA (LoBefore the concept of 'GIcal Block Address' was born, he was responsible for managing disk addresses. The so-called CHS, which includes cylinders, heads, and sectors, was implemented through this3A variable describes the disk address. It should be understood that theabsenceIt's a physical address but a logical address.

This method is also known as the LARGE addressing method, where hard disk capacity=number of magnetic heads × Cylinders × sector number × Sector size(1Later, by assigning logical addresses to each sector and addressing them on a sector by sector basis, LBA addressing was introduced, but in order to maintaintakeCompatibility of CHS mode, which can be converted into magnetic heads/cylinders/sectors through logical transformation algorithms3And LARGE Addressing mode1So, the address here is also a logical address.

(Although the storage principle of Solid-state drivetakeMechanical hard driveabsenceSimilarly, flash storage is used, but LBA is still used for managementabsenceTo further elaborate on this, we can try to understand various formats of partitions. Partitions/Partitions refer to the partitioning of disks, followed by device names and partition codes.

For example,/dev/sda1 represents the system's first1The number on the hard drive1See the Linux kernel documentation (documentation/devices.txt file) for the current partition formatsecondaryThere are two kinds of MBR: In order to be compatible with Windows disks, early Linux used the MBR (Master Boot Record, Master boot record area) that supports Windows to process the boot management programtakePartition table.

And the boot management program record areatakeThe Partition table is placed on the1individualSector. This sector is usually 512 bytes in size (all old Disk sector are 512 bytes)1A sector of 512 bytes will have these two data:secondaryMaster Boot Record (MBR): A place where the boot management program can be installed, with a total of 446 bytes

Partition table: records the status of the entire Disk partitioning. There are 64 bytes. Since the block where the Partition table is located has only 64 bytes of capacity, there can be only four groups of recording areas at most. Each group of recording areas records the start of the sectiontakeThe ending magnetic column number.

The records of these four partitions are calledsecondary The minimum unit of partition for a primary or extended partition slot is usually the magnetic cylinder, where these four groupsPartition information is calledsecondary(Primary) or extended partitions, and extended partitions can be used to record partition information using additional sectors.

Expand the partition itself andabsenceIt can be used to format partitions cut by extended partitions, also known as logical partitions. Since logical partitions are cut by extended partitions, the starting sector of the logical partition is the same as the extended partition

Number of disks1A sector is also called the main Boot sector1Summary:secondaryPartitions and extended partitions can only be defined up to four (hard drive limit) Extended partitions can only be defined at most1Logical partitions (limited by the operating system) are partitioned by extended partitions that can be formatted and used as data access slotssecondarypartitiontakeLogical partitioning.

The extended partition cannot be formatted; The number of logical partitions varies depending on the operating systemabsenceSimilarly, SATA hard drives can already break through in Linux systems 63 or more partition restrictions; The MBR Partition table has the following defects: the operating system cannot recognize the capacity above 2.2T. For example, if a partition exceeds 2.2T, the excess cannot be fetched.

MBR only1After being destroyed, only 446bytes of the MBR can not be repaired to store the boot management program, and many shortcomings of the MBR that cannot accommodate more program codes have greatly limited its application. The technology of hard disk has changed with each passing day, and the capacity of hard disk has improved rapidly (Seagate will sell 60TB Solid-state drive this year). The total space of the extra hard diskabsenceCan we hang it? So, under the newly born UEFI standard1We have developed new technologies.

GPT Logical Block Address (LBA) is a universal mechanism for describing the blocks in which data is stored on computer storage devices,1Commonly used in auxiliary memory devices such as hard drives, such as LBAIt can refer to the address of a data block or the data block pointed to by a certain address.

Nowadays, on computers, the so-called1A logical block is usually a 512 or 1024 bit ISO(9)The standard CD in 660 format is formatted in 2048 bit sets1The logical block size GPT plans all blocks on the disk using this LBA (default to 512 bytes), while the1LBA is called LBA0 (numbered from 0).

take MBR only uses section1512 bytes blocks to recordabsenceSimilarly, GPT used 34 LBA blocks to record partition information! meanwhiletakeIn the past, MBR only had1The situation where the block is killed and then diesabsenceSame, GPT except for the first 34 LBAsoutsideThe last 33 LBAs of the entire disk are also used as another1Backups! This may be saferCome on! The detailed structure looks a bit like the one below:

LBA0 (MBR compatible block):takeThe MBR mode is similar, and this compatible block is also divided into two parts,1One is a block similar to the previous 446 bytes, which stores the1Stage Boot Management Program! In the original record area of the Partition table, this Compatibility mode only places1A partition with a special symbol to indicate that this disk is in GPT format.

andabsenceUnderstand the disk management program of GPT Partition tableabsenceWill recognize this disk, unless the user has special requirements to handle this disk, otherwise it should be managedabsenceCan modify the information of this partition1Step protected this disk! LBA1 (GPT header record): This part records the location of the Partition table itselftakeSize, while also recording the location of the GPT partition used for backup (which was previously mentioned in the last 34 LBA blocks)At the same time, the verification mechanism code (CRC32) of the Partition table is placed. The operating system can judge whether the GPT is correct according to this verification code.

If there are errors, you can also retrieve the backup GPT (the last backup block on the disk) through this record area to restore the normal operation of the GPT! LBA23 (Actual recording of partition information): Starting from the LBA2 block, each LBA can record 4 partition records, so by default, there can be a total of 4 * 32=128 partition records! Because each LBA has 512 bytes, each record uses 128 bytes of space, except for the identifier required for each recordtakeRelated recordsoutsideGPT in each recordBisectionDo not provide 64bits to record the start/end sector number, therefore,GPT Partition table1For partition slots, their maximum capacity limit will be '2 ^ 64 * 512bytes=2 ^ 64 * 1Kbytes=2 ^ 33 * TB=8 ZB', please note that 1ZB=2 ^ TB! Are you saying it's big enough?

Currently, GPT partitions can provide up to 128 records by default, and in the core device records of Linux itself, for single1For disks, although in the past, they could only reach up to 15 partition slots,absenceDue to Linux kernel processing through udev and other methods, Linux no longer has this limitation! In addition,

GPT partitions no longer have the concept of primary, extended, or logical partitions. Since each record can exist independently, of course, each can be considered a primary partition! each1PointsThe area can be used for formatting! By the way, who1Sentence: GPT is a derivative of UEFI, and it is UEFI's1partaboveFeel it through command line tools1Let's go.

The following explanation for fdisk comes from man fdiskFdisk1A dialog box driven program for creating and operating Partition table. It can understand that GPT, MBR, Sun, SGI, and BSD Partition table block devices can be divided into1One or more logical disks called partitions This partition is recorded in the Partition table, usually in sector 0 of the disk.

(In BSDThe worldIn, people will discuss' disk slice 'and' disk label '.) The demo example executes the following command: sudo fdisk - l/dev/sdafdisk - l lists the Partition table of the specified device. If no specific device is specified, it will be based on theDisplay information.

The above command results are as follows: Disk/dev/sda: 931.5 GiB, 1000204886016 bytes, 1953525168 sectors Unit: Sector/1 * 512=512 bytes Sector size (logical/physical): 512 bytes/4096 bytes I/O size (minimum/optimal): 4096 bytes/4096 bytes Disk label type: gpt Disk identifier: 51C62BA8-BDEB(4)7C9(9)D7D-CF7807EB4C03 Device Start End Sector Size Type /Dev/sda1 2048 1230847 1228800 600M EFI system /Dev/sda2 1230848 3327999 2097152 1G Linux file system /Dev/sda3328000 1953523711 1950195712 929.9G Linux LVM

The above shows the/dev/sda device and its related partition information: 1. Sector information, including the size of the sectors, the number of sectors, and the size occupied by each sector. 2. Disk label type is gpt (Guid partition table). Due to the hard disk size limit (2T) of MBR and the limitation on primary partitions (4), gpt gradually becomestributary.

GPT uses UEFI to boot disksOrganization of the entire disk1Sector (sector 0) holds Partition table information 3, disk identifier,1Segment Guid, Global Only1Identifier 4: Information about each partition, including the starting and ending points of the partition, the number of sectors contained, the size, and the type of partition. For example,/dev/sda1 is the first partition of/dev/sda1Partitions.

If you are interested in front-end development, you can visit the image website of Layui: layui.wanxiangsucai.com. Layui is1A classic open source modular front-end UI framework.

为您推荐

MBR GPT conversion to GPT: MBR and GPT are too crazy

MBR GPT conversion to GPT: MBR and GPT are too crazy

device/设备打个比方:一块磁盘就是一个设备 设备通常是/dev/sda, /dev/sdb等。 设备名称指的是整个磁盘。 没...

2023-07-19 栏目:互联网+

当前非电脑浏览器正常宽度,请使用移动设备访问本站!