- How To Convert A Disk From GPT To MBR On Linux?
- Steps to convert a disk from GPT to MBR
- Step 1: List and identify the disk
- Step 2: Run the gdisk tool
- Step 3: Use the recovery and transformation options
- Conclusion
- Related apps
- 4 comments on «How To Convert A Disk From GPT To MBR On Linux?»
- Converting between GPT and MBR hard drive without losing data
- 3 Answers 3
- MBR to GPT
- GPT to MBR
- For Information
- Making your drive bootable
- Remove GPT — Default back to MBR
- 5 Answers 5
How To Convert A Disk From GPT To MBR On Linux?
The firmware interface is a way by which firmware interacts with the operating system. The BIOS is the usual firmware interface while UEFI is the newer one that has some additional features.
MBR uses the standard BIOS partition table while GPT uses Unified Extensible Firmware Interface (UEFI). Using a GPT disk has various advantages over MBR disk, for instance, you can create more than four primary partitions on a GPT disk. Also, the GPT disk is required if the size of a disk is greater than 2 TB.
But in the older systems that come with BIOS only, you can not boot using GPT disk directly instead first you need to convert the GPT disk into MBR only then you can use it.
Ahead in this article, steps are given to convert a disk from GPT to MBR on Linux.
Steps to convert a disk from GPT to MBR
For converting a disk from GPT to MBR we will use gdisk tool. If it is not in your system then first you need to install it. Use the following command to install gdisk in your system-
And then follow the steps given below-
Note: Before converting a disk from GPT to MBR backup any data on it.
Step 1: List and identify the disk
Use the command that is given below to list the disk available in your system –
Scroll and identify the disk that is to be converted from GPT to MBR in the output of this command.
Step 2: Run the gdisk tool
Now run the following command in the terminal –
Where sda1 is the disk to convert from GPT to MBR. You can see the result of the partition table scan on this disk GPT is present on it.
This will ask you to enter the name of the disk, enter the disk name and then press the return key. It also displays the partitioning scheme available on the disk.
Note:- Here /dev/sda1 is not a partition it is a separate disk, replace /dev/sda1 with the correct drive name on your system for example it could be /dev/sda on your system.
Step 3: Use the recovery and transformation options
Now enter r and then press the return key. Enter the g to convert the disk from GPT to MBR. Next, use the w to write the partition table.
Press the y if asked to accept.
Now the conversion is successful you can verify this by running the following command in the terminal –
As you can see the partition table on this disk is MBR only.
Conclusion
By following this you successfully converted the GPT disk into MBR. Now if you have a query on this then write us in the comments section.
Related apps
4 comments on «How To Convert A Disk From GPT To MBR On Linux?»
This saved me SOOOOO much time. Thank you so much for this. I had a terabyte of data on a drive that was GPT formatted in linux to NTFS that then would not read in Windows. Converting it to MBR let it now work in both without spending hours copying then re-copying back.
This is wrong and actively harmful. You need to gdisk /dev/sda, not sda1 – in other words, you need to give it the block device for the entire disk, not a single partition.
Thanks reinderien for pointing this out.
Actually, I demonstrated this guide on a virtual machine with a USB drive which is listed as sda1 on it. I did not know that it could confuse many readers. By the way I added a separate note for this.
Converting between GPT and MBR hard drive without losing data
NOTE: I don’t know a lot about hard drives so you’re going to have to work with me here. My question: Can I change my hard drive from GPT to MBR without losing data on it? NOTE: there isn’t an operating system on the laptop which I’m going to do this on. I’m going to boot from a USB and try to convert it.
Converting is not possible. You have to remove the partition and create a new one. GPT is superior to MBR though, so I would keep GPT. One of the limits of MBR is the maximum size a partition can be. I believe 2 TB is its limit.
It’s true that GPT is superior to MBR, therefore many partition layouts cannot be converted to MBR; but some layouts can. Post the result of Linux command gdisk -l /dev/sdX (substitute sdX with your HDD) so we can tell more.
Why do you want to do this conversion? It may not be necessary, and in fact may be quite inadvisable. OTOH, there are some legitimate reasons to want to do this (such as if you want to use the disk with a GPT-unaware OS).
3 Answers 3
You can convert from GPT to MBR and MBR to GPT without data loss (I have tried that) with gdisk in Linux.
Run command gdisk /dev/sdx with sdx as per your HDD partition
GPT fdisk (gdisk) version 1.0.1 Partition table scan: MBR: MBR only BSD: not present APM: not present GPT: not present *************************************************************** Found invalid GPT and valid MBR; converting MBR to GPT format. THIS OPERATION IS POTENTIALLY DESTRUCTIVE! Exit by typing 'q' if you don't want to convert your MBR partitions to GPT format! *************************************************************** Command (? for help):
MBR to GPT
Enter w to write GPT partition on disk.
Press y to confirm your choice.
GPT to MBR
Enter r to enter in recovery and transformation options.
Enter g to convert GPT to MBR partition.
For Information
You can check table by command p.
Warning: You will lose your boot loader (Ex. GRUB)
You can check if your partition is GPT or MBR now gdisk /dev/sdx with sdx as per your HDD partition in Partition table scan(p)
Something’s not right. In gdisk recovery and transformation options the g option will only recreate the protective MBR on top of the GPT but not actually convert the disk to GPT. The right way to convert a GPT disk to MBR is using fdisk o option but it does destroy data on the disk.
I observed this behaviour with gdisk v1.0.3 and fdisk from util-linux 2.33.1 when I was trying to convert an empty GPT disk (no partitions) to MBR
«Converting» MBR to GPT this way (from a terminal in GParted or some other live distro) is good enough to get Windows 10 to install in UEFI mode, so even if it’s not 100% right it’s just what I need. (I care about keeping data because I dumped the disk structure from an old machine using Clonezilla and then am putting the new Win 10 in unallocated space.)
This successfully converted my disk back to MBR but did not mark the Windows partition as Active and the disk was not bootable. I ended up using DISM to clone the Windows partition after doing a fresh install to restore the structure of the disk while preserving data.
Making your drive bootable
This is an enhancement to the information provided by Krunal and clarkttfu with more details on the steps to create a BIOS boot partition and install grub to it.
If you are changing the partition table on a a boot drive you will need to create a new «BIOS boot partition» for grub to store the bootloader in. These examples use the drive /dev/sda which will usually be the boot drive.
First, validate that there is space before the current first partition to support a boot partition, fisk -l should show that the first partition starts at sector 2048:
johnf@ubuntu:~$ sudo fdisk -l /dev/sda [. ] Device Boot Start End Sectors Size Id Type /dev/sda1 * 2048 499711 497664 243M 83 Linux /dev/sda2 501758 125829119 125327362 59.8G 5 Extended /dev/sda5 501760 125829119 125327360 59.8G 8e Linux LVM
If it does then you have the space required to create the partition. If it doesn’t you cannot follow these instructions and have a bootable system.
Use gdisk to convert the partition to gpt, you can now create a new partition for your MBR, run sudo gdisk /dev/sd, enter n to create a new partition, accept the proposed partition number, you should be able to select a first sector of 34, set the partition type of ef02:
Command (? for help): n Partition number (2-128, default 2): First sector (34-4294967262, default = 4294922240) or size: 34 Last sector (34-2047, default = 2047) or size: Current type is 'Linux filesystem' Hex code or GUID (L to show codes, Enter = 8300): ef02 Changed type of partition to 'BIOS boot partition'
You can now write your partition table with w . Run partprobe again and then install grub:
johnf@ubuntu:~$ sudo partprobe johnf@ubuntu:~$ sudo grub-install /dev/sda Installing for i386-pc platform. Installation finished. No error reported.
You should now be able to reboot your machine without issue.
Remove GPT — Default back to MBR
But when I get to the mklabel option it spits out a warning that I will lose all data on /dev/sda . Is there a way to get the normal MBR back without formatting the disk?
If you are formatting the drive, try this: blog.gnub.net/2009/03/die-gpt-die.html (sorry don’t have reputation to put in an answer!)
5 Answers 5
That link you posted looks like a very ugly hack type solution.
However, according to the man page, gdisk , which is used to convert MBR -> GPT, also has an option in the «recovery & transformation» menu (press r to get that) to convert GPT -> MBR; the g key will:
Convert GPT into MBR and exit. This option converts as many partitions as possible into MBR form, destroys the GPT data structures, saves the new MBR, and exits. Use this option if you’ve tried GPT and find that MBR works better for you. Note that this function generates up to four primary MBR partitions or three primary partitions and as many logical partitions as can be generated. Each logical partition requires at least one unallocated block immediately before its first block.
@jordanm: I haven’t done this myself (which is why I admit «google implies»), but since gdisk apparently has an explicit means, why do you believe it is risky? The gdisk man page for the r -> g option does not have any caveats at all.
It’d improve this answer if you were to inline the required gdisk step into your answer. Especially with how short the step is. Never know when the link may go dead, leaving the answer useless.
@TomášZato you need to press r first to get to the recovery and transformation options (experts only) submenu
Most of the previous respondents are correct when they say that you can usually do what you need with a GPT partition table layout, but since there are valid reasons for wanting to use MBR, I think I will just answer your question instead of assuming you are wrong for asking.
To get rid of the GPT, you need to remember that with this format, there is a partition table written to the end of the drive, where it will remain if you just try to delete it with fdisk or a non-GPT aware file system tool. What you did with parted did not address this partition table.
To erase GPT, you need to use something like gdisk. Enter gdisk as root at the prompt, and then tell gdisk what device you want to look at (i.e. /dev/sd??). Use gdisk to write a protective MBR to the disk just to make sure you have access to some MBR data structure. Then you can navigate to the expert options section (press ? at the different program prompts to see the options available to you at different times) and find the option that says «Zap (destroy) the GPT data structures and exit.» The program will prompt for confirmation, then ask you if you want to preserve the MBR structure. Do preserve this.
After that, it should be as simple as rebooting your computer (because the kernel will still be using the old partition table and it needs a restart to update), and then firing up fdisk and deleting the remnant of the GPT partition. You will still see the same warning about using GNU Parted that you saw before, but you can ignore it this time, as it will go away when you delete the partition.
This will give you an MBR partition table system on a blank drive onto which you can reinstall an OS. If you are attempting to do this with existing partitions, it is quite a bit more complicated and in some cases not even possible, so I would recommend that you simply back up your data and do it this way.