Enter the following command to execute gdisk
on your primary internal drive. You will be prompted for your login password.
sudo gdisk /dev/sda
This will result in output similar to what is shown below.
GPT fdisk (gdisk) version 1.0.3
Partition table scan:
MBR: protective
BSD: not present
APM: not present
GPT: present
Found valid GPT with protective MBR; using GPT.
Command (? for help):
Start by checking to see if the partitions in the GUID Partition Table (GPT) are in ascending order. Enter the command below to print out the GPT.
Command (? for help): p
Disk /dev/sda: 1048576000 sectors, 500.0 GiB
Model: VBOX HARDDISK
Sector size (logical/physical): 512/512 bytes
Disk identifier (GUID): A984BAF1-4F22-4E6C-9077-40FEEDF064DB
Partition table holds up to 128 entries
Main partition table begins at sector 2 and ends at sector 33
First usable sector is 34, last usable sector is 1048575966
Partitions will be aligned on 2048-sector boundaries
Total free space is 4062 sectors (2.0 MiB)
Number Start (sector) End (sector) Size Code Name
1 2048 411647 200.0 MiB EF00 EFI System
2 411648 210126847 100.0 GiB AF00 Apple HFS/HFS+
3 210126848 211458047 650.0 MiB AB00 Recovery HD
4 211458048 843775966 301.5 GiB 0700 Microsoft basic data
5 1031798784 1048573951 8.0 GiB 8200
6 843776000 1031798783 89.7 GiB 8300
Command (? for help):
Partition number 5 should occur after partition 6. Enter the commands given below to swap the values stored in the GPT for these two partitions.
Command (? for help): x
Expert command (? for help): t
Partition number (1-6): 5
New partition number (1-128, default 7): 6
Expert command (? for help):
Enter the command give below to confirm the partitions are now in ascending order.
Expert command (? for help): p
Disk /dev/sda: 1048576000 sectors, 500.0 GiB
Model: VBOX HARDDISK
Sector size (logical/physical): 512/512 bytes
Disk identifier (GUID): A984BAF1-4F22-4E6C-9077-40FEEDF064DB
Partition table holds up to 128 entries
Main partition table begins at sector 2 and ends at sector 33
First usable sector is 34, last usable sector is 1048575966
Partitions will be aligned on 2048-sector boundaries
Total free space is 4062 sectors (2.0 MiB)
Number Start (sector) End (sector) Size Code Name
1 2048 411647 200.0 MiB EF00 EFI System
2 411648 210126847 100.0 GiB AF00 Apple HFS/HFS+
3 210126848 211458047 650.0 MiB AB00 Recovery HD
4 211458048 843775966 301.5 GiB 0700 Microsoft basic data
5 843776000 1031798783 89.7 GiB 8300
6 1031798784 1048573951 8.0 GiB 8200
Next, rebuild the MBR partition table. To do this, you will need the values your recorded earlier while booted to Windows. Enter the following.
Command (? for help): r
Recovery/transformation command (? for help): h
WARNING! Hybrid MBRs are flaky and dangerous! If you decide not to use one,
just hit the Enter key at the below prompt and your MBR partition table will
be untouched.
Type from one to three GPT partition numbers, separated by spaces, to be
added to the hybrid MBR, in sequence: 2 3 4
Place EFI GPT (0xEE) partition first in MBR (good for GRUB)? (Y/N): y
Creating entry for GPT partition #2 (MBR partition #2)
Enter an MBR hex code (default AF): af
Set the bootable flag? (Y/N): n
Creating entry for GPT partition #3 (MBR partition #3)
Enter an MBR hex code (default AB): ab
Set the bootable flag? (Y/N): n
Creating entry for GPT partition #4 (MBR partition #4)
Enter an MBR hex code (default 07): 07
Set the bootable flag? (Y/N): y
Recovery/transformation command (? for help):
If you are prompted with the question given below, enter n
. Note: The more experienced individual may want to enter y
, then enter 83
when prompted for a MBR hex code.
Unused partition space(s) found. Use one to protect more partitions? (Y/N):
Print out the MBR partition table to verify the partitions have the correct values, as shown below. The result should be the same as you recorded earlier.
Recovery/transformation command (? for help): o
Disk size is 1048576000 sectors (500.0 GiB)
MBR disk identifier: 0x3C984A3E
MBR partitions:
Number Boot Start Sector End Sector Status Code
1 1 411647 primary 0xEE
2 411648 210126847 primary 0xAF
3 210126848 211458047 primary 0xAB
4 * 211458048 843775966 primary 0x07
Recovery/transformation command (? for help):
Write out the changes and quit, as shown below.
Recovery/transformation 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) to /dev/sda.
Warning: The kernel is still using the old partition table.
The new table will be used at the next reboot or after you
run partprobe(8) or kpartx(8)
The operation has completed successfully.