Converting drive from mbr to gpt

I posted this of Reddit a while ago but didn’t realize that was unofficial so I’m uploading this here:

My main issue is that I wanted to Dual Boot Windows 11 from GRUB. Windows 11 is installed on a separate drive in the gpt partition label format while EndeavorOS was on the mbr format. mbr only supports Legacy BIOS booting while gpt supports UEFI booting only. Since GRUB is on my mbr drive, I am unable to boot OSs using the UEFI standard. I did not want to reinstall my system since I spent a long time setting it up and I wanted to launch grub from this drive specifically.

My best option to fix this and improve the security and longevity of my OS install is by upgrading the partition table on my EndeavorOS install. If you have the same issue, feel free to follow along.

Find the drive you want using: sudo fdisk -l You can also confirm if it is using gpt or dos disklabel types. My drive is under: /dev/nvme1n1

Now start by upgrading the partition tables using the following command while booted into my OS: sgdisk -g /dev/nvme1n1 Verify with: fdisk -l /dev/nvme1n1 Sources: https://wiki.archlinux.org/title/GPT_fdisk, https://wiki.archlinux.org/title/EFI_system_partition

Then I had to create new partitions. However, my drive was already fully allocated between my my main endeavorOS partition of 1.8TB and a 20GB swap partition. I needed to shrink the main EndeavorOS partition. To do this I needed to boot into a live environment since I cannot unmount a drive in use.

Boot into live environment from EndeavorOS USB. Open KDE partition manager or Gparted whichever you prefer. Both are GUIs and can easily modify the partitions (You can install gparted using: sudo pacman -S gparted)

Taking from the main partition I gave ~1GB of space for this new partition. You can verify if this partition was made correctly using: fdisk -l /dev/nvme1n1

Then run fdisk so you can modify the created partition: fdisk /dev/nvme1n1p3

Change the partition type to EFI system using: ‘t’ command Select EFI file system (Should be the first option) Then print changes with the ‘p’ command If good then write and exit with the ‘w’ command Source: https://wiki.archlinux.org/title/Fdisk

I then needed to format the partition using: mkfs.fat -F 32 /dev/nvme1n1p3 This formats the partition into the fat32 file system. You can visualize the change under KDE partition manager too. Source: https://wiki.archlinux.org/title/EFI_system_partition

I then had to mount EFI system partition. But I wanted to mount it under /efi for the reasons stated in the source document. Source: https://wiki.archlinux.org/title/EFI_system_partition

I had to create an efi folder so I first started by mounting my main 1.8TB endeavorOS partition to a path that worked for me. I personally just used what it gave as default when you click the drive to look at the drive in dolphin.

I’m sure you can use the mount command too but I did struggle a bit with that here so I can’t share how to do that in this post here unfortunately.

I then verified this path using KDE partition manager or you can use lsblk.

I then created a new efi folder using: sudo mkdir /path/of/mounted/main/partition/efi Source: https://wiki.archlinux.org/title/Help:Reading#Append,_add,_create,_edit

Once done then I mounted the EFI fat32 partition to that same path using KDE partition manager. Alternatively you can use: mount /dev/nvme1n1p3 /path/of/mounted/main/partition/efi Source: https://wiki.archlinux.org/title/File_systems#Mount_a_file_system

Now we need to chroot into the system but before that make sure that packages grub and efibootmgr are installed. Source: https://wiki.archlinux.org/title/GRUB

Now time to chroot into my system since we’re still in the live USB environment: sudo arch-chroot /path/of/mounted/main/partition https://wiki.archlinux.org/title/chroot

Once in we can use the grubinstall command. I personally used the command provided by VictiniFan360 (Changing the efi-directory from /mnt to /efi): grub-install --target=x86_64-efi --efi-directory=/efi --bootloader-id=endeavouros Sources: Repairing GRUB - #4 by pebcak, https://wiki.archlinux.org/title/GRUB

Then update the grub configuration: grub-mkconfig -o /boot/grub/grub.cfg Sources: Repairing GRUB - #5 by VictiniFan360, https://wiki.archlinux.org/title/GRUB#Generate_the_main_configuration_file

Then unmounted the EFI partition using: sudo umount /path/of/mounted/main/partition/efi Can also use KDE partition manager. Source: Repairing GRUB - #5 by VictiniFan360

Exit chroot using: exit Source: https://wiki.archlinux.org/title/chroot

Run: reboot

From here my system initialized into a functioning GRUB that not only shows my EndeavorOS boot using UEFI but also my Windows 11 boot which is also running under a seperate UEFI partition on another drive that previously didn’t show when my grub drive was previously using Legacy BIOS.

Hopefully this helped whoever stumbled across this. Let me know if you have any comments or suggestions! Shout out to this amazing community!