Step Zero – Backup your important data before doing anything
Step One – Make space for Windows
Open up GParted, and make sure that you have at least 20 GB available for Windows 7, either as a partition you can remove, or as unpartitioned space. If it's a partition, remove it from GRUB to make sure it doesn't break your Ubuntu install — GParted will complain if anything bad is about to happen.
Make note of current /boot device. If that doesn't show up there, make note of the / device. The device name is something like sda5.
Step Two – Install Windows
Install Windows 7 into the space you just made
Step Three – Mount /boot
Note: Instead of mounting the boot directory or partition from the installation in the live media environment you can specify the path with the --boot-directory parameter for grub-install, more information on the manpage.
Load up from your Ubuntu live CD, and then run these commands.
If you DO NOT have a separate /boot partition:
sudo mount /dev/DEVICENAME_FROM_STEP_ONE /mnt
sudo rm -rf /boot # Careful here, make sure YOU ARE USING THE LIVE CD. I tried it, it works.
sudo ln -s /mnt/boot /boot
If you have a SEPARATE /boot partition:
sudo mount /dev/DEVICENAME_FROM_STEP_ONE /boot
Step Four – Install the bootloader
Note: These instructions were initially written for Windows 7 and BIOS booting computers. If you have UEFI and Windows 8 and above you probably need to replace grub-pc with grub-efi-amd64 in sudo apt-get install grub-pc.
Then continue with those commands:
sudo apt-get update
sudo apt-get install grub-pc
sudo grub-install /dev/sda # NOTE THAT THERE IS NO DIGIT
sudo umount /boot
And restart. It should work fine and boot both systems.
You did install Ubuntu using the BIOS/legacy boot option -- that's what "CSM" is. (This acronym expands to "Compatibility Support Module," which is EFI-speak for BIOS compatibility mode.) Thus, setting the "OS mode selection" in your firmware to "CSM" for the installation essentially tells your computer to boot only in BIOS/legacy mode.
There are a number of possible solutions. These include:
Install my rEFInd boot manager in Windows. Edit the refind.conf file: Uncomment the scanfor line and add hdbios to its options. When you reboot, rEFInd should come up and show at least two boot options. One should boot Windows and the other should start up GRUB in BIOS mode, which should in turn launch Linux. If you try this and want to experiment more, you could try tweaking the configuration to boot Linux directly in EFI mode.
Convert your existing Ubuntu installation to boot in EFI mode by adding a suitable EFI-mode boot loader. rEFInd can serve this purpose, or you could install ELILO or the EFI version of GRUB 2. The trick is registering the EFI boot loader with the firmware, which requires an EFI-mode boot of Linux or doing the work from Windows. (The preceding option does this for rEFInd by doing the work in Windows.) See my EFI Boot Loaders for Linux site for more on your options on this score. This approach has a fairly steep learning curve, but it's a fairly clean approach. There's the caveat about EFI-mode boots possibly having problems on your system, though.
Re-install Ubuntu in EFI mode. This will require overcoming your kernel panic problem, though, and I don't have any specific suggestions on doing that. Perhaps adding (or removing) a kernel option would do the trick, or switching to another kernel version (but this is awkward for an installer's kernel).
Overall, I'd say your easiest course of action is to install rEFInd. It will probably enable you to boot Linux in EFI mode, and it provides a path to experiment with EFI-mode booting if you decide to pursue that.
Disable UEFI boot support . Now try to install again. If not working follow these steps...
Shrink your Windows partition
Windows takes up the whole of the drive when it is first installed. In order to install Ubuntu you will need to make space for it.
Press the "super key" (Windows key) on your keyboard and click the magnifying glass in the top right corner. In the search box start typing "Partitions".
Click on the option called "Create and format partitions". This will bring up the "Disk Management" screen.
To shrink the drive, right click on the "OS (C:)" volume and select "Shrink volume".
A screen will appear showing how much you can shrink the drive by. You can of course choose to shrink the drive by less than offered but never go for any more than offered as you will break your Windows 8.1 operating system if you do.
Click "Shrink" to continue.
When you are finished you will see that there is a lot of unpartitioned space. This is where Ubuntu will be installed.
Turn off fast boot
Turn off secure boot
Install Ubuntu
Best Answer
Here's the general outline:
/boot
directory or partitionStep Zero – Backup your important data before doing anything
Step One – Make space for Windows
Open up GParted, and make sure that you have at least 20 GB available for Windows 7, either as a partition you can remove, or as unpartitioned space. If it's a partition, remove it from GRUB to make sure it doesn't break your Ubuntu install — GParted will complain if anything bad is about to happen.
Make note of current
/boot
device. If that doesn't show up there, make note of the/
device. The device name is something likesda5
.Step Two – Install Windows
Install Windows 7 into the space you just made
Step Three – Mount
/boot
Load up from your Ubuntu live CD, and then run these commands.
If you DO NOT have a separate
/boot
partition:If you have a SEPARATE
/boot
partition:Step Four – Install the bootloader
Then continue with those commands:
And restart. It should work fine and boot both systems.