Sunday, April 30, 2017

Dualbooting Debian and Windows when you have already installed Debian.

When dualbooting Linux and Windows, it is often recommended to install Windows first because of the various difficulties of doing it in reverse (e.g. GRUB breaking). However sometimes you want to keep Linux on your computer. So let's start this guide.

Hardware you will need:
Computer with a hard drive big enough and enough free space to fit (Windows 10 and Debian)
3 flash drives at least one must be 6GBs
Extra external hard drive

Main software necessary:
Copy of Windows 10 (product key too if necessary)
Copy of Debian (on your computer)

1. You start with a computer installed with Debian. Preferably, the boot and home directories will be in separate partitions. Make sure to backup all your important data to your external flash drive.

2. Then you need to install GParted on the first flash drive.

3. With GParted on the flash drive, you stick the flash drive into your laptop then load up the Grub bootloader to load the USB instead from the hard drive.
a. Then, since you're not running GParted from the home partition, you can load up GParted and resize your hard drive so you have unallocated space. Usually the home partition is the largest partition so you would shrink that if you have space. I'd estimate at least about 100GB free space for each OS if you're planning on keeping any data or installing any applications. After GParted is done then you can shut down the computer and pull out your GParted flash drive.

4. Install Windows on your second flash drive. Since debian will most likely not be installed using UEFI, on the flash drive you must use the msdos format with a partition which has the boot flag. If the flash drive won't mount after reformatting it, then manually mount it yourself in a convenient location like /home/USERNAME/Documents/WindowsMount where USERNAME should be replaced with your own username on Debian. Assuming your Windows was downloaded as a disk image, either mount the image or right click and extract all the contents of the ISO to the flash drive. Windows is about 4Gbs so use your larger flash drive. After you have installed Windows on your flash drive, you must turn off the computer and turn it back on. When it gets to the manufacturer logo screen like ASUS or Dell, then you must immediately press the key for your BIOS menu. It is manufacturer dependent so you'll have to look up MANUFACTURER BIOS menu key and from there you have to choose to load from your usb. Once you've saved the settings, you turn off your computer again and it should load directly from your Windows USB.

5. Once you've gone through all the Windows settings (and most importantly turning off automatic updates), then you need to download Rufus and Boot Repair then on your third flash drive you use Rufus to install Boot Repair on your flash drive. Make sure to label your flash drive. After you've done that you also need to make a grub.cfg file (it's basically to install grub on your flash drive) on your flash drive which references your flash drive by the label you gave it. So then you need to turn off your computer and then boot it and on the DELL screen you need to press your BIOS menu key again and once again tell your computer to load from a USB flash instead. This time the label should be clearly visible as your selection. Then you load up the Boot Repair OS and select repair disk and it'll restore your Grub loader so that the next time you turn on your computer you'll see both your Debian installation (and the various recovery modes and whatnot) and an option to load Windows 10.

Congratulations you have successfully dualbooted Debian and Windows 10!