Score:0

converting MBR disk with UEFI boot to GPT

mv flag

I have a MBR disk which I want to convert to GPT without losing my data and OSs (ubuntu and Manjaro) (my boot is UEFI not BIOS)

this is my fdisk -l /dev/sdb output :

Disk /dev/sdb: 931.51 GiB, 1000204886016 bytes, 1953525168 sectors
Disk model: TOSHIBA DT01ACA1
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: dos
Disk identifier: 0x0ec008e9

Device     Boot      Start        End   Sectors   Size Id Type
/dev/sdb1  *          2048    1026047   1024000   500M  b W95 FAT32
/dev/sdb2        204802048 1031114751 826312704   394G  7 HPFS/NTFS/exFAT
/dev/sdb3       1031116798 1418209279 387092482 184.6G  5 Extended
/dev/sdb4       1418209280 1953520064 535310785 255.3G 83 Linux
/dev/sdb5       1031116800 1206896639 175779840  83.8G 83 Linux
/dev/sdb6       1206898688 1222897663  15998976   7.6G 82 Linux swap / Solaris
/dev/sdb7       1222899712 1418209279 195309568  93.1G 83 Linux

Partition 3 does not start on physical sector boundary.
Partition table entries are not in disk order.

sdb1 is my ESP partition

sdb3 is my extended partion that contains sdb5 sdb6 and sdb7 (ubuntu root, swap and home partitions)

sdb4 is my Manjaro OS partition


how can i do it?

ar flag
Which one is the Ubuntu partition?
zwets avatar
us flag
Have you tried looking for solutions already? E.g. [this](http://www.rodsbooks.com/gdisk/mbr2gpt.html) looks like it would do exactly what you want.
The Second avatar
mv flag
@user68186 sdb5 sdb6 and sdb7 (ubuntu root, swap and home partitions)
The Second avatar
mv flag
@zwets yea but everything i founf is about converting MBR/BIOS to GPT/UEFI...i have MBR/UEFI which I want to convert to GPT/UEFI
oldfred avatar
cn flag
You need good backups of all your data. Also backup partition table. And plan to reinstall grub and edit fstab with new UUIDs. Converting to or from GPT - must have good backups. http://www.rodsbooks.com/gdisk/mbr2gpt.html
The Second avatar
mv flag
@oldfred so i dont need to create new esp partition,right?
oldfred avatar
cn flag
The ESP partition should also convert but will have new UUID & GUID/partUUID. UEFI uses GUID to know partiiton. But update of fstab to new UUIDs & full reinstall of grub so UEFI entry uses new GUID/partUUID. Backup partition table with sfdisk. Backup fstab, `sudo efibootmgr -v` & copy of `lsblk -e 7 -o name,mountpoint,label,size,fstype,uuid,partuuid ` Then after conversion check lsblk of `sudo blkid` again & update fstab. Then total reinstall of grub and check that efibootmgr shows new partUUID. Any place else using UUID or guid may need updates.
The Second avatar
mv flag
@oldfred...ok tnx...so the point is replacing old MBR partition's UUID with new GPT UUID on fstab and reinstalling grub ...tnx mate
Score:1
jp flag

A preliminary note: I'm the author of GPT fdisk (gdisk), so I understand what it does pretty well.

First, when doing any sort of maintenance at this level, backups are critical! Before you do anything else, you should create backups that will enable you to re-create your system if things go phenomenally badly, because in some cases, things do go phenomenally badly. Keeping backups is a good idea in general, and it's imperative if you're about to do something risky.

Second, your question doesn't specify why you want to do this. The answer to that question is important. As the saying goes, "if it ain't broke, don't fix it." If it simply offends your sensibility that you're booting from an MBR disk, then it's probably not worth the risk. Even with an adequate backup, restoring everything if things go wrong will be much more of a hassle than learning to live with your sensibility being offended. OTOH, if you're having problems of some sort, then it's possible that converting your MBR disk to a GPT disk will fix the problems; but without knowing what problems you're experiencing, I can't offer any opinion on whether this will actually help, or if there might be an easier way to fix the problem.

Third, the gdisk command will do the actual MBR-to-GPT conversion; see its documentation on this type of conversion for details. Since you're already booting in EFI mode, the boot loaders on your /dev/sdb1 will be unchanged; however:

  • The NVRAM-resident boot loader definitions that point to those boot loaders are likely to need to change, so the system might stop booting until you change them. OTOH, if you have the Linux fallback loader installed as EFI\BOOT\bootx64.efi, then recovery may be automatic, depending on how the EFI responds. On the other-other hand, you may need to be prepared with a Boot Repair disk, rEFInd on a USB flash drive, or some other emergency recovery plan.
  • Depending on how you have /etc/fstab and your boot loader configured, you may need to adjust configurations. The filesystem names and UUIDs will remain unchanged from this shift, but the partition names and GUIDs will change. (Technically, MBR doesn't support either partition names or partition GUIDs, but some tools try to create stand-ins for these values.) AFAIK, Ubuntu sets up /etc/fstab in ways that shouldn't need changing by default, but I don't know about the GRUB configuration; that might need fixing post-change. Also, of course, if you've made any non-standard changes to /etc/fstab or your boot loader, there may be changes required as as result.
  • The type code for your /dev/sdb1 is currently 0x0b, which gdisk will translate to its 0700. This is technically incorrect for an ESP, so you may want to change it to EF00. (For that matter, 0x0b is incorrect for an ESP on an MBR disk. In theory, it should be changed to 0xef if you leave the disk using MBR. In fact, depending on why you want to make the change to GPT, changing the type code on /dev/sdb1 might be all you need to do.)

Fourth, I see you've got a big Windows NTFS partition on /dev/sdb. If you're currently booting Windows from a partition on a GPT /dev/sda, then I'm guessing that the NTFS partition on /dev/sdb is a data partition. If so, then it should continue working in Windows after this change. Windows normally ties its partition table type to its boot mode, though, so if you're doing something else -- like if you're booting Windows in BIOS/CSM/legacy mode from /dev/sdb2 -- then changing /dev/sdb from MBR to GPT could render Windows unbootable.

The Second avatar
mv flag
Thank you very much for your time 1.i have backup 2.no idont have any problem, but i have some free space that cant create partition with it... (i already have 4 and cant create more on MBR) 3.i have fallback on Manjaro 4.uh no i haven't windows...i had but not now and sdb2 was belong to that and sda is my ventoy disk .... i have a concern about sdb3 (extended partition)...how does converting affect this?
jp flag
There is no conception of extended partitions in GPT. Both primary and logical partitions are converted to just-plain-partitions in GPT, and the extended partition *per se* becomes useless and so is discarded. Its contents (your logical partitions) are preserved, though.
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.