Ubuntu – Can’t boot Ubuntu because Windows 10 rewrites entire EFI partition [Solved]

dual-bootpartitioninguefi

I'm having trouble setting up a dual boot with Windows 10 and Ubuntu 16.04 (Game-pack) on an HP Pavilion Gaming Laptop (15 -cx0049nr).

I realize that many, many questions have been asked on this, but I have read dozens of threads and tried all sorts of solutions with no luck.

So far, I cleared space with the disk management tool, disabled fast boot, hibernation and secure boot and installed Ubuntu with a live USB successfully.
Right after installation, I found that if I hit F9 right away while restarting, I get the boot device list, and can choose Ubuntu. But if I don't hit F9, it goes straight to Windows. At the next reboot, if I hit F9, the Ubuntu folder and all related .EFI files are gone.

Going back into Windows, the disk management utility shows the Ubuntu partition as unallocated space. Diskpart can't find it either. Exploring the EFI partition after mounting it with Diskpart confirms that the Ubuntu folder and all grub files are gone. It's like Windows has rewritten the EFI partition and refuses to acknowledge the Ubuntu partition.

So far, I have tried:

  • Loading the liveUSB and running boot repair. This allows me to get in with F9 at start as before, until the first time that Windows boots. (At this point, fdisk -l indicates that there is a discrepancy between primary and backup GPT partition tables. Gdisk can fix it, but it comes back every time.)
  • Installing rEFInd, which can't find any Ubuntu EFI files.
  • Installing EasyUEFI, which also can't find any Ubuntu EFI files.
  • Creating a boot entry for Ubuntu with bcdedit, which persists through multiple boots, but points to nothing (Error code 0xc00000076).

I'm at a loss as to where to go next.

In the live environment, with the Ubuntu install inaccessible, sudo parted -l indicates that the backup GPT table is corrupt, but the primary is OK, and shows:

Model: ATA ST1000LM049-2GH1 (scsi)
Disk /dev/sda: 1000GB
Sector size (logical/physical): 512B/4096B
Partition Table: gpt
Disk Flags: 

Number  Start   End     Size    File system     Name                                      Flags
 1      1049kB  274MB   273MB   fat32           EFI system partition              boot, esp
 2      274MB   290MB   16.8MB                  Microsoft reserved partition  msftres
 3      290MB   551GB   550GB   ntfs            Basic data partition          msftdata
 6      551GB   969GB   419GB   ext4
 7      969GB   982GB   12.8GB  linux-swap(v1)
 4      982GB   983GB   1028MB  ntfs            Basic data partition          hidden, diag
 5      983GB   1000GB  16.9GB  ntfs            Basic data partition            hidden, msftdata


efibootmgr
BootCurrent: 0001
      Timeout: 0 seconds
      BootOrder: 2001,0000,3000,2002,2004
      Boot0000* Windows Boot Manager
      Boot0001* USB Hard Drive (UEFI) - KingstonDataTraveler 2.0           (KingstonDataTraveler 2.0)
      Boot0002* Internal EFI Shell
      Boot0004* Internal EFI Shell
      Boot0005* Default hard drive Boot
      Boot0006* Internal EFI Shell
      Boot0007* Windows Boot Manager
      Boot0008* Default hard drive Boot
      Boot2001* EFI USB Device
      Boot3000* Internal Hard Disk or Solid State Disk

Best Answer

Finally resolved: Disable Optane memory from BIOS menu. This issue (and many others in my system) stemmed from Intel's new Optane technology. Apparently the optane memory is just a 16gb SSD with a special driver that allows it to store an image of the current Windows state that is not visible or modifiable by the user. The driver also renders the drive as invisible to both Windows and Linux. Thanks, Intel. See Intel's FAQ for more info (https://www.intel.com/content/www/us/en/support/articles/000024018/memory-and-storage/intel-optane-memory.html) I finally got past this issue by disabling the optane memory in my BIOS options, after which point my system started to behave as expected. It seems that the bootloader looked at the Optane first, so nothing I did to my regular SATA drive had any visible effect on the bootloader, or Windows. Wiser users than I can probably figure some way to use this extra SSD to advantage. If you're a basic user like me with a new HP laptop with Optane memory facing similar issues, try disabling the optane drive in BIOS.

Related Question