Regenerate Grub after Windows install

Hello
I’ve installed windows and Grub was removed :frowning:
Can U help me with recover it?
My partitions are:

[manjaro-gnome manjaro]# lsblk -o PATH,PARTTYPE,FSTYPE,PARTTYPENAME
PATH           PARTTYPE                             FSTYPE   PARTTYPENAME
/dev/loop0                                          squashfs 
/dev/loop1                                          squashfs 
/dev/loop2                                          squashfs 
/dev/loop3                                          squashfs 
/dev/sda                                            iso9660  
/dev/sda1      0x0                                  iso9660  Empty
/dev/sda2      0xef                                 vfat     EFI (FAT-12/16/32)
/dev/nvme1n1                                                 
/dev/nvme1n1p1 c12a7328-f81f-11d2-ba4b-00a0c93ec93b vfat     EFI System
/dev/nvme1n1p2 e3c9e316-0b5c-4db8-817d-f92df00215ae          Microsoft reserved
/dev/nvme1n1p3 ebd0a0a2-b9e5-4433-87c0-68b6b72699c7 ntfs     Microsoft basic data
/dev/nvme1n1p4 de94bba4-06d1-4d40-a16a-bfd50179d6ac ntfs     Windows recovery environment
/dev/nvme0n1                                                 
/dev/nvme0n1p1 0x83                                 ext4     Linux
/dev/nvme0n1p2 0x82                                 swap     Linux swap / Solaris

Thank U in advance!

I saw this,

Should I only manjaro-chroot -a and

grub-install --target=x86_64-efi --efi-directory=/boot/efi --bootloader-id=manjaro --recheck ?

This /boot/efi is ok?

Yes, that should be enough and the efi seems ok.

grub-probe: error: cannot find a GRUB drive for /dev/sda1.  Check your device.map.
grub-probe: error: cannot find a GRUB drive for /dev/sda1.  Check your device.map.
==> Mounting (ManjaroLinux) [/dev/nvme0n1p1]
 --> mount: [/mnt]
[manjaro-gnome /]# grub-install --target=x86_64-efi --efi-directory=/boot/efi --bootloader-id=manjaro --recheck
Installing for x86_64-efi platform.
grub-install: error: failed to get canonical path of `/boot/efi'.```

I am not sure how to proceed, but i think there were other topics with this error so search the forum a bit.
Can it be that the live usb is not created or booted in uefi mode? I am not sure.
You can try

test -d /sys/firmware/efi && echo efi || echo bios

and

lsblk -o PATH,PTTYPE,PARTTYPE,FSTYPE,PARTTYPENAME

[manjaro-gnome /]# test -d /sys/firmware/efi && echo efi || echo bios
bios

So for some reason you are in bios mode and that is why the command for efi does not work. But you do have efi partition so i will assume the win is also installed as efi.
Check the bios/uefi settings if it is in real uefi mode or in some kind of compatibility mode like CSM, and then try again. Maybe you will need to recreate the live flash drive from a uefi system (i used balena etcher on windows) (not sure if it has both and boots both or remembers how it is created)

Maybe I should run this:

grub-install --force --target=i386-pc --recheck --boot-directory=/boot /dev/nvme0n1

?

That would be the alternative i you want to stay old scholl, but then again how did an efi partition got there in nothing is EFI. Mixing both is the least desirable and most problematic option.

1 Like

If you had a working EFI install, and you also installed windoze in EFI afterwards, and simply ‘lost’ grub, as in windoze boots first you can do the following from windoze;

From win (cmd as admin), you would probably just do something like

bcdedit

(check output)

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

(depending on the actual path, though that is likely correct)

1 Like

Your problem seems to be that you have your Linux installed in BIOS mode and Windoof in UEFI mode. This combination only allows you to switch between the installs from your firmware. If you want to use both and select the OS from grub menu you must have both systems installed in the same mode.

As Windoof most likely cannot be installed in BIOS mode any more you need to reinstall Linux in UEFI mode. Don’t forget to save your data upfront if you plan to do so.

2 Likes

My solution was:
install both systems (Windoof and linux) in UEFI-mode
AND remove Linux-disks while installing Windoof,
then remove Windoof-disks while installing Linux.
THEN connect both systems, go to uefi and set start-priority to the Linux-start-disk.
The GRUB-Loader will detect Windoof and add an entry to grub-menu…

Thanks U All!
I’ll try to do each solution :slight_smile:

1 Like

Hello,
I’ve turned off secure boot and live CD started like EFI:

`test -d /sys/firmware/efi && echo efi || echo bios

efi
`
But still error:

manjaro-chroot -a                                                                                                                        INT ✘ 
grub-probe: error: cannot find a GRUB drive for /dev/sda1.  Check your device.map.
grub-probe: error: cannot find a GRUB drive for /dev/sda1.  Check your device.map.
==> Mounting (ManjaroLinux) [/dev/nvme0n1p1]
 --> mount: [/mnt]
[manjaro-gnome /]# grub-install --target=x86_64-efi --efi-directory=/boot/efi --bootloader-id=manjaro --recheck
Installing for x86_64-efi platform.
grub-install: error: failed to get canonical path of `/boot/efi'.

I need mount the partition with linux?

lsblk -o PATH,PTTYPE,PARTTYPE,FSTYPE,PARTTYPENAME                                                       ✔ 
PATH           PTTYPE PARTTYPE                             FSTYPE   PARTTYPENAME
/dev/loop0                                                 squashfs 
/dev/loop1                                                 squashfs 
/dev/loop2                                                 squashfs 
/dev/loop3                                                 squashfs 
/dev/sda       dos                                         iso9660  
/dev/sda1      dos    0x0                                  iso9660  Empty
/dev/sda2      dos    0xef                                 vfat     EFI (FAT-12/16/32)
/dev/nvme1n1   gpt                                                  
/dev/nvme1n1p1 gpt    c12a7328-f81f-11d2-ba4b-00a0c93ec93b vfat     EFI System
/dev/nvme1n1p2 gpt    e3c9e316-0b5c-4db8-817d-f92df00215ae          Microsoft reserved
/dev/nvme1n1p3 gpt    ebd0a0a2-b9e5-4433-87c0-68b6b72699c7 ntfs     Microsoft basic data
/dev/nvme1n1p4 gpt    de94bba4-06d1-4d40-a16a-bfd50179d6ac ntfs     Windows recovery environment
/dev/nvme0n1   dos                                                  
/dev/nvme0n1p1 dos    0x83                                 ext4     Linux
/dev/nvme0n1p2 dos    0x82                                 swap     Linux swap / Solaris

[manjaro-gnome /]# cat /etc/fstab 
# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a device; this may
# be used with UUID= as a more robust way to name devices that works even if
# disks are added and removed. See fstab(5).
#
# <file system>             <mount point>  <type>  <options>  <dump>  <pass>
UUID=da6cabcf-94d9-4730-a334-19e98da6dc0a /              ext4    defaults,noatime 0 1
UUID=f73c220f-b3f0-46ac-ad0e-41635be91aa3 swap           swap    defaults,noatime 0 0
tmpfs                                     /tmp           tmpfs   defaults,noatime,mode=1777 0 0
/dev/disk/by-uuid/93b17eb3-9e51-4071-a8df-e32062445545 /mnt/93b17eb3-9e51-4071-a8df-e32062445545 auto nosuid,nodev,nofail,x-gvfs-show 0 0

PS
If it helps The linux is here and the boot directory also with the grub

/dev/nvme0n1p1 dos    0x83                                 ext4     Linux
[manjaro-gnome boot]# ls -la
total 213160
drwxr-xr-x  4 root root     4096 Dec 19 12:52 .
drwxr-xr-x 17 root root     4096 Dec 20 17:55 ..
-rw-r--r--  1 root root    81920 Dec 11 16:32 amd-ucode.img
drwxr-xr-x  6 root root     4096 Dec 19 12:52 grub

or maybe should I mount this Winodws partition as /boot?

/dev/nvme1n1p1 gpt    c12a7328-f81f-11d2-ba4b-00a0c93ec93b vfat     EFI System

I think now i know what is up. You have achieved a mix of bios and uefi and mbr (nvme0) and gpt (nvme1), which is the least desirable setup.
Now that you fixed the uefi settings and the installation media, if you can, you could reformat the nvme0 in gpt and reinstall in pure uefi mode. Or convert the partition table if you do not want to loose the current linux install.

Otherwise, well, you will not be able to make the windows appear in the grub menu. And everytime you want to switch between win and linux you will have to toggle uefi/bios(csm) mode there. Because now windows is uefi and linux is bios. If you decide to go that path the grub-install will be with target-i386.

Maybe someone can add something here, the mixed setups are not my strength.

hm… Where can I see this? When I was installing manjaro on

/dev/nvme0n1

I’m almost sure I’ve picked flags efi and boot.

From this link

They are suggesting mounting the partition EFI (that windows created) and mount the root linux partition.

sudo mount /dev/nvme0n1p5 /mnt

sudo mount /dev/nvme0n1p1 /mnt/boot/efi

but I’m not sure that helps. WDYT?

Yes you can manually mount the efi and grub-install will not complain anymore, but then again, how will an efi bootloader load the rest of the os if it is not efi. You will succeed in grub-install and then the system will fail to boot, so in this case this error is a good error.

In the PTTYPE in lsblk is written “dos”, which means MBR partitioning scheme.

Or convert the partition table if you do not want to loose the current linux install.

ok, So how can I do that. With GParted?
I have SWAP partition, that I can remove and create another partition like boot/efi ? Should I?