5

Previous system state when it was working: UEFI

  • Disk C: SSD, Windows 10 installed as main OS.
  • Disk D: HDD, just data, one partition takes the whole disk.
  • Disk X: SSD, one partition (GPT).
  • Disk O: HDD, contains windows 7.

(Note: I don't remember the order of disks, so I'll be naming them by drive label assigned in Windows.)

  1. I decided to install Ubuntu on a separate partition on disk X. I shrank the partition using Windows disk manager and verified that the system worked afterwards. Then I created bootable USB with Ubuntu 20.04.1 and booted into it.
  2. In Ubuntu installer, I used the "Something else" option because I was unsure that "Install alongside with Windows" won't try to install on disk C. In there I created a new ext4 partition and mounted to /. Then I specified this same partition as boot loader partition and finished installation.
  3. After reboot, I couldn't boot Ubuntu. Windows was booting normally as usually, without showing any options, even if I chose to boot from disk X in UEFI. Then I realized that I made a mistake on step 2 by specifying the same partition where I installed Ubuntu as boot loader partition.
  4. I booted into Ubuntu USB installer and tried to install once again. This time I chose the same partition to install Ubuntu as on step 2 and chose to format the partition (after the installer showed a warning). I chose sda as the boot loader partition (it corresponds to disk C). Installation finished normally, upon boot I was presented with GRUB boot menu. Ubuntu was working normally. NB: the installer's partition table correctly displayed partitions for Windows 10 and Windows 7 on their corresponding disks.
  5. I messed up the Ubuntu instance and wanted to do a reinstall. I booted into the installer USB again, and then again chose the same partition, chose to format it, and again chose sda as boot loader partition. I basically repeated what I did on step 4. Except when I reached the next installer screen, I saw some warning (don't remember which) which had a Back button. I decided to go back and check that I selected the right settings on the partition step, so I pressed "Go Back". --- At this point, the installer displayed an error message, so I decided to reboot and try again.
  6. In the installer on the step which displays the partition table I now cannot see the Windows 7 and Windows 10 partitions detected. The number of partitions and their sizes seem to be correct, but the OS detection cannot find them anymore. Besides, there is no "Install alongside Windows" option offered now. If I try to finish the installation with the same settings as on step 4, I get a warning that I need to specify a EFI partition. Since I didn't know which one that should be (sda? but I was specifying sda already...) I decided to not go forward with the installation and cancelled it.

Now the system is in a state where it cannot boot into GRUB.

Here're a few observations about this current state:

  1. Upon boot, I see this:
error: no such device: <GUID>
error: unknown filesystem.
Entering rescue mode...
  1. ls in grub rescue shows this: (hd0) (hd1) (hd1,gpt3) (hd1,gpt2) (hd1,gpt1) (hd2) (hd3) (fd0). ls-ing each of them yields "Filesystem is unknown" except for (hd1,gpt3) which yields ext2. ls-ing this partition yields lost+found. (It used to show also /etc and /media but after a few further steps described below it doesn't now.)
  2. When in Ubuntu live CD, I can see all the partitions using parted.
  3. I've created Windows 10 recovery USB and loaded into it. It couldn't fix startup (using Repair your computer > Troubleshoot > Repair startup). The corresponding logs show that all tests are successful, but it looks like it doesn't even detect the OS and checks the OS on the recovery USB. I then tried Advanced options > Command prompt, and in diskpart I see the following:
Disk ###  Status         Size     Free     Dyn  Gpt
--------  -------------  -------  -------  ---  ---
Disk 0    Online         55 GB    451 MB            
Disk 1    Online        465 GB     28 GB         * 
Disk 2    Online        372 GB       0 B
Disk 3    Online       1397 GB       0 B
Disk 5    No Media         0 B       0 B

I find it worrying that it doesn't display * in the Gpt column for Disk 0, which is Disk C in my terminology. Disk 1 is disk X (judging by size).

Note that select disk 0 then list partition shows the partitions:

Partition ###  Type          Size     Offset
-------------  ------------  -------  -------
Partition 1    Primary        100 MB  1024 KB
Partition 2    Primary         54 GB   101 MB
Partition 3    Recovery       522 MB    54 GB  

How do I proceed further? It seems like the data should be intact, so I don't want to reinstall Windows if possible. I don't care about the Ubuntu installation, I wanted to reinstall it anyway. I want to be able to restore Windows 10 (top priority) and Windows 7 (very desirable).

  • 2
    Usually Windows 7 was installed in 35 year old BIOS/MBR configuration. Windows 10 install is normally UEFI/gpt, but if upgrade from Windows 7 is BIOS/MBR. Windows only boots in BIOS mode from MBR and only UEFI from gpt. You should not mix UEFI & BIOS on different drives but can only with Ubuntu, but then grub only boots other installs in same boot mode. You have to then boot only from UEFI boot menu. Some UEFI require you to change default boot to/from UEFI and CSM/BIOS/Legacy to boot that install. Most UEFI now know which way to boot, so just have to select install you want. – oldfred Aug 28 '20 at 20:55
  • Well, the disk I call "Disk C" (Ubuntu sees it as sda) indeed seems to be formatted with MBR. I didn't know about MBR-BIOS/GPT-UEFI correlation in Windows, thanks! I've also found this: https://docs.microsoft.com/en-us/windows/deployment/mbr-to-gpt. Do you think that converting Disk C to GPT will help?

    Also, I'm sorry but I didn't understand the last part of your comment. Why can't I mix UEFI & BIOS mode on different drives? I'm always booting from a specific drive, what's the difference?

    – killedmyboot Aug 29 '20 at 08:51
  • 1
    You can mix on different drives. But then cannot use grub to dual boot, only UEFI. BIOS & UEFI Windows partitions, note system has totally different format & meaning between BIOS & UEFI https://msdn.microsoft.com/en-us/library/windows/hardware/dn898504%28v=vs.85%29.aspx & https://docs.microsoft.com/en-us/windows-hardware/manufacture/desktop/configure-uefigpt-based-hard-drive-partitions#RecommendedPartitionConfigurations – oldfred Aug 29 '20 at 13:19
  • Thanks! I'm now wondering how this worked at all in the beginning (step 4). I assume I couldn't possibly have had GPT on sda (disk C) that then magically (after boot-repair?) turned into MBR. But that means that I must've been booting Windows in BIOS mode all this time, and somehow managed to install GRUB which was working in BIOS mode too. But why can't it do the same now? – killedmyboot Aug 31 '20 at 20:38
  • Without details of configuration before, difficult to know. Ubuntu will boot in BIOS or UEFI from MBR or gpt. Ubuntu should be like Windows only only boot in UEFI mode from gpt. You can boot in BIOS mode from gpt with Ubuntu if you have a bios_grub partition. And sometimes, boot loader goes into one drive, but install is in another? – oldfred Aug 31 '20 at 21:18

2 Answers2

1

I had a similar Issue and fixed it with boot-repair.

sudo add-apt-repository ppa:yannubuntu/boot-repair
sudo apt-get update
sudo apt-get install -y boot-repair
boot-repair

just try the recomended repairs in the gui and reboot

  • Thanks. By "similar issue", do you mean that you also had had Windows installed? I'm worried that it could somehow make things worse Windows-wise. Also, do you happen to know why it can do the repair and Windows recovery tool cannot? – killedmyboot Aug 28 '20 at 20:07
  • yes also had dual-boot and after installing kubuntu 20.04 grub wouldn't work. windows doesn't care about any other non windows OS than might be installed and defenitelly deosn't go looking if grub works or not. I have even seen windows updates negatively affecting linux. there is a reason you should always install windows and then linux for dual-boot. windows does not and propably never will aknowledge that some people might like using something besides their totally great OS and tools. – totalynotanoob Aug 28 '20 at 20:15
  • forgot to say that boot-repair will leave windows alone and only look at grub and linux – totalynotanoob Aug 28 '20 at 20:16
  • Thanks, that worked --- I can now boot into Windows 10! Follow-up question: would it work if I created a separate EFI partition on Disk X in order to avoid having boot menu at all? So that I can choose from which disk to boot in the UEFI? – killedmyboot Aug 28 '20 at 20:20
  • Uh, but Ubuntu installer still doesn't detect Windows... What's the best way to proceed in this case? Should I still choose sda for boot loader installation? – killedmyboot Aug 28 '20 at 20:28
  • And there's still no EFI System Partition found :/ – killedmyboot Aug 28 '20 at 20:31
  • I would tike to point out that my username is sarcastic and I am in fact an noob (insert gasp). but i read in the insallation manual of ubuntu that you should choose the disk for bootloader (not a single partition). It might actually tell you that during installation as well. – totalynotanoob Aug 28 '20 at 20:42
  • on the Drive X thing: when windows is installed and you have another drive connected ubuntu should give you the option to install there automatically. but grub will also be installed there so when you disconnect that drive you might have problems booting windows because grub wont work. you can work around this problem by choosing the windows boot manager in your bios for preffered boot option and using the F12 menu for choosing to boot linux while the drive X is connected. I used to do it that way. – totalynotanoob Aug 28 '20 at 20:42
  • of EFI ect I don't know nearly enough to help there, I would only be guessing but I can reccomend reading the installation manuals ect by ubuntu. they are really helpfull and you definitelly won't be the first with most problems you will encounter. – totalynotanoob Aug 28 '20 at 20:42
  • Thanks! Re. choosing disk and not partition: yes, that's what I'm doing - I'm choosing sda and not sda1 or such. In fact that's what already selected. – killedmyboot Aug 28 '20 at 20:45
0

Check out the answer that is posted here
You need to start at that grub recue terminal that was showing (hd0) (hd1) etc.
You need to find which of those partitions holds your home directory and which one holds your grub and then update your initramfs. There are extensive notes here but not all of that will apply to your case.

  • Thanks for the answer. As I mentioned in the question, GRUB rescue can read only one partition, and it only has lost+found inside. – killedmyboot Aug 29 '20 at 07:27
  • Did you type it like ls (hd1,gpt3)/home and ls (hd1,gpt32)/home etc? – darth_epoxy Aug 29 '20 at 07:41
  • ls (hd1,gpt3)/ is what I tried. Now that I've applied boot-repair, Windows boots automatically, so I can't try GRUB rescue anymore. The only problem now is that Ubuntu installer doesn't recognize the Windows presence and requires to create a EFI partition. I'm not sure on which disk it should be created; on disk X, since it's the same disk where I'm creating the root partition for Ubuntu? Where should I place boot loader --- still on sda (disk C)? – killedmyboot Aug 29 '20 at 08:55
  • Update: I'll try to convert sda (Disk C) into GPT, so that there will be an EFI system partition. Based on this article, Windows doesn't support having two ESPs on two disks: https://docs.microsoft.com/en-us/windows-hardware/manufacture/desktop/windows-and-gpt-faq – killedmyboot Aug 29 '20 at 10:33
  • The /boot/efi mount point for Ubuntu can be put on a fat32 partition with flags esp,boot and therefore I assume it can be shared with windoze. – darth_epoxy Aug 29 '20 at 11:03