Ubuntu – Ubuntu installer not detecting Windows installation and disk partitions


I want to install 64bit Ubuntu on my PC which is already running Windows 10. The problem is, Ubuntu installer is neither detecting the windows installation nor the partitions I've made on my hard disk using windows. The installer shows an empty hard disk (no partitions) where I can install Ubuntu. Im afraid if I continue to install I might break the existing partitions and lose my files.
But the partition manager "Gparted" is showing all the existing partitions correctly. Only the installer is not able to detect the partitions. Is this issue occurring because I'm running Windows in legacy mode?
I took the following steps before trying to install Ubuntu:

  1. Created free space of 15GB on my hard drive
  2. Disabled fast boot (and couldn't disable secure boot since I'm running windows in legacy)
  3. Made a bootable USB drive for Ubuntu installation using "rufus".

And UEFI boot is already enabled in the boot manager.

Here is the output of sudo parted /dev/sda print and sudo gdisk -l /dev/sda

$ sudo parted /dev/sda print
Error: Can't have overlapping partitions.
Ignore/Cancel? Ignore
Model: ATA ST500LT012-9WS14 (scsi)
Disk /dev/sda: 500GB
Sector size (logical/physical): 512B/4096B
Partition Table: msdos
Disk Flags: 

Number  Start   End     Size    Type      File system  Flags
1      106MB   85.1GB  85.0GB  primary   ntfs         boot
2      1016kB  500GB   500GB   extended               lba
5      1049kB  106MB   105MB   logical   ntfs
6      85.1GB  280GB   195GB   logical   ntfs
7      296GB   500GB   204GB   logical   ntfs

$ sudo gdisk -l /dev/sda
GPT fdisk (gdisk) version 1.0.1

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. 

Disk /dev/sda: 976773168 sectors, 465.8 GiB
Logical sector size: 512 bytes
Disk identifier (GUID): E5565EE3-A718-45F1-9D21-1AE3D5CA64F7
Partition table holds up to 128 entries
First usable sector is 34, last usable sector is 976773134
Partitions will be aligned on 16-sector boundaries
Total free space is 31465523 sectors (15.0 GiB)

Number  Start (sector)    End (sector)  Size       Code  Name
1          206848       166189951   79.1 GiB    0700  Microsoft basic data
5            2048          206847   100.0 MiB   0700  Microsoft basic data
6       166192000       547473337   181.8 GiB   0700  Microsoft basic data
7       578930736       976769071   189.7 GiB   0700  Microsoft basic data
ubuntu@ubuntu:~$ sudo gdisk -l /dev/sda

GPartEd complains I have overlapping partitions. Is that a problem?

Best Answer

Here's the source of your problem, from your parted output:

Error: Can't have overlapping partitions.

Your disk's one primary partition (/dev/sda1) resides entirely within your extended partition (/dev/sda2). This is illegal. This invalid layout was probably created by the Windows partitioning tools, which often do this sort of thing with disks that have extended and logical partitions.

Chances are my FixPart utility, which comes with Ubuntu, can fix the problem; however, you must be careful about how you go about doing this repair. Specifically:

  • Windows normally insists on booting from a primary partition. Thus, you must ensure that whatever partition Windows uses for this purpose becomes a primary partition when FixParts has done its thing.
  • In order to create new partition(s) for Ubuntu, you must have at least one logical partition, and it must be positioned in such a way that the future Ubuntu partition(s) will be adjacent to the logical partition(s). (This point assumes that all your existing NTFS partitions contain Windows data. If you intend to convert one of them entirely to Ubuntu use, you might remain under the four-primary-partition limit of MBR.)
  • Unless I've missed something, you'll need to resize at least one partition to make room for more. FixParts can't do this. Resizing the partition in Windows is normally advisable; however, as I've already noted, the standard Windows tools tend to make a mess of things when logical partitions are present, so you may want to use a third-party tool or the Ubuntu installer to do this job. (I don't recall offhand how good the Ubuntu installer is at resizing partitions. GParted should be able to do it -- but be sure to fix the overlapping partition problem before you try!)
  • Do not create new partitions for Ubuntu using the Windows tools; they're likely to convert to a Logical Disk Manager (LDM) layout (aka a dynamic disk setup), which will be a new set of problems for Ubuntu installation. If you use Windows tools to shrink existing partition(s), leave the resulting space unallocated and let the Ubuntu installer create new partition(s) in that space itself.
  • There's always a chance that something will go badly wrong when repartitioning the disk. This is doubly true when your disk is already damaged, as yours is. I therefore recommend doing a full backup, or at least backing up your user files, before you do anything else.

Also, although you note that UEFI boot is specified in your firmware, your disk layout clearly indicates a BIOS-mode installation of Windows. When dual-booting, it's almost always best to ensure that both OSes boot in the same mode, so you should install Ubuntu in BIOS mode. Note that the boot mode (BIOS/CSM/legacy vs. EFI/UEFI) specified in the firmware is often interpreted as more of a suggestion than a command, which is why you can have a BIOS-mode boot even when you've set EFI-mode booting in the firmware.

As an alternative to some of this, you might consider converting Windows to boot in EFI mode, as described in this blog post. With Windows booting in EFI mode from a GPT disk, you needn't be concerned with primary/extended/logical partition issues, since GPT doesn't recognize that distinction. It's usually easier to ensure a consistent EFI-mode boot in a dual-boot configuration than to set up both OSes in BIOS mode, too. (See this page of mine for more on this subject.) If you go this route, it's probably safest to fix the current disk setup with FixParts as a first step; however, if you put off resizing partitions until after the MBR-to-GPT configuration, FixParts will become unnecessary.