Except that you formatted Linux partitions by error during Windows 7 installation wizard, there is no reason to think your Ubuntu files aren't there any more. I had to reinstall my Windows 7 on my dual boot machine a couple of times and faced this problem. Windows installation overwrite your MBR and put there its own code. GRUB boot directory is intact, as long as you had it in your Ubuntu partition, but the MBR code written by GRUB isn't there any more.
The following procedure has some risk. I will adapt the commands to your partition numbers according to the screenshot you uploaded, but please, review the partition numbers two times before using my commands. Also, I don't accept any responsibility if something go wrong and you end having to backup your files and reinstalling Ubuntu.
As I don't sure the following works on GPT partition tables, lets add extra security and only do it if your disk is MBR, the command sudo parted -l
must show your partition table as msdos
in line 3 or 4 of its output. If not, stop here.
- Boot into your Ubuntu Live CD, please, same version that the one that lives in your hard disk.
- Confirm first that the directory /boot, exists in your Ubuntu root partition. I assuming it is sda2 as it is formatted as ext2, so mount it and navigate to its root and see if you have a boot directory there. If it isn't there stop here.
- Dismount sda2. Use Nautilus or Unity laucher or umount command, doesn't matter. But dismount it.
- Launch Terminal.
- Use the following commands (note, if I remember correctly, when using sudo from the Live CD, just press ENTER when prompted for a password):
:
sudo -i
mount /dev/sda2 /mnt
grub-install --root-directory=/mnt/ /dev/sda
umount /mnt
exit
- Reboot your machine. Remove Live CD.
If the grub menu appears and show both, Windows 7 and Ubuntu, you are done. If not, you will have to do extra work. I'm updating this question right now to add the longer method, I had to use it in one occasion because the shorter method above leaved me in the GRUB console without any operating system to chose, if this happens to you don't panic, I'm writing the longer method right now.
Longer method: do it if, at boot, you end in a console with no operating system to select or if Windows 7 (or Ubuntu) does not show in the list
- Boot into your Ubuntu Live CD, please, same version that the one that lives in your hard disk.
- Launch Terminal.
- Use the following commands (note, if I remember correctly, when using sudo from the Live CD, just press ENTER when prompted for a password):
:
sudo -i
mount /dev/sda2 /mnt
mount --bind /proc /mnt/proc
mount --bind /dev /mnt/dev
mount --bind /sys /mnt/sys
chroot /mnt update-grub
umount /mnt/sys
umount /mnt/dev
umount /mnt/proc
exit
- Reboot your machine. Remove Live CD.
You should see now both, Windows 7 and Ubuntu, as options in the GRUB boot menu.
Credits: http://www.ubuntugeek.com/how-to-restore-grub-boot-loader-after-installing-windows.html
Both methods were tested by me in my own machine and I confirm they work.
There is a third variation, in the case you had the boot directory in another partition that is not where the Ubuntu root is mounted, but as you formatted the other partition if this were the case you already lost it anyway so there is no point in it.
Remove the FlexNet crap from the boot sector we found during our discussion in chat.
GRUB refused to install to the mbr complaining about a sector being in use by FlexNet.
Afterwards reinstall the GRUB boot loader to your Ubuntu installation in legacy mode.
Boot from your ubuntu installation media and choose Try Ubuntu without installing.
When the Ubuntu desktop appears - open a terminal and execute :
sudo dd if=/dev/zero of=/dev/sda bs=512 count=62 seek=1
sudo mount /dev/sdc2 /mnt
sudo grub-install --boot-directory=/mnt/boot /dev/sda
Note : sda = disk | sdc2 = Ubuntu system partition
In case this solution does not work, open GParted and shrink the Windows partition on sda.
Start Install Ubuntu - choose Something else and install Ubuntu to the unallocated space.
If you want to clone your old system to the new partition use clonezilla for this.
Download Clonezilla Live CD and then create a bootable media to boot from it.
Backup the Ubuntu partition from the external disk to another disk or partition.
Restore it back to the partition where you performed the new install of Ubuntu.
Download and more information -> Clonezilla
Now boot from Ubuntu install media again ...
Identify the partition UUID's - open a terminal and execute :
sudo blkid
Mount the system partition and edit the fstab file - open another terminal and execute :
sudo mount /dev/sda* /mnt
sudo gedit /mnt/etc/fstab
Replace the UUID entries with the ones from the output given from the blkid command.
In case Ubuntu will not boot - reinstall GRUB ... boot from Ubuntu install media again ...
Open a terminal and execute :
sudo mount /dev/sda* /mnt
sudo grub-install --boot-directory=/mnt/boot /dev/sda
Replace * with the partition number you have Ubuntu installed.
If all this is too complex or complicated - you as well can keep the working Ubuntu configuration on sda and copy your personal data from your old Ubuntu on sdc to your new installation on sda.
Best Answer
Have you tried it with command in terminal? Just press Ctrl+Alt+T on your keyboard to open Terminal. When it opens, run the command(s) below:
if this does not help, then try
then
and finally at end
this should work.