How to reinstall grub2 after installing Windows 11 (on a dual boot system with Ubuntu 18.04)

6,779

I've used ubuntu 21.04 in "try" mode and I have installed Boot-Repair. I've chosen to reinstall grub2 on the /dev/sdb and it did all the necessary steps correctly. After rebooting I was able to boot ubuntu 18.04 installed on /dev/sdb4

Share:
6,779

Related videos on Youtube

Marietto
Author by

Marietto

computer technician

Updated on September 18, 2022

Comments

  • Marietto
    Marietto over 1 year

    I've just installed Windows 11 on the first partition of my disk,that's partitioned like this :

    # fdisk /dev/sdb -l
    
    Disk /dev/sdb: 465.76 GiB, 500107862016 bytes, 976773168 sectors
    Disk model: Samsung SSD 860 
    Units: sectors of 1 * 512 = 512 bytes
    Sector size (logical/physical): 512 bytes / 512 bytes
    I/O size (minimum/optimal): 512 bytes / 512 bytes
    Disklabel type: dos
    Disk identifier: 0x1967ba67
    
    Device     Boot     Start       End   Sectors   Size Id Type
    /dev/sdb1  *         2048 273092607 273090560 130.2G  7 HPFS/NTFS/exFAT
    /dev/sdb2       273092608 274454527   1361920   665M 27 Hidden NTFS WinRE
    /dev/sdb3       274456576 276553727   2097152     1G 82 Linux swap / Solaris
    /dev/sdb4       276553728 976772477 700218750 333.9G 83 Linux
    

    As you can see, Ubuntu 18.04 is installed on /dev/sdb3 and /dev/sdb4.

    Previously Windows 10 was installed instead of Windows 11.

    The problem is that the installation of Windows 11 broke grub2 that was installed on top of the disk /dev/sdb and now I want to reinstall it. I've tried to do like this :

    # sudo grub-install --recheck --no-floppy --root-directory=/ /dev/sdb
    

    But it gives this error :

    Installing for x86_64-efi platform.
    grub-install: error: cannot find EFI directory.
    

    I think that it is a bug, because it detects an EFI partition, which isn't there. The disk has been formatted with MBR and it is DOS style and I have installed Windows 11 using RUFUS using the MBR method. Even /dev/sda is not EFI style :

    # fdisk /dev/sda -l
    
    Disk /dev/sda: 465.76 GiB, 500107862016 bytes, 976773168 sectors
    Disk model: CT500MX500SSD4  
    Units: sectors of 1 * 512 = 512 bytes
    Sector size (logical/physical): 512 bytes / 4096 bytes
    I/O size (minimum/optimal): 4096 bytes / 4096 bytes
    Disklabel type: dos
    Disk identifier: 0xa6e39599
    
    Device     Boot Start       End   Sectors   Size Id Type
    /dev/sda1  *     2048 976767672 976765625 465.8G 83 Linux
    

    What's the right procedure here to reinstall grub2?

    • oldfred
      oldfred almost 3 years
      Are you sure you want BIOS/MBR not UEFI/gpt? Microsoft has required vendors to install in UEFI/gpt mode since 2012. BIOS drivers may not be as well supported in the future. Windows in BIOS mode was known to delete Linux logical partitions. It looks like you only have primary. You can just use Boot-Repair's advanced mode and reinstall grub from your Ubuntu live installer boot in BIOS mode manually or with Boot-Repair added. help.ubuntu.com/community/Boot-Repair & sourceforge.net/p/boot-repair/home/Home
    • Marietto
      Marietto almost 3 years
      Does the boot-repair tool works if I don't use the ubuntu live installer but I use the ubuntu os that I have installed on /dev/sda ?
    • oldfred
      oldfred almost 3 years
      You can add Boot-Repair to any working version of Ubuntu. Can you boot? Some get a system to boot with Supergrub. supergrub & Rescatux supergrubdisk.org/rescatux & askubuntu.com/questions/1186273/… I used to use Supergrub for my older BIOS systems. Have not used Rescatux, but have it on a flash drive somewhere. For UEFI I use rEFInd for emergency boot and it fits on an old 256MB flash drive that was too small for anything else. I suggest having multiple repair tools for both Windows & Ubuntu.
    • Marietto
      Marietto almost 3 years
      it worked with ubuntu in live mode. thanks.
    • cipricus
      cipricus almost 3 years
      it worked with ubuntu in live mode. thanks - You mean you have fixed this? Please post an answer under your own question, it may prove helpful in the future. Have you used boot-repair? Could you please take a look at this question and answer based on your experience?
    • Marietto
      Marietto almost 3 years
      yes. I've used the ubuntu 21.04 in "try" mode and I have installed Boot-Repair. I've chosen to reinstall grub2 on the /dev/sdb and it did all the necessary steps correctly.