GRUB installed on /dev/sda1, "no such partition" after image restoration

13,161

Problem solved with the command:

sudo grub-install /dev/sda1 --force

--force was the critical missing piece of the puzzle.

Share:
13,161

Related videos on Youtube

autobottodoggo
Author by

autobottodoggo

Updated on September 18, 2022

Comments

  • autobottodoggo
    autobottodoggo over 1 year

    My partition setup is:

    [Win7] [Ubuntu] [extended [logical partition]] (in that exact order)

    The bootloader installed in the MBR is a non-standard one that allows you to chainload a secondary bootloader on another partition. I use the this option alternatively boot Ubuntu via GRUB installed on /dev/sda1. This setup has always worked for me, but after upgrading my hard drive, I can't seem to restore GRUB to a working state. I upgraded by restoring recent backup images to the drive (this has worked for me in the past)

    But, this time, I just get:

    Error: no such partition. Grub rescue>

    I can boot the Ubuntu installation with this at the rescue prompt:

    set root=(hd0,1)
    set prefix=(hd0,1)/boot/grub
    insmod normal
    normal
    

    But it's pretty silly to type that in every time.

    This is my disk layout according to fdisk -l

    Disk /dev/sda: 500.1 GB, 500107862016 bytes
    255 heads, 63 sectors/track, 60801 cylinders, total 976773168 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
    
       Device Boot      Start         End      Blocks   Id  System
    /dev/sda1       122896725   146336084    11719680   83  Linux
    /dev/sda2       178053120   976773119   399360000    5  Extended
    /dev/sda3   *         929   122881184    61440128    7  HPFS/NTFS/exFAT
    /dev/sda5       178055168   976773119   399358976    7  HPFS/NTFS/exFAT
    
    Partition table entries are not in disk order
    

    I've tried grub-setup, grub-install, boot-repair (which doesn't work because it only offers the option to install to MBR), none have worked.

    I have a USB thumbdrive with GRUB installed (which works when I use it to boot to the Ubuntu installation on the laptop at /dev/sda1) and its grub.cfg file is identical to the one on /dev/sda1.

    If I had to guess, does the fact that the order of the partitions listed in fdisk -l doesn't match the order they're arranged on the disk have effect on this?

    When I type set at the grub prompt I get

    prefix=(hd0,msdos2)/boot/grub
    root=hd0,msdos2
    
    • Danatela
      Danatela almost 11 years
      Did you try update-grub?
    • autobottodoggo
      autobottodoggo almost 11 years
      @Danatela: yes, I tried that. No effect.
    • autobottodoggo
      autobottodoggo almost 11 years
      @psusi: I'll try that and report back
    • psusi
      psusi almost 11 years
      You must have restored the image wrong and changed the order of the partitions. A grub-install should pick up the new partition number.
    • autobottodoggo
      autobottodoggo almost 11 years
      @psusi: I've done that, still doesn't work.
    • autobottodoggo
      autobottodoggo almost 11 years
      @psusi: ah-HA! Got it, needed to include the --force parameter with grub-install