[go: up one dir, main page]

CN108829351B - Method for converting MBR disk into GPT disk - Google Patents

Method for converting MBR disk into GPT disk Download PDF

Info

Publication number
CN108829351B
CN108829351B CN201810564939.9A CN201810564939A CN108829351B CN 108829351 B CN108829351 B CN 108829351B CN 201810564939 A CN201810564939 A CN 201810564939A CN 108829351 B CN108829351 B CN 108829351B
Authority
CN
China
Prior art keywords
disk
partition
mbr
gpt
boot
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201810564939.9A
Other languages
Chinese (zh)
Other versions
CN108829351A (en
Inventor
先泽强
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Chengdu Aomei Technology Co ltd
Original Assignee
Chengdu Aomei Technology Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Chengdu Aomei Technology Co ltd filed Critical Chengdu Aomei Technology Co ltd
Priority to CN201810564939.9A priority Critical patent/CN108829351B/en
Publication of CN108829351A publication Critical patent/CN108829351A/en
Application granted granted Critical
Publication of CN108829351B publication Critical patent/CN108829351B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/06Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
    • G06F3/0601Interfaces specially adapted for storage systems
    • G06F3/0602Interfaces specially adapted for storage systems specifically adapted to achieve a particular effect
    • G06F3/0604Improving or facilitating administration, e.g. storage management
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/06Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
    • G06F3/0601Interfaces specially adapted for storage systems
    • G06F3/0602Interfaces specially adapted for storage systems specifically adapted to achieve a particular effect
    • G06F3/0614Improving the reliability of storage systems
    • G06F3/0619Improving the reliability of storage systems in relation to data integrity, e.g. data losses, bit errors
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/06Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
    • G06F3/0601Interfaces specially adapted for storage systems
    • G06F3/0628Interfaces specially adapted for storage systems making use of a particular technique
    • G06F3/0638Organizing or formatting or addressing of data
    • G06F3/0644Management of space entities, e.g. partitions, extents, pools
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/06Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
    • G06F3/0601Interfaces specially adapted for storage systems
    • G06F3/0628Interfaces specially adapted for storage systems making use of a particular technique
    • G06F3/0655Vertical data movement, i.e. input-output transfer; data movement between one or more hosts and one or more storage devices
    • G06F3/0661Format or protocol conversion arrangements
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/06Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
    • G06F3/0601Interfaces specially adapted for storage systems
    • G06F3/0668Interfaces specially adapted for storage systems adopting a particular infrastructure
    • G06F3/0671In-line storage system
    • G06F3/0673Single storage device
    • G06F3/0674Disk device
    • G06F3/0676Magnetic disk device

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Human Computer Interaction (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Computer Security & Cryptography (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The invention relates to a method and a system for converting an MBR disk into a GPT disk, wherein the method comprises the following steps: step 1, judging whether a current computer system supports the conversion from an MBR disk to a GPT disk; step 2, judging whether the partition position on the current MBR disk supports the conversion from the MBR disk to the GPT disk; step 3, reading and storing partition information of the MBR disk; step 4, clearing partition table information of the MBR disk; step 5, initializing the MBR disk into a GPT disk; step 6, reconstructing a GPT partition table according to the partition information of the MBR disk saved in the step 3; and 7, if the MBR disk needing to be converted is the disk where the current system is located, allocating a drive letter and guiding to repair. The invention can be directly operated on a computer to realize the purpose of transferring the MBR disk to the GPT disk, and has simple and convenient operation and lower use cost.

Description

Method for converting MBR disk into GPT disk
Technical Field
The invention belongs to the field of computer disk partitioning, and particularly relates to a method for converting an MBR disk into a GPT disk.
Background
Microsoft corporation introduced a new generation of Windows8 as a PC desktop system in 2012, and microsoft corporation introduced Windows8 and used a new generation of disk Partition technology, gpt (guid Partition table), in place of mbr (master Boot record) disk Partition format, which has been used for many years. The novel GPT partition mode is more excellent in usability and expansibility compared with the traditional MBR partition mode, so that the novel GPT partition mode is gradually and more favored by consumers.
In view of the limitation that Windows itself needs to remove all partitions on an MBR disk to a GPT disk first to convert the MBR disk, the chinese patent application with application publication number CN104238952A and application publication date 2014, 12 and 24 discloses a disk partition format conversion method, which includes: reading a first disk partition table which is adaptive to a first disk partition format from a hard disk; converting the first disk partition table into a second disk partition table which is suitable for a second disk partition format according to the mapping relation between the first disk partition format and the second disk partition format; converting the hard disk from a first disk partition format to a second disk partition format; and writing the second disk partition table into the hard disk. The first disk partition format is an MBR disk partition format, the second disk partition format is a GPT disk partition format, and the MBR disk partition format can be converted into the GPT disk partition format by the method provided by the invention. But it has the following disadvantages:
1. an electronic device is required to be designed and assembled independently, a central processing unit, a storage device, a display, an input device, a disk read-write interface and a disk partition format conversion system are installed on the electronic device, when partition format conversion is required, a hard disk needs to be detached from a computer, and then the hard disk is connected with the disk read-write interface of the electronic device, and the electronic device is operated to convert an MBR (membrane bioreactor) partition format of the hard disk into a GPT (general purpose transport protocol) partition format. Obviously, when a user uses the device to convert the MBR area format of the hard disk into the GPT partition format, the hard disk on a computer needs to be detached and installed, and the operation is troublesome. And the user needs to buy one electronic device separately, so the use cost is high.
2. If the disk where the system is located (the disk where the current system is located) is converted, the boot information of the system needs to be reconfigured, and if a non-professional person has difficulty in repairing the boot configuration of the converted system, it is obvious that the probability that the system cannot be started after the conversion is very high, and the system is very prone to being down.
Disclosure of Invention
The invention provides a method for converting an MBR disk into a GPT disk, which aims to overcome the defects of the conventional method for converting the format of an MBR area of a hard disk into the format of a GPT area.
In order to solve the technical problems, the technical scheme adopted by the invention is as follows:
a method for converting an MBR disk to a GPT disk is characterized in that: the method comprises the following steps:
step 1, judging whether a current computer system supports the conversion from an MBR disk to a GPT disk;
step 2, if the MBR disk to be converted is the disk where the current system is located, judging whether the partition position on the current MBR disk supports the conversion from the MBR disk to the GPT disk; if the MBR disk needing to be converted is a disk which is not the current system, the step is not executed;
step 3, reading and storing partition information of the MBR disk, copying a necessary file to a Windows directory if the MBR disk to be converted is a disk where the current system is located, and copying the necessary file to the Windows directory if the MBR disk to be converted is a disk where the current system is not located;
step 4, clearing partition table information of the MBR disk;
step 5, initializing the MBR disk into a GPT disk;
step 6, reconstructing a GPT partition table according to the partition information of the MBR disk saved in the step 3;
and 7, if the MBR disk needing to be converted is the disk where the current system is located, allocating a drive letter and performing boot repair, and if the MBR disk needing to be converted is the disk where the current system is not located, not performing the step.
The specific judgment method in the step 1 is as follows: judging whether the disk is the disk where the current system is or is not, if not, supporting the MBR disk to GPT disk only if the current system is a Windows 200364 bit system or a system above; if the current system is the disk, the current system is a Vista 64-bit system or a system with 64 bits above, and files bootmgfw.efi and bootmgr.efi required by system Boot exist in the Windows \ Boot \ EFI directory of the current system, so that the MBR disk is supported to be converted into the GPT disk.
In step 2, if the partition position on the current MBR disk does not support the MBR disk to GPT disk, partition adjustment needs to be performed, and the specific method is as follows: judging whether a System partition and a Boot partition of a System of a current computer are separated or not; if the partition is separated, the System partition needs to be formatted into a FAT32 file System, and the type of the partition is set as an EFI partition; if the partition is not separated, whether a free space of 100MB exists after the Boot partition or not needs to be judged, if so, a FAT32 partition of 100MB is created directly at the free position after the Boot partition to be used as an EFI partition, if the free space does not exist after the Boot partition, whether the current Boot partition has enough unused space or not needs to be detected, if not, the partition adjustment fails, if the free space does not exist, the tail of the Boot partition is reduced by 100BM, and a partition of FAT32 is created by using the space of 100MB to be used as the EFI partition.
In step 2, if the partition is separated, the System partition needs to be formatted into a FAT32 file System, and the type of the partition is set as an EFI partition by configuring a GPT partition table, and the specific method is as follows: the type of the System partition is set as EFI type on GPT disk, and each item of each partition in the partition table is defined as follows:
struct GptTableItem
{
GUID PARTITIONType// the type of the partition
Unique identifier of the partition
UINT64 FirstLBA// the starting sector of the partition
UINT64 LastLBA// end sector of the partition
UINT64 Attributes of the partition
WCHAR Name [ GPT _ NAME _ SIZE ]/Name of the partition
};
The PartitionType value is set to { c12a7328-f81f-11d2-ba4b-00a0c93ec93b }, and when this entry is finally written to the partition table of the GPT disk, this partition becomes an EFI partition.
In step 3, the specific method for reading and storing partition information of the MBR disk is as follows: the read partition information of the MBR disk is uniformly managed by using DiskMgr (disk manager, hereinafter, referred to as DiskMgr), the MBR disk needing to be converted is found in the DiskMgr, and the MBR disk needing to be converted is cloned from the DiskMgr.
In step 3, in the specific method for reading and storing partition information of the MBR disk, a Recovery environment of an original System and a BCD copy required after conversion to a GPT are also required to be backed up, if the Recovery environment of the original System exists in the System partition, a Recovery directory in the System partition needs to be completely copied to a Recovery directory of a root directory of the Boot partition, and after the conversion is successful, the Recovery environment of the System is repaired to ensure the integrity of the System function.
In step 3, copying the necessary files to the Windows directory refers to copying the 2GPT _ BCD files in the installation directory to the Windows directory of the current system.
In step 4, the specific method for clearing the partition table information of the MBR disk comprises the following steps: and reading the first 34 sectors on the disk into the memory for backup, filling 0, and clearing the partition table of the MBR disk. The main purpose of clearing the MBR partition table is to keep a real partition and to indicate the disk as an empty disk, so that the later call of the translation function can be successful, and also to initialize the GPT disk partition table so as to avoid erroneous partition information caused by residual information.
In step 5, the specific method for initializing the MBR disk to the GPT disk is as follows: calling the DeviceIoControl function of Windows and transmitting the control code IOCTL _ DISK _ CREATE _ DISK, and setting the initialization parameter to PARTITION _ STYLE _ GPT.
In step 5, after the initialization parameter is set to PARTITION _ STYLE _ GPT, if the function returns successfully, the initialization is successful, and if the function call fails, the PARTITION table information backed up to the memory in step 4 is written back to the current disk, so that the integrity of the user data is ensured.
In step 6, when reconstructing the GPT partition table, if the MBR DISK to be converted is the DISK where the current system is located, manually organizing the partition table information and directly updating the partition table through the file writing function of the system, and if the MBR DISK to be converted is the DISK where the non-current system is located, directly calling the deviceiucontrol function of the system and updating the partition table by using the control code IOCTL _ DISK _ SET _ DRIVE _ LAYOUT _ EX.
In step 6, the specific method for manually organizing the partition table information and directly updating the partition table through the file writing function of the system is as follows: constructing a 128-entry GptTableItem array, wherein each entry represents a partition, writing the type, unique identification, starting sector, ending sector information, attribute and name of each partition into continuous 32 sectors starting from the 3 rd sector of the disk, and constructing and writing the GPT disk identification in a GPT head and an MBR after successful writing.
In step 7, the specific method for allocating the drive letter is as follows: and informing a MountPoint manager of Windows of registering a new device according to the Arc Number of the System partition, and then allocating a drive letter to the new device.
In step 7, the specific method for guiding repair is as follows: firstly, creating a directory with the following structure in a System partition:
EFI
┏━┻━┓
┃ ┃
Boot Microsoft
Boot
copying Windows \ Boot \ EFI \ bootmgfw.efi in the current system to an EFI \ Boot directory to rename the same as Boot x64.efi, copying all files except bootmgfw.efi in the EFI \ Boot directory to an EFI \ Microsoft \ Boot directory, copying the BCD file copied to the Windows directory in the step 3 to the EFI \ Microsoft \ Boot directory to rename the same as the BCD file name.
BCD repair: in order to solve the System boot problem, the BCD file copied to the System needs to be reconfigured according to the starting position of the current System partition, and since the BCD file is deeply ordered, the file only needs to be opened with a search key and replaced with a corresponding value;
repairing the drive letter: and finding a corresponding key value in the position of the registry HKEY _ LOCAL _ MACHINE \ SYSTEM \ MountedDevices through the reserved partition information of the original disk, updating the key value into converted data, restarting the SYSTEM after the steps are finished, and setting the starting mode of the BIOS as UEFI, thus finishing lossless conversion.
Interpretation of professional terms:
system partitioning: referred to as boot partitions.
Boot partitioning: refers to the partition in which the system is located.
In order to realize the steps, the invention provides a system for converting an MBR disk into a GPT disk, which is characterized in that: the system comprises a disk read-write module, a disk manager, a file system module and a conversion module;
the magnetic disk read-write module is used for reading and writing the magnetic disk sector;
the disk manager is used for constructing disk and partition information;
the file system module is used for providing the establishment and the size adjustment of a corresponding file system, and is responsible for establishing a FAT32 file system and adjusting the size of a Boot partition when the MBR is converted into the GPT;
and the conversion module is used for converting the MBR partition format of the disk into the GPT partition format.
The system also comprises a Native module which is used for providing display and operation environment support of the system in a Native environment.
The system also comprises a guiding and repairing module which is used for ensuring that the system can be started normally after the conversion is completed.
The system comprises a system checking module and a disk checking module, wherein the system checking module is used for judging whether the current system supports conversion of the MBR partition format of the disk into the GPT partition format, and the disk checking module is used for judging whether the current disk is the disk where the current system is located or is not the disk where the current system is located.
Compared with the prior art, the invention has the following beneficial effects:
the method provided by the invention can be directly operated on a computer to realize the purpose of converting the MBR disk into the GPT disk, does not need a user to detach the disk from the computer for conversion, and is installed on the computer after the conversion is finished, so that the time and labor are saved, and the use is very convenient for the user. The invention also provides a system for converting the MBR disk into the GPT disk, the steps can be realized by installing the system on a computer, and after the installation is finished, a user can realize automatic conversion only by selecting the MBR disk to be converted, and the operation is simple and convenient. Because the invention is a pure software structure, other hardware does not need to be installed and purchased, and the use cost is greatly reduced compared with the prior art. The invention automatically realizes the restoration of the system guide information after the conversion is finished, and the user does not need to resort to the equal three parties or manually restore the system by himself, thereby greatly saving the time cost and improving the stability of the system.
Drawings
FIG. 1 is a process flow diagram of the present invention.
Detailed Description
The present invention will be further described with reference to the following examples, which are intended to illustrate only some, but not all, of the embodiments of the present invention. Based on the embodiments of the present invention, other embodiments used by those skilled in the art without any creative effort belong to the protection scope of the present invention.
The invention provides a method for directly converting an MBR disk to a GPT disk on a computer, which comprises the following steps:
step 1, judging whether a current computer system supports MBR disk-to-GPT disk conversion, wherein the specific judgment conditions are as follows:
judging whether the disk is the disk where the current system is or is not (manually or automatically), if not, supporting the MBR disk to GPT disk only if the current system is a Windows 200364 bit system or more; if the current system is the disk where the current system is located, the current system is a Vista 64-bit system or a system with 64 bits above, and files bootmgfw.efi and bootmgr.efi required by system Boot exist in a Windows \ Boot \ EFI directory of the current system, so that the MBR disk is supported to be converted into a GPT disk;
step 2, judging whether the partition position on the current disk supports the conversion from the MBR disk to the GPT disk, if so, entering the step 3, otherwise, executing partition adjustment, if the adjustment is successful, entering the step 3, and if the adjustment is failed, ending the operation; executing the step only if the current disk is the disk where the current system is located, and not executing the step if the current disk is the disk where the non-current system is located;
the specific method for executing partition adjustment comprises the following steps: judging whether a System partition and a Boot partition of a System of a current computer are separated or not; if the partition is separated, the System partition needs to be formatted into a FAT32 file System, and the type of the partition is set as an EFI partition in a mode of configuring a GPT partition table; if the partition is not separated, whether a free space of 100MB exists after the Boot partition or not needs to be judged, if so, a FAT32 partition of 100MB is directly established at the free position after the Boot partition to be used as an EFI partition, if the free space does not exist after the Boot partition, whether the current Boot partition has enough unused space or not needs to be detected, if not, the partition adjustment fails, if the free space does not exist, the tail of the Boot partition is reduced by 100BM, and a partition of FAT32 is established to be used as the EFI partition;
the type of the partition is set as an EFI partition by configuring a GPT partition table, and the specific method comprises the following steps: the type of the System partition is set as EFI type on GPT disk, and each item of each partition in the partition table is defined as follows:
struct GptTableItem
{
GUID PARTITIONType// the type of the partition
Unique identifier of the partition
UINT64 FirstLBA// the starting sector of the partition
UINT64 LastLBA// end sector of the partition
UINT64 Attributes of the partition
WCHAR Name [ GPT _ NAME _ SIZE ]/Name of the partition
};
Setting the PartitionType value to { c12a7328-f81f-11d2-ba4b-00a0c93ec93b }, the partition becomes an EFI partition when the entry is finally written into the partition table of the GPT disk;
step 3, reading and storing partition information of the MBR disk, copying a necessary file to a Windows directory if the MBR disk to be converted is a disk where the current system is located, and copying the necessary file to the Windows directory if the MBR disk to be converted is a disk where the current system is not located;
the specific method for reading and storing the partition information of the MBR disk comprises the following steps: uniformly managing the read partition information of the MBR disk by using DiskMgr (disk manager, hereinafter referred to as DiskMgr), finding an MBR disk needing to be converted in the DiskMgr, cloning the MBR disk needing to be converted from the DiskMgr, and cloning the disk needing to be converted from the DiskMgr, wherein the main purpose is to restore a partition table suitable for the GPT disk after the original disk partition information is stored and is convenient to convert successfully;
in the specific method for reading and storing the partition information of the MBR disk, the Recovery environment of the original System and the BCD copy required after conversion to the GPT are also required to be backed up, if the Recovery environment of the original System exists in the System partition, the Recovery directory in the System partition needs to be completely copied into the Recovery directory of the root directory of the Boot partition, and after the conversion is successful, the Recovery environment of the System is repaired, so that the integrity of the System function is ensured.
Copying the necessary files to the Windows directory means copying the 2GPT _ BCD files in the installation directory to the Windows directory of the current system;
and 4, clearing partition table information of the MBR disk, specifically: reading the first 34 sectors (the continuous 34 sectors starting from the 1 st sector of the disk) on the disk into the memory for backup, filling 0, and clearing the partition table of the MBR disk. The main purpose of clearing the MBR partition table is to keep a real partition and to indicate the disk as an empty disk, so that the later call of the translation function can be successful, and also to initialize the GPT disk partition table so as to avoid erroneous partition information caused by residual information.
Step 5, calling an initialization function of a system of the computer to reinitialize the current MBR disk into the GPT disk, specifically: calling a DeviceIoControl function of Windows and transmitting a control code IOCTL _ DISK _ CREATE _ DISK, setting an initialization parameter as PARTITION _ STYLE _ GPT, if the function returns success, the initialization is successful, and if the function call fails, the PARTITION table information backed up to the memory in the step 4 is written back to the current DISK to ensure the integrity of user data;
step 6, reconstructing a GPT partition table according to the partition information of the MBR disk saved in the step 3; if the MBR DISK needing to be converted is the DISK where the current system is located, manually organizing partition table information and directly updating the partition table through a file writing function of the system, and if the MBR DISK needing to be converted is a DISK where the non-current system is located, directly calling a DeviceIoControl function of the system and updating the partition table by using a control code IOCTL _ DISK _ SET _ DRIVE _ LAYOUT _ EX; the specific method for manually organizing the partition table information and directly updating the partition table through the file writing function of the system comprises the following steps: constructing a 128-entry GptTableItem array, wherein each entry represents a partition, writing the type, unique identification, starting sector, ending sector information, attribute and name of each partition into continuous 32 sectors starting from the 3 rd sector of the disk, and constructing and writing the identifiers of the GPT disk in a GPT head and an MBR after successful writing;
step 7, if the MBR disk needing to be converted is the disk where the current system is located, disk symbols are required to be distributed and boot repair is required, and if the MBR disk needing to be converted is the disk where the current system is not located, the step is not executed;
in step 7, the specific method for allocating the drive letter is as follows: informing a MountPoint manager of Windows to register new equipment according to the Arc Number of the System partition, and then distributing a drive letter for the new equipment;
in step 7, the specific method for guiding repair is as follows: firstly, creating a directory with the following structure in a System partition:
EFI
┏━┻━┓
┃ ┃
Boot Microsoft
Boot
copying Windows \ Boot \ EFI \ bootmgfw.efi in the current system to an EFI \ Boot directory to rename the same as Boot x64.efi, copying all files except bootmgfw.efi in the EFI \ Boot directory to an EFI \ Microsoft \ Boot directory, copying the BCD file copied to the Windows directory in the step 3 to the EFI \ Microsoft \ Boot directory to rename the same as a BCD file name;
BCD repair: in order to solve the System boot problem, the BCD file copied to the System needs to be reconfigured according to the starting position of the current System partition, and since the BCD file is deeply ordered, the file only needs to be opened with a search key and replaced with a corresponding value;
repairing the drive letter: and finding a corresponding key value in the position of the registry HKEY _ LOCAL _ MACHINE \ SYSTEM \ MountedDevices through the reserved partition information of the original disk, updating the key value into converted data, restarting the SYSTEM after the steps are finished, and setting the starting mode of the BIOS as UEFI, thus finishing lossless conversion.
In order to realize the steps, the invention provides a system for converting an MBR disk into a GPT disk, which is characterized in that: the system comprises a disk read-write module, a disk manager, a file system module and a conversion module;
the magnetic disk read-write module is used for reading and writing the magnetic disk sector;
the disk manager is used for constructing disk and partition information;
the file system module is used for providing the establishment and the size adjustment of a corresponding file system, and is responsible for establishing a FAT32 file system and adjusting the size of a Boot partition when the MBR is converted into the GPT;
and the conversion module is used for converting the MBR partition format of the disk into the GPT partition format.
The system also comprises a Native module which is used for providing display and operation environment support of the system in a Native environment.
The system also comprises a guiding and repairing module which is used for ensuring that the system can be started normally after the conversion is completed.
The system comprises a system checking module and a disk checking module, wherein the system checking module is used for judging whether the current system supports conversion of the MBR partition format of the disk into the GPT partition format, and the disk checking module is used for judging whether the current disk is the disk where the current system is located or is not the disk where the current system is located.

Claims (4)

1. A method for converting an MBR disk to a GPT disk is characterized in that: the method comprises the following steps:
step 1, judging whether a current computer system supports the conversion from an MBR disk to a GPT disk;
step 2, if the MBR disk to be converted is the disk where the current system is located, judging whether the partition position on the current MBR disk supports the conversion from the MBR disk to the GPT disk; if the MBR disk needing to be converted is a disk which is not the current system, the step is not executed;
step 3, reading and storing partition information of the MBR disk, copying a necessary file to a Windows directory if the MBR disk to be converted is a disk where the current system is located, and copying the necessary file to the Windows directory if the MBR disk to be converted is a disk where the current system is not located;
step 4, clearing partition table information of the MBR disk;
step 5, initializing the MBR disk into a GPT disk;
step 6, reconstructing a GPT partition table according to the partition information of the MBR disk saved in the step 3;
step 7, if the MBR disk needing to be converted is the disk where the current system is located, disk symbols are required to be distributed and boot repair is required, and if the MBR disk needing to be converted is the disk where the current system is not located, the step is not executed;
the specific judgment method in the step 1 is as follows: judging whether the disk is the disk where the current system is or is not, if not, supporting the MBR disk to GPT disk only if the current system is a Windows 200364 bit system or a system above; if the current system is the disk where the current system is located, the current system is a Vista 64-bit system or a system with 64 bits above, and files bootmgfw.efi and bootmgr.efi required by system Boot exist in a Windows \ Boot \ EFI directory of the current system, so that the MBR disk is supported to be converted into a GPT disk;
in step 2, if the partition position on the current MBR disk does not support the MBR disk to GPT disk, partition adjustment needs to be performed, and the specific method is as follows: judging whether a System partition and a Boot partition of a System of a current computer are separated or not; if the partition is separated, the System partition needs to be formatted into a FAT32 file System, and the type of the partition is set as an EFI partition; if the partition is not separated, whether a free space of 100MB exists after the Boot partition or not needs to be judged, if so, a FAT32 partition of 100MB is directly established at the free position after the Boot partition to be used as an EFI partition, if the free space does not exist after the Boot partition, whether the current Boot partition has enough unused space or not needs to be detected, if not, the partition adjustment fails, if the free space does not exist, the tail of the Boot partition is reduced by 100MB, and a partition of FAT32 is established to be used as the EFI partition;
in step 3, the specific method for reading and storing partition information of the MBR disk is as follows: uniformly managing the read partition information of the MBR disk by using DiskMgr, finding the MBR disk to be converted in the DiskMgr, cloning the MBR disk to be converted from the DiskMgr, then backing up the Recovery environment of the original System and copying a BCD required after the conversion to GPT, if the Recovery environment of the original System exists in the System partition, copying all Recovery directories in the System partition to the Recovery directory of the root directory of the Boot partition, and repairing the Recovery environment of the System after the conversion is successful to ensure the integrity of the System function;
in step 7, the specific method for guiding repair is as follows: firstly, creating a structure directory in a System partition:
copying Windows \ Boot \ EFI \ bootmgfw.efi in the current system to an EFI \ Boot directory to rename the same as Boot x64.efi, copying all files except bootmgfw.efi in the EFI \ Boot directory to an EFI \ Microsoft \ Boot directory, copying the BCD file copied to the Windows directory in the step 3 to the EFI \ Microsoft \ Boot directory to rename the same as the BCD file name.
2. The method for converting an MBR disk to a GPT disk according to claim 1, wherein: in step 5, the specific method for initializing the MBR disk to the GPT disk is as follows: calling the DeviceIoControl function of Windows and transmitting the control code IOCTL _ DISK _ CREATE _ DISK, and setting the initialization parameter to PARTITION _ STYLE _ GPT.
3. The method for converting an MBR disk to a GPT disk according to claim 2, wherein: in step 5, after the initialization parameter is set to PARTITION _ STYLE _ GPT, if the function returns successfully, the initialization is successful, and if the function call fails, the PARTITION table information backed up to the memory in step 3 is written back to the current disk, so that the integrity of the user data is ensured.
4. The method for converting an MBR disk to a GPT disk according to claim 1, wherein: in step 7, the specific method for allocating the drive letter is as follows: and informing a MountPoint manager of Windows of registering a new device according to the Arc Number of the System partition, and then allocating a drive letter to the new device.
CN201810564939.9A 2018-06-04 2018-06-04 Method for converting MBR disk into GPT disk Active CN108829351B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201810564939.9A CN108829351B (en) 2018-06-04 2018-06-04 Method for converting MBR disk into GPT disk

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201810564939.9A CN108829351B (en) 2018-06-04 2018-06-04 Method for converting MBR disk into GPT disk

Publications (2)

Publication Number Publication Date
CN108829351A CN108829351A (en) 2018-11-16
CN108829351B true CN108829351B (en) 2021-10-12

Family

ID=64144000

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201810564939.9A Active CN108829351B (en) 2018-06-04 2018-06-04 Method for converting MBR disk into GPT disk

Country Status (1)

Country Link
CN (1) CN108829351B (en)

Families Citing this family (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112445677B (en) * 2019-09-04 2024-06-18 中国石油化工股份有限公司 Health state checking and repairing method and storage medium for computer cluster
CN112328287B (en) * 2020-11-24 2024-05-03 杭州海康威视数字技术股份有限公司 Method, device, equipment and storage medium for updating embedded equipment system
CN112416657B (en) * 2020-12-09 2023-05-09 成都傲梅科技有限公司 System cloning method
CN114924914B (en) * 2022-05-31 2023-04-25 广州鼎甲计算机科技有限公司 Disk partition table information backup and recovery method and system

Citations (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102591691A (en) * 2011-12-31 2012-07-18 曙光信息产业股份有限公司 Hard disc starting method and operation system starting and loading method based on basic input/output system (BIOS)
CN103268241A (en) * 2013-05-28 2013-08-28 山东超越数控电子有限公司 Method for achieving hiding or display of hard disk partitions in BIOS
CN104238952A (en) * 2013-06-06 2014-12-24 鸿富锦精密工业(武汉)有限公司 Magnetic disk partition format switching method and system
CN104348902A (en) * 2013-07-23 2015-02-11 英特尔公司 Techniques for moving data between a network input/output device and a storage device
CN105446758A (en) * 2014-08-29 2016-03-30 昆达电脑科技(昆山)有限公司 Method for installing operating system
EP3057270A1 (en) * 2015-02-12 2016-08-17 Intel Corporation Technologies for modular forwarding table scalability
CN107193506A (en) * 2017-06-22 2017-09-22 山东超越数控电子有限公司 A kind of implementation method for kylin system root partition dilatation of getting the bid
CN107436761A (en) * 2017-07-01 2017-12-05 武汉噢易云计算股份有限公司 The management method that UEFI systems based on UEFI mainboards coexist with legacy system
CN107870739A (en) * 2017-03-15 2018-04-03 珠海市杰理科技股份有限公司 Disk file storage method and system

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US9304703B1 (en) * 2015-04-15 2016-04-05 Symbolic Io Corporation Method and apparatus for dense hyper IO digital retention
CN105912428B (en) * 2016-05-20 2019-01-08 上海数腾软件科技股份有限公司 Realize that source data is converted into the system and method for virtual machine image in real time

Patent Citations (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102591691A (en) * 2011-12-31 2012-07-18 曙光信息产业股份有限公司 Hard disc starting method and operation system starting and loading method based on basic input/output system (BIOS)
CN103268241A (en) * 2013-05-28 2013-08-28 山东超越数控电子有限公司 Method for achieving hiding or display of hard disk partitions in BIOS
CN104238952A (en) * 2013-06-06 2014-12-24 鸿富锦精密工业(武汉)有限公司 Magnetic disk partition format switching method and system
CN104348902A (en) * 2013-07-23 2015-02-11 英特尔公司 Techniques for moving data between a network input/output device and a storage device
CN105446758A (en) * 2014-08-29 2016-03-30 昆达电脑科技(昆山)有限公司 Method for installing operating system
EP3057270A1 (en) * 2015-02-12 2016-08-17 Intel Corporation Technologies for modular forwarding table scalability
CN107870739A (en) * 2017-03-15 2018-04-03 珠海市杰理科技股份有限公司 Disk file storage method and system
CN107193506A (en) * 2017-06-22 2017-09-22 山东超越数控电子有限公司 A kind of implementation method for kylin system root partition dilatation of getting the bid
CN107436761A (en) * 2017-07-01 2017-12-05 武汉噢易云计算股份有限公司 The management method that UEFI systems based on UEFI mainboards coexist with legacy system

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
《免重装系统 手把手教你MBR转GPT分区表》;张伟;《中关村在线》;20161020;第1-5页、图1-9 *

Also Published As

Publication number Publication date
CN108829351A (en) 2018-11-16

Similar Documents

Publication Publication Date Title
CN108829351B (en) Method for converting MBR disk into GPT disk
US6012130A (en) Method and apparatus for automated disk drive upgrades
US6851073B1 (en) Extensible system recovery architecture
US6820214B1 (en) Automated system recovery via backup and restoration of system state
US6317845B1 (en) System for computer recovery using removable high capacity media
US6934722B1 (en) Method of finding application components in an intelligent backup and restoring system
CN100458699C (en) Method and system for updating fastener
US7334157B1 (en) Restore of data to a computer system having different hardware
US9075758B2 (en) Removable storage device with transactional operation support and system including same
CN105446826A (en) Virtual machine backup and recovery method and device
US20050235281A1 (en) Combined software installation package
US6374366B1 (en) Automated drive repair systems and methods
JP2006244484A (en) System and method for using file system to automatically backup file as generational file
JP2006286001A (en) Use of USB memory devices for operating system recovery
US20070220304A1 (en) Restoring a client device
CN100403271C (en) How to backup and restore data
US20040221024A1 (en) Apparatus and method for setting environment of client in client / server system, and program recording medium therefor
CN113342365A (en) Operating system deployment method, device, equipment and computer-readable storage medium
US20070294332A1 (en) Processing device for end customer operation
CN104077196A (en) Linux boot failure recovering method and device
US20120260049A1 (en) Cloning method and system
CN112069435A (en) A method and system for switching nginx configuration files through scripts
CN108845766B (en) Method for converting GPT disk into MBR disk
US20060069902A1 (en) Method for recovering operating system and user data executed in a computer and its recovery system thereof
US8990618B2 (en) Partial fault tolerance in an embedded appliance

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant