Exact matches only
Search in title
Search in content
Search in posts
Search in pages

Zap GPT data structures from a disk, while preserving existing MBR partitions

Using GPT partitions, or a GPT partitioning scheme, takes care of the shortcomings of the MBR partitioning scheme. However, if you are not careful, it could make things difficult for you. But don’t point fingers at the technology itself.

Back in November 2012, while attempting to dual-boot Ubuntu 12.10 and Windows 8 Pro on a solid state drive (SSD), I made an observation which I wrote about in Why is Windows 8 on SSD invisible to Ubuntu 12.10’s installer?. At that time, the most vexing thing was that I could not reproduce the problem on my regular hard disk drives (HDDs). And I could not figure out the solution.

Bartek Juszczak, a reader who commented on that article, suggested a very simple solution. I never bothered to try it out until yesterday when I made a first attempt to triple-boot Windows 7, Ubuntu 12.10 and Fedora 18 on the same SSD.

Even though I was using Windows 7 instead of Windows 8 Pro, it was the same problem all over again; Ubuntu’s installer could not detect the existing Windows 7 on the SSD.

To give you an idea of the nature of the problem, take a look at this screen shot. If you’ve ever installed Ubuntu or any Ubuntu-derived distribution, you know that it’s from the partitioning methods step of Ubiquity, the graphical installation program of Ubuntu Desktop. Though it says that “This computer has no detected operating system,” there is a fresh installation of Windows 7 on it.
Ubuntu Ubiquity Installer

Even from the Advanced Partitioning Tool’s window, there is no evidence of any partition on it. Why? Based on Juszczak comment, and from my observation while attempting to implement his fix, it appears that the SSD had GPT partitions on it before Windows was installed. So the GPT data structures were confusing Ubiquity.
Ubuntu Advanced Partitioning Tool

After successfully implementing Juszczak’s fix, Ubiquity’s accurately detected the presence of Windows 7 on the SSD. If you are facing the same problem, this short article gives you a step-by-step guide, with screen shot, on how to remedy it.
GPT Partitions

I made the attempt to fix the problem while installing Ubuntu from the Live desktop. You will be working from a shell terminal, and be using Gdisk to mess with the disk. Since Gdisk is not installed in the Live environment, it will have to be installed using sudo apt-get install gdisk. After that, run the command shown in the screen shot below. The output reveals what the problem is: Presence of MBR and GPT partition tables on the same SSD. That’s why Ubuquity got confused.
GPT Partitions gdisk

Since I installed Windows 7 using an MBR partitioning scheme, the reasonable option to select is “1.” I want to preserve the MBR partitions.
GTP Partitions Gdisk

Now that I’ve told Gdisk what I don’t want to destroy, it is expecting additional commands. Type “x” to see a list of command options.
GPT Partitions Gdisk

The option we are looking for is “z” (zap (destroy) GPT data structures and exit).
GPT Partitions Gdisk

Type “y” to confirm wiping the GPT data structures.
GPT Partitions Gdisk

Then “n” to preserve the MBR partitions. That’s it.
GPT Gdisk

Exact matches only
Search in title
Search in content
Search in posts
Search in pages
Digital Ocean SSD VPS Cloud Server droplets

Digital Ocean is a VPS/Cloud hosting provider. For just $5 per month, you can get yourself a Cloud server with 512 MB of RAM, 20 GB super-fast SSD, free snapshots, plus backups for a minimal fee. All via a simple graphical interface.

And by signing up with this referral link, you can help support this website.

If you are reading this, your ad could also be occupying this space. Contact us to make it happen.

If commenting on this article is closed, please post your comments at forum.linuxbsdos.com.

35 Comments

  1. linuxnoob7 says:

    hi,

    I tried to install ubuntu on my computer but I couldnt do it without erasing windows so Im trying your technique to solve it but it says my gpt is not existent and then I received this message:

    ***************************************************************
    Found invalid GPT and valid MBR; converting MBR to GPT format
    in memory. THIS OPERATION IS POTENTIALLY DESTRUCTIVE! Exit by
    typing ‘q’ if you don’t want to convert your MBR partitions
    to GPT format!
    ***************************************************************

    and then

    Command (? for help): ?
    b back up GPT data to a file
    c change a partition’s name
    d delete a partition
    i show detailed information on a partition
    l list known partition types
    n add a new partition
    o create a new empty GUID partition table (GPT)
    p print the partition table
    q quit without saving changes
    r recovery and transformation options (experts only)
    s sort partitions
    t change a partition’s type code
    v verify disk
    w write table to disk and exit
    x extra functionality (experts only)
    ? print this menu

    could you help me? Im running windows 7!

    thanks :)

    • finid says:

      questions:

      1. Did you install Windows 7 yourself or is did it come with the PC?

      2. Is Windows 7 installed on MBR or GPT partitions? If MBR, then you can zap the GPT partitions.

      3. Can you see the Windows 7 partition from the advanced disk partitioning tool’s window?

      I’m trying to see whether we can install Ubuntu without going through the steps in this article. Whatever you want to do, first backup your data.

      If you can, try taking a screenshot of the partitioning type step and the advanced partitioning tool window and post them on a new post at the forum.

      • linuxnoob7 says:

        1. It came pre-installed on the PC

        2. How do I check if it is install on MBR or GPT?

        3. ^

        • finid says:

          Boot into the live desktop and restart the installation. At the installation type step, choose the Soemthing else option and take a screenshot of the advanced partitioning tool window.

          That should show all the partitions the installer detected on the disk. Post the image on a new post on the forum.

          I think it’s MBR, but I just want to make sure. Guide to disks and disk partitions in Linux is a good article on this topic.

          • linuxnoob7 says:

            I posted on the forum

          • finid says:

            That looks like MBR, but I’d like to see it from the Ubuntu installer.

            What’s that 1.7 GB partition in front of the System partition?

            The partitioning scheme will be much clearer from Ubuntu’s installer, so let’s see that too.

  2. Finiderire says:

    Good post.

  3. Brendan says:

    Hi, when i type in sudo gdisk /dev/sda, i get a list of the partiotion table but it says my MBR is protected and it says ‘Found valid GPT with protective MBR; using GPT.’ and just puts me straight into options, what do i do?

  4. Marzounette says:

    You save my life dude, seriously!!! Thx!!

  5. Michel says:

    Hi ! I have tried the procedure because Ubuntu installer was enable to detect Windows.
    I have tried to installation again and i got this question:
    unmount partitions that are in use?

    Which I answered yes…. maybe that was a mistake. Ubuntu didnt recogniwe Windows any better so i did not continue installation. I cant boot on Windows now. Would you have any idea on how to get back my windows booting ??

    • finid says:

      When you try to boot Windows, what happens? And do you have a Windows installation CD?
      Also, what version of Ubuntu are you trying to install and on what type of hardware?

  6. jeffrey says:

    wow its works.. thanks

  7. Umesh Wakalekar says:

    Hi,
    Since 2 months I was trying to dualbooting ubuntu with win 8 with uefi mode. before a month I read this post to resolve issue. but ubuntu installer cd was getting error after using
    sudo apt-get install gdisk command. Its saying that gdisk is
    only for basic not for gpt.

    But today I got direct installer package from… http://www.rodsbooks.com/gdisk/download.html
    & installed that gptfdisk_0.8.8-1_i386.deb

    Thanks to you to inspire me to give me guidence of “Zap GPT data structures from a disk, while preserving existing MBR partitions”
    Because of that I successfully removed gpt structure & get option of Install ubuntu alongside with windows” option.

    thanks to forum again.
    good day !!

  8. nerdcom says:

    so, I did this and it worked great, except then when I rebooted all I could boot to was the live usb and NOT windows 8.1 (on a lenovo yoga 2 pro) so in the end I just wiped the disk and installed ubuntu over windows. not what i was shooting for, but helped me commit to obliterating windows, so, well, um, thanks i guess??!!??!

    • finid says:

      Ok, what I need now is a store-bought Windows 8 notebook. Unfortunately, I’m willing to give even 1 cent to MS, just so I can use the PC to write tutorials.

      Anybody willing to donate?

      • nerdcom says:

        thanks for what you have done. maybe i just need to build my own laptop. bought this one due to light weight, thin body, etc. really tired of the windows/mac BS tried to like some dedicated linux machines (system76) but didn’t have the small size/lightweight. i’m feeling pretty comfortable ditching windows…

        • finid says:

          Then just wipe whatever OS that came with your current box and install any Linux distribution that works for you. Been using Linux exclusively for 15 years. No regrets.

          • nerdcom says:

            wiped windows and been on Ubuntu ever since and not looking back. used it the last 2 years or so, starting to experiment with others too.

  9. Vaibhav Bhasin says:

    Hey, you didn’t replied to my problem ?!

  10. Vaibhav Bhasin says:

    Hello,
    I tried the instructions that you gave and I got the following error. Could you please explain me what I should do as I am a kind of noob in all these partitions and all.
    https://www.dropbox.com/s/fz3nq3f56cpuv1l/Screenshot%20from%202013-09-24%2006%3A18%3A28.png
    Please do reply.

    • finid says:

      Your screen shot does not show the options that comes after that warning. Post another one showing those options. There should be an option to destroy the invalid GPT data structures, which is the one to select.

      But post the screen shot show I can be sure.

      • Vaibhav Bhasin says:

        After that, it showed:
        Command (? for help)

        Same as in your screenshot in tutorial.
        Thank You.

        • finid says:

          Well, it only detect a valid MBR partition on the system, so the commands you can run pertain to just that partitioning scheme.

          But let’s get back to the beginning. What issues were you having before you embarked on it, and could you provide some info on your hardware?

          • Vaibhav Bhasin says:

            Well, it’s like, I was trying to install Ubuntu on my Windows 8 laptop(64-bit Non-UEFI) and I have tried it earlier also, where when I booted through the USB and then when I went through the install Ubuntu, it gave me a choice that “Install Ubuntu alongside Windows 8″ but now, it’s not showing up maybe because I shifted from 32-bit Windows 8 to a 64 bit one.
            My Specs:
            2 GB Ram
            2.0 GHz Intel Pentium B940
            500 GB Hard disk
            It’s a laptop so I don’t know much. Hope you can help me as Ubuntu and Windows 8 both are me necessity.
            thanks a lot.

          • finid says:

            Life will be so much better without Windows 8, but that’s a separate discussion.

            Ok, if the laptop is OEM, have you checked the Secure Boot settings. Also, if it is OEM and it came with Windows 8, it should be using the 64-bit version and the GPT partitioning scheme.

            So switching it to non-UEFI mode before installing Ubuntu will not change all that, which I think is the reason you are seeing a message about invalid GPT data structures even though the output is only showing MBR data structures.

            Check the settings, switch back to UEFI and try zapping ZPT to see if it will actually show valid GPT data structures.

  11. patrick says:

    I really like the way the terminal windows were captured.
    Could you please describe the process?

    Your terminal window screenshots are very easy to read and
    the background color looks really good too. Slightly brown or purple.

  12. wb greene says:

    Would seem to be a bug in Ubiquity. If multiple partition tables exist, obviously the non-empty one should be used by default. If multiple partition tables are used, (is this even possible?) then there is a real problem and asking would seem to be required.

Leave a Comment