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.
Installing Windows after Ubuntu is not the recommended process for a dual boot Windows and Ubuntu system, but it is possible.
First, you have to make sure that the 50GB free space is available, resizing your Ubuntu by using gParted if necessary.
Also use gParted or Disk Utility to format the the free space as NTFS, this prevents Windows 7 from creating an additional boot partition in addition to the "C" drive.
Next, boot to the Windows DVD installer and install Windows on the NTFS partition. Upon reboot, Windows will automatically boot and you won't see the grub menu allowing you to choose Ubuntu, because the Windows bootloader has replaced grub.
Now, what you need to do is run Ubuntu from LiveCD or LiveUSB and installboot-repair.
To install boot-repair, open up a terminal by pressing Ctrl+Alt+T and type the following commands:
This answer covers UEFI-only, and is meant to be a bit of a more modern answer as UEFI has succeeded the ancient BIOS. Also, there are some edits here to fit the fact it's answering a "how I do this" rather than a "can I do this" type of question.
To install Windows alongside Ubuntu, you just do the following:
Insert Windows 10 USB
Create a partition/volume on the drive to install Windows 10 on alongside Ubuntu (it'll create more than one partition, that's normal; also make sure you have space for Windows 10 on your drive, you might need to shrink Ubuntu)
Install the Windows 10.
That's it!
Note: when making sure things are ready for your dual boot, check if Ubuntu is installed in the GPT partition table! While 99% of the time you will be using GPT if you're planning to do this, it is possible to install Ubuntu's UEFI on MBR but Windows 10 does not support that strange use-case. In that situation, convert to GPT if possible. If not, backup and reinstall, and I'd recommend that as it'll be easier.
When you boot have you checked the boot order on your BIOS? If you're booting straight to the hard drive it will always miss the USB. You need to move the USB device boot option higher in the priority list.
Also check that your computer allows you to boot from USB in the USB port you are using.
First, you have to boot with a live CD/USB stick and shrink your partition in order to create a second one. Windows 7 requires and creates a second partition which is called "system reserved". I don't know why, but it does. (So you will end up with three partitions or four if you have a swap partition.)
When your partition is ready, just boot with your Windows 7 DVD/USB stick and install Windows 7 on the new partition.
When Windows 7 has been installed, GRUB will break and you will only be able to boot Windows (automatically). Just boot with a live Ubuntu CD/USB stick and fix it (how it is mentioned in other comments).
Now another issue that some users may face:
I own an HP Mini 210 netbook which came with Windows 7. I erased everything and installed Ubuntu. Later on I decided to also reinstall Windows 7 and have a dual boot (needed Windows for a specific application from my university which wouldn't run through wine). At that time I had three partitions:
- Ubuntu
- Swap
- Backup/download storage
Now when I tried to install Windows 7 I faced a problem because Windows 7 needs to create a second primary partition (system reserved). I already had three partitions and therefore was unable to create two more. The workaround here is to create an extended partition in which you will include both swap and backup storage. Now I have:
- Ubuntu (primary)
- Extended
- Swap
- Backup/download storage
- Windows 7 (primary)
- Windows 7 system reserved (primary)
In case your computer came with a pre-installed copy of Windows 8 and you removed it because to many people told you to hate it and you found that after you installed Ubuntu, that it isn't what you want, note this:
Your computer boots with UEFI and has a GPT partition table.
For installing Windows 7, either create and boot the Windows 7 installation media in UEFI-mode or set boot-mode and partition table to legacy.
The most save way is to install Windows 7 first and to reinstall Ubuntu after that. This will ensure that grub works.
You can also edit your partitions with a live cd, and then install Windows 7. When you have done this you boot into Ubuntu with a live cd and restore grub. This procedure however, is a bit more delicate than just installing them in the right order.
To install Windows you need an empty partition that will be dedicated to Windows. If you do, then go ahead and install on this using the normal installation procedure. After installation, reboot into Windows and reboot a few times more to experience Windows ;-) (sorry, couldn't resist)
Like you said, this will break GRUB and your computer can only boot Windows after this. Do not despair, as there is a help section dedicated to restoring GRUB and being able to dual boot. Look here. After performing this, your computer will be able to boot Ubuntu as well as Windows.
Before you start, very very carefully note down the location (hard drive number, make & partition number within that) of the current Ubuntu install (which you don't obviously want to overwrite) and the empty partition in which you want to install windows. Also, during Windows installation, if it offers to format any partition other than the one you are installing Windows into, please do not accept.
I suggest you virtualize Windows 7 with something like VirtualBox (http://www.virtualbox.org)
This way you can run Windows and Linux at the same time, without the chance of destroying you Bootloader Grub.
I don't know why you want to run Windows 7, but if you don't need the full hardware capacity (Running the Latest 3D Games for example) of your computer for windows then virtualization can be a good solution.
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.
Installing Windows after Ubuntu is not the recommended process for a dual boot Windows and Ubuntu system, but it is possible.
Next, boot to the Windows DVD installer and install Windows on the NTFS partition. Upon reboot, Windows will automatically boot and you won't see the grub menu allowing you to choose Ubuntu, because the Windows bootloader has replaced grub.
Now, what you need to do is run Ubuntu from LiveCD or LiveUSB and install boot-repair.
To install boot-repair, open up a terminal by pressing Ctrl+Alt+T and type the following commands:
After installation, boot-repair will automatically launch, if is doesn't, launch it via Dash.
Make sure to select recommended repair to repair grub. Reboot and that's it.
UEFI only!
This answer covers UEFI-only, and is meant to be a bit of a more modern answer as UEFI has succeeded the ancient BIOS. Also, there are some edits here to fit the fact it's answering a "how I do this" rather than a "can I do this" type of question.
To install Windows alongside Ubuntu, you just do the following:
That's it!
Note: when making sure things are ready for your dual boot, check if Ubuntu is installed in the GPT partition table! While 99% of the time you will be using GPT if you're planning to do this, it is possible to install Ubuntu's UEFI on MBR but Windows 10 does not support that strange use-case. In that situation, convert to GPT if possible. If not, backup and reinstall, and I'd recommend that as it'll be easier.
boot-repair did a really good job launched from a live-usb, by just applying the recommended option.
When you boot have you checked the boot order on your BIOS? If you're booting straight to the hard drive it will always miss the USB. You need to move the USB device boot option higher in the priority list.
Also check that your computer allows you to boot from USB in the USB port you are using.
First, you have to boot with a live CD/USB stick and shrink your partition in order to create a second one. Windows 7 requires and creates a second partition which is called "system reserved". I don't know why, but it does. (So you will end up with three partitions or four if you have a swap partition.)
When your partition is ready, just boot with your Windows 7 DVD/USB stick and install Windows 7 on the new partition.
When Windows 7 has been installed, GRUB will break and you will only be able to boot Windows (automatically). Just boot with a live Ubuntu CD/USB stick and fix it (how it is mentioned in other comments).
Now another issue that some users may face:
I own an HP Mini 210 netbook which came with Windows 7. I erased everything and installed Ubuntu. Later on I decided to also reinstall Windows 7 and have a dual boot (needed Windows for a specific application from my university which wouldn't run through wine). At that time I had three partitions:
Now when I tried to install Windows 7 I faced a problem because Windows 7 needs to create a second primary partition (system reserved). I already had three partitions and therefore was unable to create two more. The workaround here is to create an extended partition in which you will include both swap and backup storage. Now I have:
In case your computer came with a pre-installed copy of Windows 8 and you removed it because to many people told you to hate it and you found that after you installed Ubuntu, that it isn't what you want, note this:
Your computer boots with UEFI and has a GPT partition table.
For installing Windows 7, either create and boot the Windows 7 installation media in UEFI-mode or set boot-mode and partition table to legacy.
The most save way is to install Windows 7 first and to reinstall Ubuntu after that. This will ensure that grub works.
You can also edit your partitions with a live cd, and then install Windows 7. When you have done this you boot into Ubuntu with a live cd and restore grub. This procedure however, is a bit more delicate than just installing them in the right order.
To install Windows you need an empty partition that will be dedicated to Windows. If you do, then go ahead and install on this using the normal installation procedure. After installation, reboot into Windows and reboot a few times more to experience Windows ;-) (sorry, couldn't resist)
Like you said, this will break GRUB and your computer can only boot Windows after this. Do not despair, as there is a help section dedicated to restoring GRUB and being able to dual boot. Look here. After performing this, your computer will be able to boot Ubuntu as well as Windows.
Before you start, very very carefully note down the location (hard drive number, make & partition number within that) of the current Ubuntu install (which you don't obviously want to overwrite) and the empty partition in which you want to install windows. Also, during Windows installation, if it offers to format any partition other than the one you are installing Windows into, please do not accept.
I suggest you virtualize Windows 7 with something like VirtualBox (http://www.virtualbox.org)
This way you can run Windows and Linux at the same time, without the chance of destroying you Bootloader Grub.
I don't know why you want to run Windows 7, but if you don't need the full hardware capacity (Running the Latest 3D Games for example) of your computer for windows then virtualization can be a good solution.