Find the answer to your Linux question:
Page 1 of 2 1 2 LastLast
Results 1 to 10 of 19
I had ubuntu 12.04 and Win7 installed in my system. Yesterday Windows crashed and i had to format and re-install it. I have not touched the Linux drive (swap and ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Sep 2012
    Posts
    5

    [Help] Ubuntu and Grub2 lost after re-installing windows 7


    I had ubuntu 12.04 and Win7 installed in my system.
    Yesterday Windows crashed and i had to format and re-install it.
    I have not touched the Linux drive (swap and main are intact)
    But Grub is not shown and system boots into windows
    I need linux back

  2. #2
    Super Moderator devils casper's Avatar
    Join Date
    Jun 2006
    Location
    Chandigarh, India
    Posts
    24,729
    Boot up from Ubuntu LiveCD/USB and execute this in Terminal :
    Code:
    sudo mount /dev/sdaX /mnt
    sudo grub-install --root-directory=/mnt /dev/sda
    sudo umount /mnt
    Replace X in first command with actual root partition number. Let say, you have installed Ubuntu in /dev/sda3. Replace X with 3 in mount command. Reboot machine and GRUB2 will be back in business.
    It is amazing what you can accomplish if you do not care who gets the credit.
    New Users: Read This First

  3. #3
    Just Joined!
    Join Date
    Sep 2012
    Posts
    5
    Quote Originally Posted by devils casper View Post
    Boot up from Ubuntu LiveCD/USB and execute this in Terminal :
    Code:
    sudo mount /dev/sdaX /mnt
    sudo grub-install --root-directory=/mnt /dev/sda
    sudo umount /mnt
    Replace X in first command with actual root partition number. Let say, you have installed Ubuntu in /dev/sda3. Replace X with 3 in mount command. Reboot machine and GRUB2 will be back in business.
    I am sorry to say this, but I am a total noob and doesnt know which sda i have installed ubuntu on. I will give u details of my hdd partition so that you can help me figure this out

    My HDD is like this

    [Win7-60GB-NTFS] [LinuxSwap-8GB] [Linux Main Drive-80GB] [Extended Volume with 5 Logical Drives - NTFS]

    I hope u can help me with this

  4. #4
    Super Moderator devils casper's Avatar
    Join Date
    Jun 2006
    Location
    Chandigarh, India
    Posts
    24,729
    Boot up from Ubuntu LiveCD/USB and execute this
    Code:
    sudo fdisk -l
    Post the output here.
    * Its small L in fdisk -l.
    It is amazing what you can accomplish if you do not care who gets the credit.
    New Users: Read This First

  5. #5
    Just Joined!
    Join Date
    Sep 2012
    Posts
    5
    Quote Originally Posted by devils casper View Post
    Boot up from Ubuntu LiveCD/USB and execute this
    Code:
    sudo fdisk -l
    Post the output here.
    * Its small L in fdisk -l.
    Thanks for the reply casper. I am posting the content below

    Disk /dev/sda: 1000.2 GB, 1000204886016 bytes
    255 heads, 63 sectors/track, 121601 cylinders, total 1953525168 sectors
    Units = sectors of 1 * 512 = 512 bytes
    Sector size (logical/physical): 512 bytes / 4096 bytes
    I/O size (minimum/optimal): 4096 bytes / 4096 bytes
    Disk identifier: 0xab12e771

    Device Boot Start End Blocks Id System
    /dev/sda1 * 2048 206847 102400 7 HPFS/NTFS/exFAT
    /dev/sda2 206848 125841407 62817280 7 HPFS/NTFS/exFAT
    /dev/sda3 141844478 1953521663 905838593 f W95 Ext'd (LBA)
    Partition 3 does not start on physical sector boundary.
    /dev/sda4 125841408 141842431 8000512 82 Linux swap / Solaris
    /dev/sda5 293634048 719474687 212920320 7 HPFS/NTFS/exFAT
    /dev/sda6 719476736 1145317375 212920320 7 HPFS/NTFS/exFAT
    /dev/sda7 1145319424 1355051007 104865792 7 HPFS/NTFS/exFAT
    /dev/sda8 1355053056 1657483263 151215104 7 HPFS/NTFS/exFAT
    /dev/sda9 1657485312 1953521663 148018176 7 HPFS/NTFS/exFAT
    /dev/sda10 141844480 293634047 75894784 83 Linux

    Partition table entries are not in disk order

    Disk /dev/sdb: 1000.2 GB, 1000204886016 bytes
    255 heads, 63 sectors/track, 121601 cylinders, total 1953525168 sectors
    Units = sectors of 1 * 512 = 512 bytes
    Sector size (logical/physical): 512 bytes / 512 bytes
    I/O size (minimum/optimal): 512 bytes / 512 bytes
    Disk identifier: 0x0005aa43

    Device Boot Start End Blocks Id System
    /dev/sdb1 2048 976760831 488379392 7 HPFS/NTFS/exFAT
    /dev/sdb2 976760832 1848645631 435942400 7 HPFS/NTFS/exFAT
    /dev/sdb3 * 1848645632 1953519615 52436992 7 HPFS/NTFS/exFAT

    Disk /dev/sdc: 1998 MB, 1998519808 bytes
    62 heads, 62 sectors/track, 1015 cylinders, total 3903359 sectors
    Units = sectors of 1 * 512 = 512 bytes
    Sector size (logical/physical): 512 bytes / 512 bytes
    I/O size (minimum/optimal): 512 bytes / 512 bytes
    Disk identifier: 0x00031865

    Device Boot Start End Blocks Id System
    /dev/sdc1 * 62 3901659 1950799 b W95 FAT32

  6. #6
    Just Joined!
    Join Date
    Mar 2008
    Posts
    7
    Let me start by saying that that is a very unusual partition table. But the only Linux partition in that fdisk output is /dev/sda10. So you could try replacing "X" with "10" in the earlier set of commands. I'm very confused at why you would have so many different NTFS partitions, and it makes me wonder if there is some problem on the Windows side.

  7. #7
    Super Moderator devils casper's Avatar
    Join Date
    Jun 2006
    Location
    Chandigarh, India
    Posts
    24,729
    shaywalter is correct. Replace X with 10.
    Code:
    sudo mount /dev/sda10  /mnt
    Regarding partition structure, everything looks normal except overlap of Extended Partition. You can ignore it for a while.
    One can make as many Logical Partitions as one needs.
    It is amazing what you can accomplish if you do not care who gets the credit.
    New Users: Read This First

  8. #8
    Just Joined!
    Join Date
    Jun 2011
    Posts
    13
    When I had this problem, I used a Window utility, EasyBCD, to fix the problem. Added Linux to the Windows 7 boot process. I now get a boot prompt which says Windows 7 or Linux. If I select Linux, I then get my grub screen and I'm off. Not an optimal solution but it works. The major issue is any subsequent Linux install as a multiple boot or any grub update will break this solution. You must then boot with a Windows 7 CD/DVD and do a repair. You go to the command prompt and run bootrec.exe with the switches to fix the MBR and boot sector (/FixMbr and /FixBoot). The other suggestions here may well be better. Research both and you decide what works for you.

  9. #9
    Just Joined!
    Join Date
    Dec 2008
    Location
    Lund, Sweden
    Posts
    31
    Another alternative is to boot into Linux using a generic boot disk, such as Super Grub Disk (download the iso, burn a CD, and boot from that). When booting it will scan your hard drive for bootable partitions, you can then boot to your Linux partition, and run grub from there, which in turn will create grub entries for your Linux and Windows partitions.

  10. #10
    Super Moderator devils casper's Avatar
    Join Date
    Jun 2006
    Location
    Chandigarh, India
    Posts
    24,729
    Quote Originally Posted by ricard View Post
    Another alternative is to boot into Linux using a generic boot disk, such as Super Grub Disk (download the iso, burn a CD, and boot from that). When booting it will scan your hard drive for bootable partitions, you can then boot to your Linux partition, and run grub from there, which in turn will create grub entries for your Linux and Windows partitions.
    Thats what I have suggested in first place. If one has installation LiveCD/USB then there is no need of SuperGRUB disk. Executing grub-install command will re-install GRUB.
    Quote Originally Posted by gbray
    When I had this problem, I used a Window utility, EasyBCD, to fix the problem. Added Linux to the Windows 7 boot process. I now get a boot prompt which says Windows 7 or Linux. If I select Linux, I then get my grub screen and I'm off. Not an optimal solution but it works. The major issue is any subsequent Linux install as a multiple boot or any grub update will break this solution. You must then boot with a Windows 7 CD/DVD and do a repair. You go to the command prompt and run bootrec.exe with the switches to fix the MBR and boot sector (/FixMbr and /FixBoot). The other suggestions here may well be better. Research both and you decide what works for you.
    Thats why we don't suggest EasyBCD or any other third party too. Linux installers are very much capable of detecting other distros and setup multiboot. Problem arise only of you re-install Windows OS. Best solution is, re-install GRUB using installation CD/USB.
    It is amazing what you can accomplish if you do not care who gets the credit.
    New Users: Read This First

Page 1 of 2 1 2 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •