UEFI Dual boot with Windows 7/8

This article Article description::describes how to dual boot Microsoft Windows on a UEFI computer.

Prerequisites
We assume you have a computer with Windows 7 or later installed on a GPT-partitioned drive and booting in UEFI mode. Secure Boot has to be disabled in BIOS.

If the drive is empty, try installing Windows before installing Linux.

Disable "Fast Startup"
It is strongly recommended to disable "Fast Startup", aka "hybrid shutdown" or "hybrid boot" in Windows. Without it, Windows' filesystems are not unmounted even when you're using Linux, so editing Windows files can result in data loss. Even if you do not intend to share filesystems, the EFI System Partition is likely to be damaged on an EFI system.

To disable Fast Startup, see here for Windows 8 and here for Windows 10.

Shrink the Windows partition
You can skip this if there's already room for Gentoo partitions.

Windows 7

 * 1) Press the Windows-r to open the "Run" dialog, and enter diskmgmt.msc OR go to Control Panel/Administrative Tools and open Computer Management. Select the "Disk Management" option under "Storage" from the tree menu on the left.
 * 2) Right click on the target partition and choose “shrink volume”
 * 3) Provide the size of the shrink

Windows 8 or Windows 10:

 * 1) Press - (windows key and x key simultaneously).
 * 2) Choose “Disk Management”
 * 3) Right click on the target partition and choose “shrink volume”
 * 4) Provide the size of the shrink

Optional: Download and install rEFInd in Windows
Get rEFInd

Extract refind-bin-{version}.zip to a handy location. Suggest C:\.

Get directions; then install rEFInd from Windows to the Windows EFI System partition (ESP)

For simpler booting in some configurations, ensure that you've installed EFI filesystem drivers for the partition that holds your Linux kernel.

Screenshots from user Drake Donahue.

Obtain UEFI bootable Linux media
Download Get a System Rescue Cd iso Knoppix 7.2 is not a suitable substitute. Create a System Rescue Cd or System Rescue USB flash drive

Mount the sysresccd or USB drive and restart the computer. The CD or USB should appear as a choice in the rEFInd menu. If the bootable media does not appear in the rEFInd menu, select "Reboot to Computer Setup Utility", then in the BIOS screen check for an entry for the bootable media that is marked as "UEFI". Select that entry as the first boot choice.

Quick and easy
With an EFI System Partition provided by installation of Windows or self created, create the root (/) partition (and optionally other partitions) according to the Handbook and proceed with installation until Architecture specific kernel configuration. Complete kernel configuration according to EFI stub and proceed from Configuring the modules.

Reboot and enjoy an UEFI dual boot system!!

Alternative procedure
Exceptions/additions to the Gentoo Handbook:

Create partitions
Use ''instead of  or  for GPT disks. It's provided by.

START OF GDISK EXAMPLE:

gdisk /dev/sda GPT fdisk (gdisk) version 0.8.6

Partition table scan: MBR: protective BSD: not present APM: not present GPT: present

Found valid GPT with protective MBR; using GPT.

Command (? for help): p Disk /dev/sda: 500118192 sectors, 238.5 GiB Logical sector size: 512 bytes Disk identifier (GUID): C72786B7-C1FB-4A60-8F5F-216FA9097A98 Partition table holds up to 128 entries First usable sector is 34, last usable sector is 500118158 Partitions will be aligned on 2048-sector boundaries Total free space is 123357805 sectors (58.8 GiB)

Number Start (sector)    End (sector)  Size       Code  Name 1           2048          616447   300.0 MiB   2700  Basic data partition 2         616448          821247   100.0 MiB   EF00  EFI system partition 3         821248         1083391   128.0 MiB   0C01  Microsoft reserved part 4        1083392       376762367   179.1 GiB   0700  Basic data partition

Command (? for help): n Partition number (5-128, default 5): First sector (34-500118158, default = 376762368) or {+-}size{KMGTP}: Last sector (376762368-500118158, default = 500118158) or {+-}size{KMGTP}: +100M Current type is 'Linux filesystem' Hex code or GUID (L to show codes, Enter = 8300): Changed type of partition to 'Linux filesystem' Entering GPTPart::SetName(const UnicodeString...)

Command (? for help): n Partition number (6-128, default 6): First sector (34-500118158, default = 376967168) or {+-}size{KMGTP}: Last sector (376967168-500118158, default = 500118158) or {+-}size{KMGTP}: +1G Current type is 'Linux filesystem' Hex code or GUID (L to show codes, Enter = 8300): 8200 Changed type of partition to 'Linux swap' Entering GPTPart::SetName(const UnicodeString...)

Command (? for help): n Partition number (7-128, default 7): First sector (34-500118158, default = 379064320) or {+-}size{KMGTP}: Last sector (379064320-500118158, default = 500118158) or {+-}size{KMGTP}: Current type is 'Linux filesystem' Hex code or GUID (L to show codes, Enter = 8300): Changed type of partition to 'Linux filesystem' Entering GPTPart::SetName(const UnicodeString...)

Command (? for help): p Disk /dev/sda: 500118192 sectors, 238.5 GiB Logical sector size: 512 bytes Disk identifier (GUID): C72786B7-C1FB-4A60-8F5F-216FA9097A98 Partition table holds up to 128 entries First usable sector is 34, last usable sector is 500118158 Partitions will be aligned on 2048-sector boundaries Total free space is 2014 sectors (1007.0 KiB)

Number Start (sector)    End (sector)  Size       Code  Name 1           2048          616447   300.0 MiB   2700  Basic data partition 2         616448          821247   100.0 MiB   EF00  EFI System Partition 3         821248         1083391   128.0 MiB   0C01  Microsoft reserved part 4        1083392       376762367   179.1 GiB   0700  Basic data partition 5      376762368       376967167   100.0 MiB   8300  Linux filesystem 6      376967168       379064319   1024.0 MiB  8200  Linux swap 7      379064320       500118158   57.7 GiB    8300  Linux filesystem

Command (? for help): w

Final checks complete. About to write GPT data. THIS WILL OVERWRITE EXISTING PARTITIONS!!

Do you want to proceed? (Y/N): y OK; writing new GUID partition table (GPT) to /dev/sda. The operation has completed successfully.

Make file systems:

As long as the EFI stub kernel is in an ext2, ext3, ext4, ReiserFS, Btrfs, or FAT32 file system rEFInd will find it and add it to the menu.

Run :

The partition PARTUUID will be used in the kernel configuration in the form root=PARTUUID=92d3d504-9e7e-4c3d-9e56-15e3bd43511b.

Keep it handy.

Continue with the handbook through "7. Configuring the Kernel".

Kernel configuration
Use either "7.b. Default: Manual Configuration" or "7.c. Alternative: Using genkernel" but start genkernel with verses just. In addition to the items specified in the handbook or set by genkernel, enable the following:

In menuconfig:

General setup CONFIG_BLK_DEV_INITRD=y CONFIG_INITRAMFS_SOURCE="" CONFIG_RD_GZIP=y CONFIG_RD_BZIP2=y CONFIG_RD_LZMA=y CONFIG_RD_XZ=y CONFIG_RD_LZO=y CONFIG_RD_LZ4=y

If an initramfs is to be used, add an initrd="/boot/ " to the kernel configuration item "CONFIG_CMDLINE" as in the following example:

If systemd is to be used, add "init=/usr/lib/systemd/systemd" to the kernel configuration item "CONFIG_CMDLINE" as in the following example:

If systemd and an initramfs are to be used; example:

Use to build a manual kernel. Finish the Handbook. No need to emerge or install grub or lilo or grub2. rEFInd will act as the boot manager.

Alternative booting
You may consider boot options suggested by refind Linux page. If you going to stick with refind config setup would be a better decision. In few words you're not required to hardcode kernel launch arguments, instead you should provide in the  partition next to the kernel binary. It's also possible to select described in file boot options at refind launch screen (press F2 to invoke additional boot options menu). You could find additional info with examples of at refind linux page.

Dynamic disk
"Dynamic disk" in Windows can be thought as an analog of LVM in Linux, which is not recommendable for dual boot. (See this ArchWiki article for more.)

In, an ebuild of "libldm", which provides read/write access to dynamic disks, is submitted.

External resources

 * How to repair Windows' EFI bootloader ... ... if it accidentally got deleted


 * Gentoo subsystem on Windows 10