0

I'm trying to convert either unallocated space to GPT or /dev/sda3 to GPT so that I can install windows on said partition. The issue I'm running into is that when I load gdisk /dev/sda it states that Partition 3 is in use so I unmount it, and try it again and nothing. I checked this question out and followed the answer and I still get the same error and I can't convert it. Does anyone have an answer?

EDIT: The following is the terminal and how I see it.

    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
in memory. THIS OPERATION IS POTENTIALLY DESTRUCTIVE! Exit by
typing 'q' if you don't want to convert your MBR partitions
to GPT format!
***************************************************************


Command (? for help): p
Disk /dev/sda: 976773168 sectors, 465.8 GiB
Logical sector size: 512 bytes
Disk identifier (GUID): 24416D0F-15FE-4237-89AA-CFB5BD774C1E
Partition table holds up to 128 entries
First usable sector is 34, last usable sector is 976773134
Partitions will be aligned on 2048-sector boundaries
Total free space is 6125 sectors (3.0 MiB)

Number  Start (sector)    End (sector)  Size       Code  Name
   1            2048       204802047   97.7 GiB    8300  Linux filesystem
   3       204802048       960233471   360.2 GiB   0700  Microsoft basic data
   5       960235520       976771071   7.9 GiB     8200  Linux swap

Command (? for help): n
Partition number (2-128, default 2): 3
partition 3 is in use.
Partition number (2-128, default 2): Partition number (2-128, default 2): 

2 Answers2

1

You cannot convert only a part of the device to GPT because changing to GPT affects the partition table, which is on the very start of the drive.

It is different than MBR, so either you use MBR OR you use GPT, but not both.

Also using GPT you can boot using UEFI, MBR is intended for use with BIOS.

So, best is to directly convert the whole drive to GPT.

Look at this good topic to convert from MBR to GPT: How can I change/convert a Ubuntu MBR drive to a GPT, and make Ubuntu boot from EFI?


EDIT:

Also check if all partitions are umounted, for this, use the command mount on terminal to find out. Everything you find with /dev/sda you should unmount using umount /dev/sdaX (instead of X the desired partition, e. g. /dev/sda2), of course in root mode, either using su or prepended sudo.

For creating partitions etc. use gparted which you can install using sudo apt-get install gparted, and start with gparted or gksu gparted.

xdevs23
  • 275
1

xdevs23's answer is good, but I want to elaborate on some issues. First, when you launched gdisk on your disk, it automatically converted MBR to GPT in memory. Anything you do subsequently works on the transformed GPT data structures, unless and until you hit w, at which point the disk itself is transformed to use GPT. The n command in gdisk creates a new partition. Thus, when you used n and then specified 3 as the partition, you were telling gdisk to create a new partition #3 -- but that partition entry already exists. The gdisk error refers to this fact; it has nothing to do with what partitions are currently mounted. (gdisk doesn't care about mounted partitions, and will readily delete or modify them -- but if you do so, your changes won't be visible until you restart or remove the disk, since the kernel will continue to use the old partition table.)

Another point, and really a more important one in this context, is to ask why you want to create a GPT partition. My guess is that Windows complained about the use of MBR and said it wanted GPT. This is simply a symptom that you booted the Windows installer in EFI/UEFI mode; but the use of MBR implies that Ubuntu is installed in BIOS/CSM/legacy mode. Mixing boot modes is not a good idea. The simplest solution may be to install Windows in BIOS mode, too. Doing this will require finding the right way to boot the Windows installation medium. You'll probably need to use your boot manager and pick the option for the boot medium that lacks the string "UEFI" in its description.

The trouble with this is that you've already got three primary partitions on the disk. If you intend to install Windows to one of those partitions (presumably /dev/sda3), you may be OK; however, Windows has a tendency to convert disks from a plain MBR setup to MBR with a Logical Disk Manager (LDM) layer atop it when the number of partitions exceeds four. If the Windows installer does this, you'll have a hard time fixing the problem, since Ubuntu can't boot from such disks -- at least, not easily, and I've never heard of anybody succeeding it making it work.

Thus, converting from MBR to GPT may be useful; however, you'll then need to re-install an Ubuntu boot loader. As I said, mixing boot modes is undesirable, so it will be best to install an EFI boot loader for Linux. You can do this either manually or in a semi-automated way. Using Boot Repair can do this -- but be sure to boot it in EFI mode. (In fact, disabling your CSM in your firmware setup utility may be best if you go this route.) Another alternative is to use my rEFInd boot manager on USB flash drive or CD-R to boot Ubuntu. You can then swap out the grub-pc package for the grub-efi package to install GRUB manually; or install the rEFInd Debian package or PPA to have rEFInd take over as your boot manager.

Yet another option may be to install Windows to a second disk. If you do this in BIOS mode, you won't need to mess with the Ubuntu boot loader. Windows can use LDM or not, as it desires, without causing problems for Ubuntu. This is obviously more likely to work on a desktop than on a laptop, and requires extra hardware.

Installing Windows in a virtual machine (using VirtualBox, KVM/QEMU, or something similar) can avoid many of the headaches I've just described, but may be limiting if you want Windows for game-playing or something else that requires direct hardware access.

In sum, you have a number of options. The trick is navigating them all. There are quite a few ways the installation you're attempting can go wrong, so if you don't know what you're doing, this can be hazardous. Overall, I recommend you try a virtual machine installation, if that's practical. If not, you really should read up on the subject of EFI-mode booting. I recommend:

Rod Smith
  • 44,284
  • 7
  • 63
  • 105