MBR to GPT / GPT to MBR, UEFI and GRUB
MBR to GPT
Linux - boot in MBR mode as usual, then do: gdisk /dev/sdX p check partition table, if it is empty, then do q because this might not work w write table to disk and exit Note 1: Make sure there are some space after the last partition and maybe also a little before the first to fit the backup partition table and the main partition table. Note 2: In case gdisk does not show any partitions, then you might end up with an empty partition table. You can possibly recover the previous partition table. Install testdisk and follow https://linuxconfig.org/how-to-recover-partition-table-in-linux, that is: Run testdisk, No Log, choose the disk to recover on, choose Intel (not GPT), choose Analyse, choose Quick search, choose check what it found – hopefully it found the partitions, then Write and confirm. If switching from legacy BIOS to UEFI, then additional changes are needed, such as creating an EFI partition and uninstalling grub-pc and installing grub-efi. Do not reboot. To do the conversion from Windows 10: Go to Recovery, Restart, Troubleshoot, Advanced options, Command prompt, run mbr2gpt If using the Linux method above then Linux nor Windows will not boot unless more are done. So before rebooting: Create a new FAT32 partition of 100 MB, set boot + efi flags on it. If possible, put it first, then use cfdisk /dev/sdX and select Sort to sort them. If you cannot sort because Sort is not available, then use sfdisk to dump the partition table: sfdisk -d /dev/sdX > partitions Then edit partition numbering in the partitions file. Then write it back: sfdisk /dev/sdX < partitions In the Linux system partition create /boot/efi directory in case it does not exist: mkdir -p /boot/efi Run blkid, note the UUID=<value> for the EFI partition Edit /etc/fstab, add a line for the EFI partition: UUID=<value> /boot/efi vfat umask=0077 0 0 Mount it mount -a Reload it for systemd: systemctl daemon-reload Remove grub-pc, add grub-efi: apt install grub-efi (will remove grub-pc) Install grub, telling it where to look for the EFI files, where the boot directory is and what disk: grub-install -d /usr/lib/grub/x86_64-efi --boot-directory=/boot /dev/sda Note! Not doing this results in this junk error: Installing for i386-pc platform. grub2-install: warning: this GPT partition label contains no BIOS Boot Partition; embedding won't be possible. grub2-install: warning: Embedding is not possible. GRUB can only be installed in this setup by using blocklists. However, blocklists are UNRELIABLE and their use is discouraged.. grub2-install: error: will not proceed with blocklists. Instead you now should get this: Installing for x86_64-efi platform. grub-install: warning: EFI variables cannot be set on this system. grub-install: warning: You will have to complete the GRUB setup manually. Installation finished. No errors reported. It tells you it cannot edit the BIOS variables, because the system is booted in legacy mode. On next reboot, you will have to use Boot from file and find the shimx64.efi file Reboot, enter BIOS, switch from legacy/CSM to UEFI, quit and select Boot from file, then browse to the disk, EFI, debian, shimx64.efi Debian should boot. Run: grub-install /dev/sda (again) In case it still does not want to boot GRUB run: efibootmgr Look for the debian line. Set the debian number, replace XXXX with BootXXXX for debian in the above listing: efibootmgr -o XXXX If this does not work, look for special issues for your system, like this for HP 840 G1: https://wiki.archlinux.org/title/HP_EliteBook_840_G1 If you have Windows 10 installed you need to repair or rebuild the boot for it: Boot a Windows installer ISO from USB drive, go next on language options and then select Restore system. https://woshub.com/how-to-repair-uefi-bootloader-in-windows-8/ Go to Troubleshoot, Command Prompt, then write: diskpart list disk Then do this to select the right disk: sel disk N Then this to list partitions and volumes: list partition list volume Use dir X:\ to find the volume with X:\Windows Find the EFI partition in the list and assign a letter to it: select volume X assign letter K: Then install the bcd boot files to the EFI partition: bcdboot X:\Windows /l XX-YY /s K: /f ALL Replace XX-YY with your locale, for English us en-US, for Swedish use sv-SE, here are the language codes listed: https://docs.microsoft.com/en-us/windows-hardware/manufacture/desktop/available-language-packs-for-windows?view=windows-11 Not sure if this is necessary, but do this to the same drive as Windows is located on: bcdedit.exe /store X:\boot\bcd /create {bootmgr} /d "windows Boot Manager" Then redo: bcdboot X:\Windows /l XX-YY /s K: /f ALL Then reboot. References: https://askubuntu.com/questions/1314111/convert-mbr-partition-to-gpt-without-data-loss https://superuser.com/questions/903112/grub2-install-this-gpt-partition-label-contains-no-bios-boot-partition https://woshub.com/how-to-repair-uefi-bootloader-in-windows-8/
GPT to MBR
Linux: gdisk /dev/sdX r recovery and transformation options (experts only) g convert GPT into MBR and exit w write table to disk and exit Notes: This is risky, for some reason when testing this first, then the whole disk contents was converted into one large partition. If there are more than 4 partitions, then a type f W95 Extended (LBA) extended partition will be made to put the additional partitions in - not a type 5 extended partition made in cfdisk or gparted. This can be fixed with fdisk afterwards: fdisk /dev/sdXY p print the partition table - find the W95 Extended (LBA) partition to change to Extended t change a partition type - type partition number, then 5 for Extended w print the table to the disk and quit If switching from UEFI to legacy BIOS, then additional changes are needed, such as uninstalling grub-efi and installing grub-pc.
UEFI - Boot directly from disk name boot option
USB drives with ISO:s are possible to boot directly from the UEFI boot manager just by inserting them or selecting the drive itself in the boot order list. This is however not the case with regular disks, they require that specific entries for boot options on the drive, like "debian", are added to the list. By doing a removable drive GRUB install it becomes possible to select the drive directly in the list: grub-install --removable --force --boot-directory=/boot --efi-directory=/boot/efi /dev/sda --no-nvram This does however not stop the addition of the "debian" boot option to the UEFI NVRAM anyway when GRUB loads. https://askubuntu.com/questions/1298684/stop-grub-from-changing-the-efi-boot-order The following text flashes by in VirtualBox at least: System BootOrder not found. Initializing defaults. Creating boot entry "BootXXXX" with label "debian" for file "\EFI\Debian\debian64.efi" Another problem with this is that the boot order is not arranged automatically so the disk comes before the EFI Shell, which is the case with CD drives. So the EFI Shell boots instead of the drive.
Legacy boot with GPT
Windows: "Unlike most Linux based OSes, Windows strictly requires 'msdos' (MBR) partitioning for BIOS mode (or Legacy/CSM under UEFI) and conversely it strictly requires GPT for UEFI mode. This is ap[pl]icable to any Windows version supporting both modes - Windows 7 and up to Windows 10 - and obviously not applicable to Windows 11 that only supports UEFI mode and GPT." https://superuser.com/questions/1810526/is-it-possible-to-install-windows-10-on-old-bios-pc-with-gpt-drive
This is a personal note. Last updated: 2025-10-31 00:36:41.



