Find the answer to your Linux question:
Page 1 of 2 1 2 LastLast
Results 1 to 10 of 12

Thread: grub repair

Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1

    grub repair


    I have Windows and Ubuntu installed on my laptop as dualboot. The way the partition table was setup is:
    hda1 = Windows XP (primary)
    hda2 = Unused (primary)
    hda3 = Extended
    hda5 = Ubuntu / (Logical inside hda3)
    hda6 = Ubuntu swap (Logical inside hda3)
    hda7 = NTFS storage partition (Logical inside hda3)

    Everything was working fine, until Windows corrupted itself. After reinstalling Windows, it got rid of grub MBR, so now only Windows can boot up. I've looked at several fixes online, but none seem to work for me. Here is what I tried and results I got:

    1.) With Gentoo CD tried "mkdir dummydir", "mount /dev/hda3 dummydir", after this I went into dummydir and it did indeed contain the stuff from hda5 (Ubuntu root directory) (also, mounting /dev/hda5 gives an error saying that I need to specify partition type, using -t ext3 says that it's a logical partition and I want to mount extended one instead, which is why I mounted /dev/hda3). After this I tried "chroot dummydir", which changed me to root@livecd. And then I tried using "grub-install /dev/hda" which gave me and error: "/dev/hda: Not found or not a block device. So then instead of that I launched grub and tried "root (hd0, 4)" (since that should correspond to /dev/hda5, also (hd0, 4) is what /boot/grub/menu.lst claims as my Ubuntu partition), however, that command gave me "Error 21: Selected disk does not exist" error in grub.

    2.) Burned Fedora Core rescue cd, tried "linux rescue" command. After a few prompts it told me that it would try to find linux partitions and add them to /mnt/sysimage. Then it told me that it couldn't find any linux partitions (but obviously the partition is there if I can mount it and view files on it).

    3.) Now, last solution I found from here: http://doc.gwos.org/index.php/Restore_Grub
    Apparently I put in my Ubuntu CD and go through with install until it asks me for partitions, then I should manually partition and set /, /boot, swap, and save changes which should give me an error and let me repair Grub afterwards. So I went with that, but when I got to the partition screen all I see now is unallocated space the size of my whole harddrive (not a single partition is showing), first time I was installing Ubuntu they were all there. So I continue past that, and assign my partitions, but it's not catching their sizes correctly, it thinks they're all 0Kb. When I press forward, it won't let me continue saying that minimum partition size for / is 2048Mb. So I can't go to the grub part of the installation.

    Can someone help me please? I don't want to do a clean Ubuntu reinstall just because of this. My guess is that these issues are arising because I'm using logical partition for Linux instead of primary and something has to be done differently with logical ones, is that so? I also have this uneasy feeling that my partition table got erased, but if it did, how am I still able to mount partitions?

  2. #2
    SuperMod (Back again) devils casper's Avatar
    Join Date
    Jun 2006
    Location
    Chandigarh, India
    Posts
    24,777
    3.) Now, last solution I found from here: http://doc.gwos.org/index.php/Restore_Grub
    thats a very unsafe method imo. did you choose 'Do Not Format Partition' option in partition section? i think you have deleted all partitions.
    is Windows booting up now? boot up from Ubuntu LiveCD and execute 'sudo fdisk -l' command. post output here.
    It is amazing what you can accomplish if you do not care who gets the credit.
    New Users: Read This First

  3. #3
    Ok, I fixed it. BTW, I didn't tell it to reformat my partitions, I am always very careful about things like that, I unchecked those boxes immediatelly as soon as I got to the screen. I didn't have the chance to try "fdisk -l" command since the problem is not there anymore.

    Anyway, here is what I did:

    In Windows XP, I opened Computer Management Console (Start->Run: compmgmt.msc), and went to Disk Management. This showed me all my partitions, however, I noticed that inside my extended partition, all logical partitions had clones of same size as them except slightly larger and marked as "Unformatted". It was also claiming that my harddrive is 194 GB (even though it's only 111 GB).

    Then I downloaded Partition Table Doctor (which as some websites claim is the only software that rebuilds partition tables, although I somehow doubt that in the last 20 years or so no one except them has thought of it). Anyway, after running it, it told me that it could fix it and showed me the result (which is what my original partition table looked like) (p.s. the demo version only tells you what partition table will look like once it's fixed, it doesn't actually save changes). After I rewrote the partition table with it, I rebooted and tried Computer Management Console again. This time it displayed the partitions correctly, without weird unformatted clones. So I put the Fedora rescue cd back in and tried "linux rescue" again. This time it found my Ubuntu installation, and set it to /mnt/sysimage. Then I did "chroot /mnt/sysimage", followed by "grub-install /dev/hda". Then rebooted, and grub started working, I'm now typing this from my good old Ubuntu. Hope this helps to whoever has this problem in the future.

  4. $spacer_open
    $spacer_close
  5. #4

  6. #5

    Question Repair GRUB

    Hello

    I had XP and Ubuntu, until I had to reinstall XP. Now I do not have anymore the GRUB. I want to repair GRUB. My file system is this:
    hda 1 - XP
    hda 2 - extended
    hda linux-swap
    hda / (ubuntu)
    hda /usr
    hda 5 - ntfs
    hda 6 - ntfs
    hda 7 - ntfs
    hda 8 - ntfs

    hdb 1 ntfs
    hdb 2 ntfs
    hdb 5 ntfs
    hdb 6 ntfs

    Thanks to all!

    PS: when I boot from CD and trying to install Ubuntu, my file system looks like this (but I know there are the partitions, because I didn't change them, and I can still boot in XP from hard disk):

    hda is comepletly an unallocated space
    hdb 1 ntfs
    hdb 2 ntfs
    hdb 5 ntfs
    hdb 6 ntfs

    I cannot destroy hda to install a fresh Ubuntu, I need XP and my other files.
    Thanks again

  7. #6
    SuperMod (Back again) devils casper's Avatar
    Join Date
    Jun 2006
    Location
    Chandigarh, India
    Posts
    24,777
    boot up from Ubuntu LiveCD, Open Terminal and execute this
    Code:
    sudo grub-install /dev/hda
    reboot machine.
    It is amazing what you can accomplish if you do not care who gets the credit.
    New Users: Read This First

  8. #7
    Following the previous threads I downloaded Super GRUB DISK and I fixed GRUB. It's exactly how I had it before Now I can boot XP from GRUB, but I can not boot in Ubuntu 6.10. I didn't formated linux partitions.

  9. #8
    SuperMod (Back again) devils casper's Avatar
    Join Date
    Jun 2006
    Location
    Chandigarh, India
    Posts
    24,777
    Quote Originally Posted by thoroner View Post
    Following the previous threads I downloaded Super GRUB DISK and I fixed GRUB. It's exactly how I had it before Now I can boot XP from GRUB, but I can not boot in Ubuntu 6.10. I didn't formated linux partitions.
    what error message appear on selecting Ubuntu title in GRUB menu?
    It is amazing what you can accomplish if you do not care who gets the credit.
    New Users: Read This First

  10. #9

    Exclamation

    Quote Originally Posted by devils_casper View Post
    what error message appear on selecting Ubuntu title in GRUB menu?
    My boot screen looks like this:
    Ubuntu, kernel 2.6.17-10-generic
    Ubuntu, kernel 2.6.17-10-generic (recovery mode)
    Ubuntu, memtest86+
    Other Operating Systems:
    Windows XP Media Center Edition

    when I try to enter on any mode of Ubuntu (generic, recovery, memtest) the system replies:
    Error 17: Cannot mount selected partition
    Press any key to continue...

    --------------------------------------------------------------------------
    after XP reinstallation I have XP Pro, not Media Center, but even if the name is not correct I can boot in XP!
    --------------------------------------------------------------------------
    Back to the GRUB screen boot I tried this:
    pressed "c" (command line) then:

    grub> sudo grub-install /dev/hda

    Error 27: Unrecognized command

    grub> root (hd0,0)

    grub> root (hd1,0)

    Error 11: Unrecognized device string

    grub> root (hd2,0)

    Error 27: Unrecognized command

    grub> root (hd0,0)

    grub> root (hd3,0)

    Error 27: Unrecognized command

    grub> root (hd5,0)

    Error 27: Unrecognized command

    grub> sudo grub

    Error 27: Unrecognized command

    grub> find /boot/grub/stage2
    (hd0,6)

    grub> setup (hd0)

    Error 17: Cannot mount selected partition

  11. #10
    SuperMod (Back again) devils casper's Avatar
    Join Date
    Jun 2006
    Location
    Chandigarh, India
    Posts
    24,777
    -->
    after XP reinstallation I have XP Pro, not Media Center, but even if the name is not correct I can boot in XP!
    GRUB doesn't boot Windows directly. it uses chainloading. title name doesn't matter.

    grub> sudo grub-install /dev/hda
    dont prefix 'sudo' before 'grub-install' command at grub> prompt.

    did you try executing 'sudo grub-install /dev/hda' in the Terminal of LiveCD?
    It is amazing what you can accomplish if you do not care who gets the credit.
    New Users: Read This First

Posting Permissions

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