Grub rescue after "Windows Anniversary Update"

5,061

Solution 1

There are two options you can use. You can use the grub rescue console to mount and update/fix grub, or you can use a Live Ubuntu disk/usb for this. Since your question suggest this is a fresh install, you most likely still have your Live DVD/USB handy.

Boot to your install media. If you have a UEFI capable computer, ensure that you boot to that mode.

When you get to the prompt, allowing you to Try without installing Ubuntu, choose that option.

Open a terminal (type terminal in the Ubuntu Dash search).

Run these commands in the console:

  • The XY in line #1 is a variable. This is the partition where Ubuntu is installed (ie /dev/sda6). This can be any partition on any drive attached to your computer.

  • The XY in line #3 is a variable. Replace this with the partition that has EFI installed. This is almost always /dev/sda1. If your boot drive isn't an EFI drive, skip steps #3 and #10.

  • The X in line 6 is your boot drive (a single letter). This almost always is /dev/sda.

 1:$ sudo mount /dev/sdXY /mnt
 2:$ for i in /sys /proc /run /dev; do sudo mount --bind "$i" "/mnt/$i"; done
 3:$ sudo mount /dev/sdXY /mnt/boot/efi
 5:$ sudo chroot /mnt
 6:# grub-install /dev/sdX
 7:# update-grub
 8:# exit
 9:$ for i in /sys /proc /run /dev; do sudo umount "/mnt/$i"; done
10:$ sudo umount /mnt/boot/efi
11:$ exit

Reboot the computer.

Grub Rescue

Outside of having a USB or DVD install disk, these are steps for the Grub Rescue prompt:

1. set prefix=(hdX,Y)/boot/grub

Use the values determined earlier.

Example: If the Ubuntu system is on sda5, enter: set prefix=(hd0,5)/boot/grub

2.* set root=(hdX,Y)

Confirm the correct X,Y values and press ENTER.

Example: If the Ubuntu system is on sda5, enter: set root=(hd0,5)

3. insmod normal

Load the normal module.

If the module loads there will be no message.

If the module fails to load, try the full path: insmod (hdX,Y)/boot/grub/normal.mod

4. normal

Transition to the normal GRUB 2 mode with increased functionality.

If the module loads there will be no message.

If the module loads, HELP, TAB completion and command recall using the UP/DN keys should be available.

5. set

(Optional) Review the current settings.

6. insmod linux

Load the linux module. An error message usually means the path is incorrect.

7.* linux /vmlinuz root=/dev/sdXY ro

Selects the latest kernel.

Example: linux /vmlinuz root=/dev/sda5 ro

If the vmlinuz symlink does not exist in /, use the full path to the kernel in /boot

Example: linux /boot/vmlinuz-3.2.0-14-generic root=/dev/sda1 ro

8. initrd /initrd.img

Selects the latest initrd image.

If the initrd symlink does not exist in /, use the full path to the initrd image in /boot

If successful, after ENTER there will be a slight delay and no messages.

9. boot

More details and definition of the available Grub Rescue commands can be found in the Ubuntu Community Help Docs. That's the source of the Grub Rescue commands above.

I've used it, and find it fairly easy as you get used to it. But it's not as easy to explain to a novice as it is to actually use. As you perform the steps, it'll start to make more sense.

Using Testdisk to recover a lost partitions and Files

$ sudo testdisk

1: Select Create       - ENTER
2: Select Create       - ENTER
3: Select Disk         - Proceed
4: Select Intel        - ENTER
5: Select Analyse      - ENTER
6: Select Quick Search - ENTER

If it finds your Ubuntu partition you will see it listed. You can identify it by it's name, size, and type (ext4).

Select Ubuntu Partition and press ENTER. Then select the Write option to recover the partition.

IF it has problems recovering the partition use the Deeper Search option.

If after Deeper Search you still can't recover the whole partition, select the option to recover files. Then you can pick the important files you need to recover.

If you are going to recover files you'll have to have a drive to recover the files to. Sometimes recovery takes a lot of time and expense. You might have to invest in something similar to a USB to Sata adapter and connect it to your system for recovering the files to. Depending on the amount of files, a 120G USB Pendrive may suffice for the backup medium.

You can review the details for using Testdisk at: TestDisk Step By Step.

Solution 2

The correct answer is that Windows 10 did its "Anniversary Update", and it wiped out your Ubuntu partition. Thanks Microsoft! If you can still boot Windows, let it finish installing all updates before trying to recover Ubuntu.

When booted to the Ubuntu Live DVD/USB, you can install testdisk in terminal, and try to recover the lost partition, but it's not easy.

To install and run testdisk, in terminal, type the following commands:

sudo apt-get update
sudo apt-get install testdisk
sudo testdisk

See http://www.cgsecurity.org/wiki/TestDisk_Step_By_Step for a step by step procedure that will get you started. You'll need the output of sudo fdisk -l (lower case L) to use testdisk.

If you can't recover using testdisk, you'll need to reinstall Ubuntu.

Questions? Problems? Let us know how you do. Cheers, Al

Share:
5,061

Related videos on Youtube

Zachery Calahan
Author by

Zachery Calahan

Updated on September 18, 2022

Comments

  • Zachery Calahan
    Zachery Calahan about 1 year

    Let's get some background info, I am dual-booting Win10 and Ubuntu 16.04 (I believe) on an HP 62 laptop. After the first restart, it gave me the grub rescue screen. I did the ls command and got (hd0) (hd0,msdos5) (hd0,msdos3) (hd0,msdos2) (hd0,msdos1). I tried using the ls command with all of them and I have gotten an error. It said unknown filesystem. I do know my files are intact, (as far as windows anyway) and are readable. I don't have a live USB or CD.

    Edit: I currently have a live USB booted. After looking at my partition table, I know sda2 is my Windows OS, and sda4 is my Linux OS, but how would I go about fixing them?

    Edit:lsblk -f; sudo parted -l after I input this I got:

    NAME   FSTYPE   LABEL           UUID                                 MOUNTPOINT
    sda                                                                  
    ├─sda1 ntfs     System Reserved 78746B10746AD104                     
    ├─sda2 ntfs                     52CE70B8CE7095C7                     
    ├─sda3 ntfs                     32DA13F9DA13B855                     
    └─sda5 swap                     acf66f09-4c28-4c76-a318-d2f77efaa56a [SWAP]
    sdb                                                                  
    └─sdb1 vfat     UBUNTU 16_0     7C9B-EA5B                            /cdrom
    sr0                                                                  
    loop0  squashfs                                                      /rofs
    Model: ATA TOSHIBA MK5056GS (scsi)
    Disk /dev/sda: 500GB
    Sector size (logical/physical): 512B/512B
    Partition Table: msdos
    Disk Flags: 
    
    Number  Start   End    Size    Type      File system     Flags
     1      1049kB  525MB  524MB   primary   ntfs            boot
     2      525MB   388GB  388GB   primary   ntfs
     3      388GB   389GB  844MB   primary   ntfs            diag
     4      389GB   500GB  111GB   extended
     5      494GB   500GB  6229MB  logical   linux-swap(v1)
    
    
    Model: SanDisk Cruzer U (scsi)
    Disk /dev/sdb: 15.6GB
    Sector size (logical/physical): 512B/512B
    Partition Table: msdos
    Disk Flags: 
    
    Number  Start   End     Size    Type     File system  Flags
     1      1049kB  15.6GB  15.6GB  primary  fat32        boot, lba
    

    Edit: This is the GParted picture. (I took it down to allow the other ones.)

    Edit: This is my BIOS screen and my Boot Option Menu. There is only the primary drive.

    enter image description here

    Boot Option Menu

    Edit: Thanks so much to everyone to for helping me fix my computer. I have all of my files intact. I really hope this helps someone else who may be having this problem.

    How I did it and how it happened: At first, went to use my computer for a school project. Windows decided to install its updates at the time, so I let it. After the first restart, it gave me the grub rescue> screen. I ran the ls command to see my partitions, and I got the output of (hd0) (hd0,msdos5) (hd0,msdos3) (hd0,msdos2) (hd0,msdos1) Notice that there isn't a (hd0,msdos4). That would mean that Windows deleted the Ubuntu partition. I tried setting paths to the grub files, but they were not there. After a bit, I use a different computer to create a Live USB and booted from that. I opened up a terminal and tried installing testdisk. (Make sure to go into your settings and enable the "universe" option in Software & Updates) When testdisk installed I ran through it and did a deep search on my hard drive. After it was done I labeled the Windows launcher to *. (Primary bootable) I then named the rest P. (Primary) I opened grub rescue again, after saving the partition table, and ran ls. The output was something similar to (hd0) (hd0,msdos5) (hd0,msdos4) (hd0,msdos3) (hd0,msdos2) (hd0,msdos1) (hd1) (hd1,msdos1) I ran ld (hd0,msdos3) and it gave the result that is is a ext2 drive. Finally! I then ran set root=(hd0,msdos3) set prefix=(hd0,msdos3)/boot/grub insmod normal normal and it booted just fine! Hope this helps you, because it definatly helped me.

    • Apologician
      Apologician about 7 years
      Will you boot to a live disk and append the output of: lsblk -f; sudo parted -l to your question?
  • Zachery Calahan
    Zachery Calahan about 7 years
    I already had both installed a long time ago. Yesterday windows just updated. I am in a live usb right now, but it doesn't seem to have boot repair
  • terdon
    terdon about 7 years
    Comments are not for extended discussion; this conversation has been moved to chat.
  • terdon
    terdon about 7 years
    Comments are not for extended discussion; this conversation has been moved to chat.