How to remove GPT from HDD?
I have a Asus K55VM-Sx027V laptop and I formated it with Ubuntu because whenever I tried to install Windows 7 64bit, it wouldn't let me because my HDD had GPT protection.
Now that I have Ubuntu 12.10, how do I remove GPT protection from my laptop?
Solution 1:
Use gdisk
instead of fdisk.
It isn't installed by default, so get it with:
sudo apt-get install gdisk
Then umount
the drive and call gdisk
for the device:
sudo gdisk /dev/sdX
It will prompt you to select the partition:
Found valid MBR and GPT. Which do you want to use?
1 - MBR
2 - GPT
3 - Create blank GPT
Select the GPT one. In my case, 2
. Use the ?
command to print the command list. Enter x
for expert options, then z
to zap the GPT table and all the data on the disc:
Command (? for help): x
Expert command (? for help): z
About to wipe out GPT on /dev/sdx. Proceed? (Y/N): y
GPT data structures destroyed! You may now partition the disk using fdisk or
other utilities.
Blank out MBR? (Y/N): y
Solution 2:
You can use wipefs
to remove all common id blocks from a device before changing the partition format.
sudo wipefs -a /dev/sdx
Solution 3:
With a simple Python function!
def clear_gpt(target):
'''
According to http://en.wikipedia.org/wiki/GUID_Partition_Table - GPT
stores partition data in the first and last 34 LBA blocks. A LBA sector
is normally 512 bytes.
'''
fd = open(target, "w+")
fd.seek(0)
fd.write('\0' * 34 * 512)
print "done nuking data at the beginning of disk", target
fd.seek(0, 2) # SEEK_END is 2
disk_size = fd.tell()
fd.seek(disk_size - 34*512)
fd.write('\0' * 34 * 512)
print "done nuking data at the end of disk", target
Get a full example from:
http://blog.gnub.net/2009/03/die-gpt-die.html
Solution 4:
GPT is the GUID Partition Table, which is a method of defining partitions (not protection) on your computer. If Windows is complaining about your use of GPT, that means that the Windows installer has booted in BIOS mode rather than in (U)EFI mode. There are two ways to work around this problem:
- Boot the Windows installer in EFI mode. This might or might not be possible, depending on your computer. If it's new (sold in the last 6-12 months), it probably supports EFI-mode booting. To boot in EFI mode, you may need to fiddle with your firmware settings to enable EFI-mode booting. Sometimes hitting the button to get to the boot options when you boot will produce two options for booting your CD: one in BIOS (aka legacy) mode and the other in EFI mode.
- Convert the hard disk to use MBR partitioning rather than GPT. You can do this with GPT fdisk (gdisk) by using its "g" option on the "recovery & transformation" menu. There are, however, a lot of caveats and details to such a conversion; see the GPT fdisk documentation for details. When you're done, Ubuntu will no longer boot; you'll need to re-install the boot loader. (You'll need to do this after installing Windows in BIOS mode anyhow, so you might as well put this off until after you install Windows.)
EFI-mode booting with GPT is still very new and can be trouble-prone, but converting your partition table from GPT to MBR is also a rather risky endeavor. Thus, it's hard for me to say which approach is best. Of course, you might not even be able to boot your computer in EFI mode, so you might have to do it by converting your partition table.
An alternative to either approach is to run Windows from within VirtualBox or some other virtualization environment under Linux. This is simpler and safer, and it may be adequate for many purposes. It's most likely to be a problem if you want to run video-intensive games, if you need low-level access to the hardware, or if you have inadequate RAM to support a virtualized environment sufficient for your needs.
Whichever approach you take (aside from a virtualized Windows), I strongly recommend you back up any important data first; mucking with partition tables is always risky.
Edit: Zolar1's comments suggest the possibility that Ubuntu is installed in BIOS mode but using GPT. Installing Windows in EFI mode in this case will require one of two things:
- Converting Ubuntu to boot in EFI mode rather than in BIOS mode
- Switching boot modes (EFI for Windows, BIOS for Linux)
Either is possible. You can convert Ubuntu to boot in EFI mode by adding an EFI boot loader. There are several options, as described here. Ubuntu uses GRUB 2 as its EFI-mode boot loader by default, but IMHO this is a poor choice.
Switching between EFI-mode and BIOS-mode boots of the computer is usually awkward, but sometimes a boot options switch (accessible by pressing F8, F12, or some other key at boot time) can make this tolerable. Another options may be to install rEFInd, which is an EFI-mode boot manager that can (as of version 0.4.6) hand off the boot process to a BIOS-mode boot loader (or to an EFI boot loader).