This is the second part of a 2-part series on converting Windows 7 from MBR to GPT. Here we delve into the actual conversion process. This is not for the faint of heart; be sure you have an adequate backup. It helps if you are comfortable using the command line and changing BIOS/UEFI settings.
Basically, the process involves converting the partition table to GPT, creating a UEFI System partition, and populating that partition with the appropriate files.
- Copy Windows Boot Files
- Boot into Linux (Parted Magic).
- Use gdisk to convert the HD from MBR to GPT.
- Use GParted to create a UEFI System partition.
- Set up the UEFI System partition.
- Use the Windows 7 install CD to repair the boot process.
Copy Windows Boot Files
Copy the windows boot files onto a USB thumb drive. After the disk is converted to GPT, these files will be placed in the EFI partition.
Show hidden files.
- Open an explorer window and press “Alt” to bring up the menu.
- Go to: Tools –> Folder Options
- Select the View tab.
- Select “Show hidden files, folders, and drives”.
The windows boot files are available in 2 places: on the hard drive, and on the install DVD. Don’t worry if you weren’t given a Window 7 install DVD with your computer; a friend’s DVD will work just as well. In any case you’ll need a Windows 7 64-bit install DVD later.
- Brows to C:\Window\Boot\
- Copy the “EFI” folder to your thumb drive.
- Browse to [Win7 x64 DVD]\sources\
- Use 7-Zip to view the contents of “install.wim”.
- Browse to [install.wim]\1\Windows\Boot\
- Copy the “EFI” folder to your thumb drive.
I ran into problems with the boot files from my hard disk. The Window 7 DVD I had was not the one that had been used to install Windows on my computer. Using the boot files from the DVD solved those problems.
Boot into Linux
I used Parted Magic to convert my disk. You can get the latest version at PartedMagic.com.
- Download the x86_64 image of Parted Magic (I downloaded pmagic_2012_2_19_x86_64.iso).
- Burn the image to a CD (ImgBurn is a good tool).
- Boot from the Parted Magic CD.
- Insert the Parted Magic CD and reboot.
- Press ESC to enter the Startup Menu.
- Select “Boot Menu”.
- Choose ATAPI CD/DVD Drive.
- At the boot selection screen, highlight option 1 and press TAB to edit it.
- add “nomodeset” to the end of the list of boot arguments.
- Press “Enter” to boot.
Why set “nomodeset”? Because the HP Omni All-in-One doesn’t have an external monitor, linux has a hard time detecting what mode to use for the display. This option fixes the problem of a blank or garbled screen.
Convert from MBR to GPT
gdisk is a command-line tool that will convert your MBR disk to GPT without changing the partitions. For a walkthrough on using gdisk: http://www.rodsbooks.com/gdisk/walkthrough.html
Open a terminal and enter the following command:
# gdisk /dev/sda
This will open gdisk on the primary hard disk (the secondary hard disk would be /dev/sdb). To convert the disk to GPT, type “w” and press Enter.
# gdisk /dev/sda GPT fdisk (gdisk) version 0.7.2 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 OPERATON IS POTENTIALLY DESTRUCTIVE! Exit by typing 'q' if you don't want to convert your MBR partitions to GPT format! *************************************************************** Command (? for help):w Final checks complete. About to write GPT data. THIS WILL OVERWRITE EXISTING PARTITIONS!! Do you want to proceed? (Y/N): y OK; writing new GUID partition table (GPT). Warning: The kernel is still using the old partition table. The new table will be used at the next reboot. The operation has completed successfully.
Create UEFI System Partition
Now that the partition table is GPT, it is time to create some partitions. If you plan on installing additional operating systems (e.g. linux or hackintosh) now is a good time to set up those partitions. You could use gdisk to do this or any other GPT-aware partitioning tool. I used GParted, which is a graphical tool & has an icon on the Parted Magic desktop.
The UEFI System partition should be 200MB FAT32. Unfortunately, I had some issues with FAT32 and the rEFInd bootloader, so my UEFI system uses FAT16.
My partitioning scheme is as follows:
No. Name Size FS 1 Windows Boot 100MB NTFS 2 Windows 7 250GB NTFS 3 HP Recovery 12.5GB NTFS 4 UEFI System 200MB FAT16 5 Ubuntu 250GB Ext4 6 Hackintosh 250GB HFS+ 7 Experimental 250GB Ext4 8 Swap 9GB Swap 9 Home 375GB HFS+
After all the partitions are created, it is important to make sure that the UEFI System partition is the correct partition type and attributes. Go back into gdisk and change the partition type to “EF00” and enable the system partition attribute.
# gdisk /dev/sda GPT fdisk (gdisk) version 0.8.1 Partition table scan: MBR: protective BSD: not present APM: not present GPT: present Found valid GPT with protective MBR; using GPT. Command (? for help): t Partition number (1-9): 4 Current type is 'Microsoft basic data' Hex code or GUID (L to show codes, Enter = 8300): ef00 Changed type of partition to 'EFI System' Command (? for help): x Expert command (? for help): a Partition number (1-9): 4 Known attributes are: 0: system partition 1: hide from EFI 2: legacy BIOS bootable 60: read-only 62: hidden 63: do not automount Attribute value is 0000000000000000. Set fields are: No fields set Toggle which attribute field (0-63, 64 or to exit): 0 Have enabled the 'system partition' attribute. Attribute value is 0000000000000001. Set fields are: 0 (system partition) Toggle which attribute field (0-63, 64 or to exit): Expert command (? for help): w Final checks complete. About to write GPT data. THIS WILL OVERWRITE EXISTING PARTITIONS!! Do you want to proceed? (Y/N): y OK; writing new GUID partition table (GPT). Warning: The kernel is still using the old partition table. The new table will be used at the next reboot. The operation has completed successfully.
Setup the UEFI System Partition
Now the UEFI System partition is ready for some data. Mount the partition:
# mkdir /mnt/UEFI # mount /dev/sda4 /mnt/UEFI
Mount your thumb drive (the one with the Windows 7 boot files on it).
To determine with device the thumb drive is, first type this command:
# tail -f /var/log/messages
Then plug in your thumb drive. Watch the log. You’re looking for something like this: “sdc: sdc1”. That means your thumb drive is /dev/sdc1. Press “ctrl+c” to kill the tail command. Then mount your thumb drive.
# mkdir /mnt/usb # mount /dev/sdc1 /mnt/usb
Create this file structure on the UEFI System partition: “/EFI/Microsoft/Boot”. In other words:
# mkdir /mnt/UEFI/EFI # mkdir /mnt/UEFI/EFI/Microsoft # mkdir /mnt/UEFI/EFI/Microsoft/Boot
Copy the contents of the EFI subfolder from your thumb drive to the Boot folder on the UEFI System partition.
# cd /mnt/usb/Backup/Windows/Boot/EFI # cp -R * /mnt/UEFI/EFI/Microsoft/Boot/
Unmount the filesystems and remove your thumb drive.
Repair the Windows 7 Startup Files
Reboot the computer using your Windows 7 x64 Setup disk. You can use your friend’s disk if you want. Just be sure it’s a 64-bit version of Windows 7; the 32-bit version doesn’t support UEFI.
Be sure to boot the disk in UEFI/GPT mode. On the HP Omni the steps are as follows:
- Press “Esc” to enter the Startup Menu.
- Press “F9” to enter the Boot Menu.
- Select your DVD from the UEFI Boot Sources list. Mine is called “UEFI: hp DVDWBD TS-LB23P”
After the disk boots, choose your language and keyboard and press “Next”.
Select “Repair your computer” and let the disk do its thing.
If you get an error message that says:
This version of System Recovery Options is not compatible with the version of Windows you are trying to repair. Try using a recovery disc that is compatible with this version of Windows.
Do no fear. Simply use the boot files from the Windows 7 Setup DVD, not from your computer. The boot files from the DVD will be compatible with the DVD.
If everything is working properly, you will get the following message:
Windows found problems with your computer's startup options. Do you want to apply repairs and restart the computer?
Click “Repair and restart”.
I had run through the process twice (booting from DVD & clicking “Repair and restart”) before Windows would boot correctly.
You should now see “Windows Boot Manager” as an option in your UEFI boot menu. Select it to boot into Windows.
That’s it! You now have a Windows 7 system that boots using UEFI from a disk with a GUID Partition Table. Congratulations!