I had a system with dual booting of Windows and Ubuntu. Windows was Installed First and Ubuntu Second. Now Windows is all virus- Virus and I want to format it. but once I format and reinstall windows the Bootloader won't show any options to boot into Ubuntu. The Bootloader will be of windows by default. How can I format Windows but keep the Bootloader of Ubuntu ?
This will only work if this was a GRUB dual boot. If you have used wubi to install it, then recovery is a bit harder.
First, create an Ubuntu Live CD or thumb drive.
Next, boot into the CD/Pen drive, and use the "try ubuntu" option.
Now, open the terminal and type
sudo fdisk -l. Find out which partition is the "Linux" partition. Let's call it
sudo mount /dev/sdaX /mnt sudo mount --bind /dev /mnt/dev sudo mount --bind /proc /mnt/proc sudo mount --bind /sys /mnt/sys sudo mount --bind /dev /mnt/dev sudo mount --bind /proc /mnt/proc sudo mount --bind /sys /mnt/sys sudo update-grub sudo grub-install /dev/sda sudo umount /mnt/dev sudo umount /mnt/proc sudo umount /mnt/sys sudo umount /mnt/usr sudo umount /mnt sudo reboot
If you mean format Windows with the bootloader created (Assuming with Wubi) inside of it, then it is not possible (At least to my knowledge). This is because the boot loader is still inside the Windows environment and when you format that partition, well you pretty much are eliminating everything in it, including the boot part or at least a part of the boot part related to the system (In the case of a separated system partition for this).
You need and I highly recommend (Which is much better) to have the bootloader outside of the Windows environment, first for safety reasons, second for performance reasons. This is done with a LiveDVD or LiveUSB of Ubuntu. The reason behind this and also the reason (One of many as to why I do not recommend using Wubi) is because:
If you have the boot part that manages Windows and Ubuntu inside the Windows environment and somehow Windows gets corrupted, you loose both. Even the option to boot from Ubuntu to repair Windows is gone (Assuming you do not have in that moment a Live Ubuntu CD/DVD/USB).
There has been many cases where using Wubi has resulted in loosing by corruption do to Windows either the Linux boot part or both. You do not even have to do a lot of research for this, just look in the Ubuntu forum or Askubuntu. Heck, just look into any Linux distro that has nicely tried to have the boot part inside the Windows file system.
The boot part does not play nicely when left inside Windows, specially when some "upgrades" in Windows (Windows 7 and 8) appear that magically happen to damage the boot part for Linux. Remember, this is not using GRUB as we know it but the Windows boot menu.
Having the boot loader (GRUB when outside the Windows file system) outside the Windows file system gives you more flexibility over problems like Viruses in Windows, file system corruption in Windows, making backup of files, etc.. since you have Ubuntu as a backup OS.
When you encounter a problem with GRUB, you can in most cases fix it quickly and easily, either with a LiveCD or some basic commands. When you have it inside Windows, it's a bit trickier (Not easy).
If you have the boot loader outside the Windows environment, it is much easier to accomplish an easy task such as formatting Windows because of viruses and not worry about the boot part for it. Ubuntu will take care of that. If not, in many cases a simple execution of
sudo update-grubwill help.
Right now you can download a LiveCD/LiveDVD/LiveUSB of Ubuntu and install/reinstall Ubuntu from it. This will make sure the boot part is outside the Windows environment. After testing to see you get the GRUB menu telling you which system to use (Either Ubuntu or Windows) before going to the Windows environment, then you are ready to simply format the Windows part and install it again.
This however will imply that you will need to redo the boot part since Windows is not kind when other Operating systems are in the same PC. What I would recommend then would be to:
Reinstall you Windows, do not worry about Ubuntu.
With a Live copy of Ubuntu, reinstall Ubuntu using the LiveCD. Do not boot from inside Windows, boot the Live copy from the CDROM, DVDROM or USB. This way you make sure the boot part (GRUB) is outside the Windows system and you avoid many problems caused by our friendly Windows environment.