Wednesday, August 14, 2013

Dual boot Debian 7 Wheezy on existing Win8 UEFI machine


I don't want to bother giving a lengthy background or info... So I'll just try to make this post a short mash up of what you need to know.

Prelude: Dual-booting a laptop/machine wherein there is an existing Windows 8 installed in a UEFI boot-up environment

First off, you'll probably need to do some shrinking of existing partitions. In my case, I just shrank my Windows8 drive C: using the disk manager build-in under the "Computer Management".

Afterwards, you'll need to use a UEFI-bootable linux image. For me, I used a PXE bootable Debian 7 Wheezy-stable image and created a root, swap, and home partition from the unused space. Do take note that you need to use the new GPT partitioning (for those with fresh hard drives); this option is usually asked or selected when using the "advanced mode" when installing.

Now here is the tricky part... after you proceed to install GRUB, that grub instance will not work later after finishing the installation. You will need to use an external USB linux image or disk that can boot as UEFI. This is not necessarily need to be a Debian USB image as I used a Kubuntu 13.04 image and placed it in a USB stick.

Use the USB stick to boot the machine up and use its GRUB rescue to manually boot the already installed Debian. For those a bit lost on using the GRUB rescue command line, below are the lines I used.

set prefix="(hdX,gptX)/boot/grub"
set root="(hdX,gptX)"
insmod normal
normal


Note that the prefix is just to denote the location of the grub installation folder, so the value might change depending on your partition layout. On the example I gave, I only have a root partition so I had to specify the "boot" folder. If your case is that you created a separate "/boot" partition, the prefix would probably look like...

set prefix="(hdX,gptX)/grub"


Once you have managed to boot-up to your installed Debian partition, log-in to your root (or use sudo if that's your preference) and install the following packages:

# apt-get install grub-efi-amd64 efibootmgr

We then have to mount temporarily the partition containing the already existing EFI loader of Windows. This is usually around 250-300MB in partition size and contains files and folders with names like "Boot" and "EFI". I'll leave it up to you which or what partition number that may be.

# mkdir /boot/efi
# mount /dev/sdaX /boot/efi

Next is loading the driver/module for the EFI support, which will then aid with the re-install and detection of GRUB of the existing EFI Windows 8 partition and creating a Debian EFI entry.

# modprobe efivars
# grub-install /dev/sda
# update-grub

Kindly check if there is a new EFI entry present on the output displayed upon executing the "update-grub". Also, check inside /boot/efi if there is a new folder or entry that matches in terms of the name of the EFI entry listed a while back.

If all goes well, you will see a new UEFI boot priority inside your BIOS apart from the UEFI Windows Boot Manager.

Hope this helps!


Other resources that you might find useful:



4 comments:

  1. Hi,

    Thanks for the great tutorial, but I've got a problem: when I execute " grub-install --directory=/dev/ /dev/sda" (because without --directory it said it would'nt work), it says it " Can't open /dev//modinfo.sh"
    And when I look to find it, it isn't there. Also, modprobe efivars doesn't work.
    I've tried searching for a solution, but no solution worked for me so far.
    I'm using Jessie instead of Wheezy.

    ReplyDelete
  2. But when I use efivarfs instead, it does work, but nothing new is added. Meh, I'll try some more stuff.

    ReplyDelete
  3. @Tobias: usually grub-install doesn't need the "directory" parameter unless it is specifying a non-conventional location or the /boot partition is not mounted as itself.

    The efivars should be included when you install the efibootmgr. Not sure though in Jessie if they changed the included packages as a suggestion or pre-reqs.

    Nonetheless, I bid you good luck on your endeavor!

    ReplyDelete
  4. Backing up data in advance is really important. Or you would have to use
    western digital hard drive recovery software for help, which is really troublesome.

    ReplyDelete