Dual-system Windows and Ubuntu

I did dual boot with Windows 7 & Ubuntu 14.04. I get both in boot menu but can't boot into Windows 7. The primary drive where Windows 7 was configured now shows to be logical drive with all files in it. How to resolve it ?

This is what it shows:

irshad@irshad-desktop:~$ lsblk
NAME   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sda      8:0    0 465.8G  0 disk     
├─sda1   8:1    0  58.6G  0 part /media/irshad/B2E08E69E08E339F    
├─sda2   8:2    0     1K  0 part     
├─sda5   8:5    0 195.3G  0 part /media/irshad/8E90A6A690A6946D    
├─sda6   8:6    0 182.8G  0 part /media/irshad/7650B08250B04B1F   
├─sda7   8:7    0    25G  0 part /   
└─sda8   8:8    0     4G  0 part     
sr0     11:0    1  1024M  0 rom  

I tried to run update-grub but I get the following result.

$ sudo update-grub 
Generating grub configuration file ... 
/etc/grub.d/06_custom: 31: /etc/grub.d/06_custom: function: not found 
/etc/grub.d/06_custom: 34: /etc/grub.d/06_custom: save_env: not found 
/etc/grub.d/06_custom: 36: /etc/grub.d/06_custom: Syntax error: "}" unexpected

At last I booted win 7 by using Testdisk. Link to solution if anyone has problem in booting windows even thought all the files are present/intact.

If you have damaged the boot sector of one of your partitions (e.g. by installing GRUB in it by mistake), you may have troubles. For example, if it is a Windows partition, you will not be able to boot into Windows any more.

Remark: if you have this problem, Boot-Repair should automatically warn and tell you the name (eg sda2) of the broken partition.

Here is how to repair it:

Via an Ubuntu disc

Step 1 - Boot on a liveCD or liveUSB

Boot your computer on a Ubuntu live-CD or live-USB, then choose "Try Ubuntu".

Step 2 - Install TestDisk in the live-session

Once in the Ubuntu live session, install TestDisk this way:

  1. Connect internet
  2. Open the Software Center, in the top bar click Edit -> Software Sources -> enable the Universe repository
  3. Open a terminal (Ctrl+Alt+T) and type :

    sudo apt-get update
    sudo apt-get install -y testdisk && sudo testdisk
    

Step 3 - Use TestDisk

  1. Via the arrows and the Enter key, go to the [No log] menu,
  2. then select the disk where the broken partition is,
  3. then select [Proceed],
  4. then choose the type of partition (generally [Intel]),
  5. then[Advanced],
  6. then select the broken partition with [Boot], it will display something like :

    Boot sector
    Status: Bad
    
    Backup boot sector
    Status: OK
    
    Sectors are not identical.
    
    A valid NTFS Boot sector must be present in order to access
    any data; even if the partition is not bootable.
    
    [  List  ]  [Backup BS]  [Rebuild BS]  [  Dump  ]
    
  7. Check that you have "Status ok" below "Backup boot sector"

  8. select [Backup BS].

Done

Via a Windows disc

This method is only able to fix the bootsector of a Windows partition.

  1. Get a Windows recovery disk, as explained on this page

  2. Boot on it, and use the 'fixboot' command (not the 'fixmbr' one). This should fix the bootsector of Windows.

source: Ubuntu official documentation


Boot your system using windows 7 installation CD to fix your Windows boot first.

Go to "repair your system" after selecting your language from first dialog.
use command prompt (Troubleshoot ► Advanced Options ► Command Prompt)
type bootrec /fixboot then hit enter
type bootrec /fixmbr then hit enter

THEN boot from Ubuntu live CD/USB and do below steps to restore your grub:

  1. Open a Terminal (use Ctlr+Alt+T)
  2. Mount /dev/sda7 (this one you can get from lsblk where root / partition mounted in) by the following commands: (run one by one)

    sudo mount /dev/sda7 /mnt
    for i in /sys /proc /run /dev;do sudo mount --bind "$i" "/mnt$i";done
    sudo chroot /mnt
    
  3. And run below command to install grub to main partition /dev/sda:

    grub-install /dev/sda
    
  4. Update grub and exit and reboot your system.

    update-grub
    exit
    sudo reboot