Grub and Ubuntu disappeared after Windows update

12,818

Solution 1

Windows 10 Anniversary Update, and I understand that Windows 10 Creators Update is the same, both can delete Linux partitions for no particular reason. It's not fully understood what factors trigger this action, however it might be related to MBR formatted disks.

Your sda4 is an extended partition that currently contains sda5 swap partition, and also held the previous Ubuntu partition, presumably sda6... which was located between blocks 253681662 and 484151295.

You can try using testdisk to recover your partition.

Boot to a Ubuntu Live DVD/USB, and in the terminal type:

sudo apt-get update

sudo apt-get install testdisk

sudo testdisk

See http://www.cgsecurity.org/wiki/TestDisk_Step_By_Step for help on how to use this tool.

Solution 2

If you're on your Windows, search for 'Command Prompt' and run as administrator. Then, in the command line, type:

bcdedit /set {bootmgr} path \EFI\ubuntu\grubx64.efi

Then, restart and you're good to go. If you want reverse your setting, type:

bcdedit /deletevalue {bootmgr} path \EFI\ubuntu\grubx64.efi

This is the simplest way to get grub back on your Windows.

Solution 3

To elaborate on heynnema's answer, Windows partitioning tools have LONG had bugs that cause them to delete logical partitions or convert them inappropriately to primary form, leading to serious problems. I tried Googling for examples, but I found just this one, concerning Windows XP. Windows XP! That's how long these bugs have existed. I'm 100% certain that there are other bug reports, but they're probably old enough that Google's not turning them up in the first couple pages of my search results. Since the release of Windows 8, the number of MBR-based installations has been dropping, so the number of problem reports has been shrinking.

In fact, I became so frustrated by problem reports about this sort of issue that in 2011 I wrote FixParts, which is based on (and part of) my GPT fdisk utility suite, installed in the gdisk package in Ubuntu. FixParts will not solve your specific problem, though; as heynnema says, you need TestDisk (or something similar to it) for that. I mention this as another illustration of how common and long-standing these Windows disk partitioning bugs are.

There is some practical advice to be gleaned from your situation:

  • Use Windows partitioning tools for as little as possible, especially on MBR disks and most especially on MBR disks with extended and logical partitions. Of course, a Windows update, such as you report having done, might be difficult (or at least undesirable) to avoid....
  • If you must use Windows partitioning tools, either directly or as part of something like the update you did, back up your disk first. This includes both a traditional file backup and a backup of your partition table. You can do the latter with a command like sudo sfdisk -d /dev/sda > parts.txt, which backs up the partition table on /dev/sda to parts.txt. If you need to restore that partition table, you'd use sudo sfdisk -f /dev/sda < parts.txt; however, if Windows has modified your partition table, it may have made a change that must be preserved (like resizing the Windows partition), so be wary. The backup might still be helpful in selectively recovering a deleted Linux partition, though. (An sfdisk partition table backup is human-readable, although you need to know a bit to understand its format.)
  • Use GPT and EFI installations rather than MBR and BIOS installations whenever possible. Because GPT doesn't use extended or logical partitions, the Windows tools' problems in handling them is unimportant for GPT disks. I'm unaware of any bugs in the Windows partitioning tool's handling of GPT disks that comes anywhere near the problem level of the bug you've encountered in its handling of MBR disks. Of course, if your computer is BIOS-only, this isn't an option; and converting from MBR/BIOS to GPT/EFI carries risks of its own and may be more bother than it's worth. (This Windows tool will do the conversion, if you want to look into it. Be aware, though, that I have no idea how well it would work with a dual-boot configuration.)
Share:
12,818

Related videos on Youtube

Pigna
Author by

Pigna

Updated on September 18, 2022

Comments

  • Pigna
    Pigna over 1 year

    I had Windows 10 and Ubuntu 14.04 installed in dual boot. Roughly 125GB each.

    After the Windows update the PC only showed me the grub rescue terminal. I could neither use Ubuntu nor use Windows.

    I inserted the liveCD and ran boot-repair.

    After that Windows appeared normally, but no GRUB and no Ubuntu.

    This is what I get when I run sudo fdisk -l:

    enter image description here

    Ubuntu must be either /dev/sda2 or /dev/sda4, since they are the biggest partitions, but neither of them is recognized as a Linux system.

    What should I do?

    • David Foerster
      David Foerster over 6 years
      Could you please post text files, dialogue messages, and program output listings as text, not as images? To achieve the latter two you can either 1) select, copy & paste the dialogue text or terminal content or 2) save the program output to a file and use that. Longer listings (the editor will tell you what's too long) should be uploaded to a pastie service and linked to in the question. Thanks.
    • David Foerster
      David Foerster over 6 years
      I'm voting to reopen this question since the linked question assumes that there is a bootable Linux partition available which is not the case here according to what little info we have in the form of the fdisk output (disregarding the medium holding the live system itself).
    • pomsky
      pomsky over 6 years
      Please don't add "solved" to the question. If you wish to improve the accepted answer, you may suggest an edit to the answer. If you have a significantly different solution, then write a new complete answer yourself.
  • HenrikB
    HenrikB over 2 years
    Thank you. I'm confirming that this did the trick. Background: After doing a software update including Lenovo firmware updates on Ubuntu 18.04, the dual-boot machine booted straight into Windows 10. The Grub menu was nowhere to be found/accessed.