So its been a week long struggle to get the Kali Linux 2016 up and running alongside Windows 10 in my PC(HP Pavilion 15-p073tx). Quite a learning experience, given that I am new to firmware and booting stuff. But as usual the internet comes to the rescue with lots of tutorials online. But as it turns out its very difficult to tackle the specific problem that I faced and had to refer many sources to get it to work. I hope this post helps with at least some of the doubts that one might face during the process.
The most important thing in following any tutorial is to understand what you are doing. Just following them works until you mess up somewhere and are left clueless what might have gone wrong. No need to get to the depth of the stuff because that's not practical. So I tried to get a minimal understanding and that's what this post is about.
THE HURDLE
UEFI(Unified Extensible Firmware Interface). Since Windows 8, UEFI Secure Boot Protocol was implemented. UEFI is the successor to BIOS. This new thing was introduced to overcome the shortcomings of BIOS one of them being to prevent boot-time malware injection. So comes the problem trying to boot through a USB flash drive or a CD/DVD for installing Linux. UEFI performs a bootloader check and only the ones with a secure digital key pass through. Some of the Linux distributions like Red Hat, Ubuntu etc supposedly have bought these digital keys and thus are easier to install. That's not the case with Kali Linux. There are many tutorial videos on YouTube showing how to install Kali Linux in UEFI mode and the best one I found and followed (most of the part) is from
https://www.youtube.com/watch?v=7m6ALEZKO3Q (I actually appreciate and thank Nehal J Wani , the man behind the video for the tutorial and replying to my queries!) I will be summarizing the process in the coming sections.
The next hurdle is to get the installed Kali Linux identified and get the booting option on starting the PC. The Linux distributions come with the bootloader GRUB. But from the experience of people I found in the comment sections of these many tutorials, I have learnt that it has many glitches(like the PC directly boots into Windows without asking options and stuff). During the Linux installation process, it identifies the Windows 10 OS and asks you to install GRUB. Many tutorials install grub and then later fix it while in the tutorial in the video mentioned above, he doesn't install it and does that later. But I did it differently and will explain soon.
THE PROCESS
1) We need to create a partition in the Hard Disk to install Kali linux. This is done using
Disk Management which can be accessed by right clicking on the window icon on bottom left of windows 10 or through run command as shown in tutorial.
2) Shrink the existing large partition(Don't touch the EFI or System Partition. They are small too by the way). I have a 1TB hard disk and I chose to allocate 50GB to Linux.
Do not create a new partition. Make sure it remains as "Free Space" or "Unallocated".
3) Download the Kali linux iso file from the website (
https://www.kali.org/downloads/). Choose the 64bit or 32bit version depending on your system. Burn this iso image to a dvd. Windows 10 can do this without third party software. Just right click and choose "Burn disk image".
4) Insert the dvd. Now we need to disable fast startup. Type "power options" in the search. On the left you will find "Choose what power button does". You will find "change settings that are currently unavailable". click on that and then at the bottom you can uncheck the fast startup option. You can turn it on later.
5) Now we need to disable the Secure Boot option from the boot menu. So, restart the PC and access the BIOS settings. You need to press a particular key repeatedly before startup. In my case it was the Esc button. Find BIOS settings and you can see Secure boot enabled and Legacy Boot disabled. Choose the Secure Boot and disable it. In my case it automatically enables Legacy Boot.
6) Save the settings and again before the actual startup of the PC, press the key repeatedly. This time go to the "Boot Device" menu and boot through the internal CD/DVD. Disabling secure boot alows to boot in BIOS mode instead of UEFI . Else if you try booting in UEFI, you end up with an authentication error (in which case just press ok and boot normally to windows, restart and this time do it right:P ).
7) Follow all the steps from this point in the tutorial till the finishing of installation of Kali Linux.
You would have got a "no boot loader installed" message and then finish the installation)
8) Here is where I took a different path. I had made a system rescue cd. The tutorial requires you to boot it in UEFI mode (he made a video on making this bootable media too in both UEFI and Legacy mode). But for some reason, I kept getting the authentication error on trying to boot from UEFI mode even though i followed all the steps in tutorial. So I had to do some learning to get into my Linux through some other means.
THE DETOUR
During the search to rectify this problem, I stumbled upon something called rEFInd which I later learned is a boot manager (popularly used for dual booting linux on Macs). The website
http://www.rodsbooks.com has everything one can possibly find to lean about rEFInd. But I felt it was complicated and struggled to get my work done. So this is what I did in simple steps. You can always refer to the website for detailed explanations.
1) Download the rEFInd image file from
http://www.rodsbooks.com/refind/getting.html . I chose to make a USB flash drive (because I had 1GB pen drive lying around) so downloaded the USB Flash drive image file. You can instead download CD-R file and burn the iso on a CD. In case of USB, we need to copy the image file to the pen drive using low level copying. For this I used Win32 disk manager. The interface is easy and you will figure out how to copy easily.
NOTE: On doing the low level copying, the pendrive memory size appears to be reduced and formatting wont help. So if you want to reuse the pendrive after the process, you can refer to
https://www.youtube.com/watch?v=_TRWUJ1oZHc
2) Make sure Secure Boot is still disabled. Insert the pen drive and access the "Boot Device" menu as before. You will find your flash disk in the menu but you will have two options, one followed with
"(UEFI)" and the other without. Make sure you check the one with UEFI.
3) You will be greeted with a graphical menu. Choose the Linux (penguin icon) and for the first time, you are inside Kali Linux you installed.. (yaay!)
All we need to do now is to install rEFInd boot manager and we are done!
The download can be made from within Linux or use other PC to do it.(I has configured my network during Linux installation while using wired net connection. And for some reason, Kali linux didn't recognize my Broadcom wifi adapter now and thus had to use this video to rectify it later
https://www.youtube.com/watch?v=tkDaK8589KY ). So, just make sure you have the Binary Debian package which comes as .deb file inside your linux.
5) Using terminal navigate to the folder containing the .deb file and then use the command
dpkg -i refind_0.10.3-1_amd64.deb
6) The installation process will take place. Either you end up with a successful installation or get a few error messages with possible suggestions.
7) In my case, the problem was efibootmgr couldnt be run. The solution was to rename refind_x64.efi to the bootloader it is replacing.
8) Find EFI/BOOT or/and EFI/Microsoft/Boot. Rename EFI/BOOT to EFI/OldBoot. Find refind folder within EFI folder and bring it to EFI/refind. Rename this to EFI/BOOT. Now rename refind_x64.efi to bootx64.efi if you have 64 bit PC or any corresponding bootloader (The error message specifies the name or you can browse inside EFI/OldBoot to check .efi file exists and rename to that). Coming to EFI/Microsoft/Boot, find bootmgfw.efi. Move it to EFI/Microsoft. Copy and paste the contents of EFI/refind into EFI/Microsoft/Boot and rename refind_x64.efi to bootmgfw.efi. Weirdly(or not) I had both the directories so I did both. (you can find the instructions in http://www.rodsbooks.com/refind/installing.html under "Renaming the files manually")
This was to allow the rEFInd bootmanager to start first instead the ones you replaced.
After this run "dpkg -i refind_0.10.3-1_amd64.deb" again and this time installation was successful!!
You can remove the USB, restart the PC and you will have the boot loader up giving option to boot onto Windows 10 or Kali Linux.
AND WE ARE DONE!
So now we have a dual booting of Kali linux and Windows 10!.. Its working pretty fine for me. Though the Secure Boot must be kept disabled, I think Kali linux is booting in UEFI only because the rEFInd bootmanager booted in UEFI through USB before. I would Appreciate if somebody could tell me a trustworthy way to check this because I got confused from the different solutions I found online.
That's all.. HAVE FUN..