Monday, June 25, 2012

Installing Windows after Ubuntu while dual-booting

    If you ever want to install windows on your system and dual boot with your current ubuntu installation, you don't have to get rid of your current installation. You can do it without re-installing ubuntu all-over again. 

Note : You need to have a working internet connection for the same or you need to have following five files correspong to your system architecture ( amd64 or i386 ) to proceed.
a) grub2-common_1.99-12ubuntu5_<architecture>.deb
b) grub-gfxpayload-lists_0.5_<architecture>.deb
c) grub-pc-bin_1.99-12ubuntu5_<architecture>.deb
d) grub-common_1.99-12ubuntu5_<architecture>.deb
e) grub-pc_1.99-12ubuntu5_<architecture>.deb
     You can download these from :

If your system satisfy the above condition then just do as in the following steps :

1) Back-up whatever you want to preserve. ( for worst-case scenario )

2) Have a Ubuntu CD / DVD / bootable USB disk with you. You will need it later on.

3) Create a partition for your windows installation from your ubuntu installation ( if you don't have one ) . The partion need-not to be formated as NTFS for now as you can do the same while installing windows. Just make a unformatted partition or simply create a blank free space (partition ) . You can do it via Gparted partition editor. If you don't have it installed , you can have it by entering following command in the terminal :
                       sudo apt-get update && sudo apt-get install gparted

4) Install Windows on the new partition.Remember not to touch the partition(s) containing your ubuntu installation or swap area.

5) At this point of time you won't be able to see or use your current ubuntu installtion as the system will straight boot into the new Windows installation.

6) Boot from your Ubuntu CD / DVD / bootable USB disk .

7) Open the terminal and enter the following command :

 i) sudo mkdir /mnt/temp ( creates a temporary directory for mounting your ubuntu partition )
ii) sudo mount /dev/sda2 /mnt/temp ( here /dev/sda2 is the partition where your ubuntu installation lies )
iii) Also mount some miscellaneous file-systems for proper working of chroot command : 
        for i in /dev /dev/pts /proc /sys; do sudo mount -B $i /mnt/temp$i; done
iv) Now chroot into your ubuntu Installation :
                                  sudo chroot /mnt/temp
v) If the above commands run successfully, the terminal prompt should include "root" ( root@ubuntu:/# ), which indicates you are in the chroot environment.
vi) Confirm you have working net connection in the chroot environment ( for downloading the grub installation files if you have not already downloaded it ) :
                               ping archive.ubuntu.com
vii) Update your package list : This step is optional if you have already downloaded the grub files.
                                sudo apt-get update
viii) Purging the Grub Loader : Do not proceed to next command if you don't have a working internet connection or you do not have access to downloaded grub files . The next command will remove grub, grub-pc (Grub 2) and grub-common. If you are sure you have never had Grub legacy on the current installation you may omit "grub" from the next command.
                             apt-get purge grub grub-pc grub-common
Here is what you will have to do:
  • Press ENTER to continue.
  • Read the warning during the install about removing the bootloader. TAB to highlight "<Yes>" and press ENTER.
viii) Re-install the grub packages : 
                   Command :
                           apt-get install grub-common grub-pc
Here is what will happen:
  • You will be given the opportunity to add extra kernel options to the kernel line. If you don't know, you probably don't need them ; TAB to highlight "<OK>" and press ENTER.
  • Read the installation notes. TAB to "<OK>" to continue.
  • When presented with the device option, use the Up/Down keys to select the correct drive ( /dev/sdX ).
  • Make sure the installation drive [*] /dev/sdX has an asterisk next to it ( example: [*] /dev/sda ). 
  • If it doesn't, highlight it and press the SPACE bar to select it. Do not select a partition ( example: [ ] /dev/sda5 , etc). 
  • TAB to "<OK>" and press ENTER. When it has finishing the installation, you should have Grub 2 installed.
ix) Update the Grub Loader files
                     update-grub
x)- Exit the chroot environment
                       exit
If you have successfully exited chroot, the terminal prompt should return to the Ubuntu Live CD prompt ( ubuntu@ubuntu:~$ ).

8) Reboot your system and you will be presented a grub based boot-menu containing the choice of operating systems ( including Windows ) you want to boot.There it goes ....

Have a happy Ubuntu Experience...

No comments:

Post a Comment