6

For some reason GRUB on hard drive WDC WD40EJRX-89A disappear. Maybe the reason is that I physically change SATA drives/cables and I'm not sure if I plug SATA cables in same slots.

I try to reinstall GRUB using live cd but it's not getting installed

    root@debian:~# fdisk -l
Disk /dev/sdc: 232.89 GiB, 250059350016 bytes, 488397168 sectors
Disk model: Samsung SSD 850 
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: gpt


Device         Start       End   Sectors   Size Type
/dev/sdc1       2048   1085439   1083392   529M Windows recovery environment
/dev/sdc2    1085440   1290239    204800   100M EFI System
/dev/sdc3    1290240   1323007     32768    16M Microsoft reserved
/dev/sdc4    1323008 185296895 183973888  87.7G Microsoft basic data
/dev/sdc5  185296896 488394751 303097856 144.5G Microsoft basic data


Disk /dev/sdb: 3.64 TiB, 4000787030016 bytes, 7814037168 sectors
Disk model: WDC WD40EJRX-89A
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: gpt


Device          Start        End    Sectors   Size Type
/dev/sdb1        2048    1050623    1048576   512M EFI System
/dev/sdb2     1050624    4956159    3905536   1.9G Linux filesystem
/dev/sdb3     4956160 5669019647 5664063488   2.6T Linux filesystem
/dev/sdb4  5669019648 5669224447     204800   100M EFI System
/dev/sdb5  5669224448 5669257215      32768    16M Microsoft reserved
/dev/sdb6  5669257216 5882199868  212942653 101.5G Microsoft basic data
/dev/sdb7  5882200064 5883518975    1318912   644M Windows recovery environment
/dev/sdb8  5883521024 5883725823     204800   100M EFI System
/dev/sdb9  5883725824 5883930623     204800   100M EFI System


Disk /dev/sda: 931.51 GiB, 1000204886016 bytes, 1953525168 sectors
Disk model: ST1000VX000-1ES1
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

Device     Boot     Start        End    Sectors   Size Id Type
/dev/sda1  *         2048    6053887    6051840   2.9G 83 Linux
/dev/sda2       336230400 1953521663 1617291264 771.2G  7 HPFS/NTFS/exFAT
/dev/sda3         6055934  336230399  330174466 157.4G  5 Extended
/dev/sda5         6055936  336230399  330174464 157.4G 83 Linux

Partition 3 does not start on physical sector boundary.
Partition table entries are not in disk order.


Disk /dev/sdd: 7.5 GiB, 8056209408 bytes, 15734784 sectors
Disk model: Transcend 8GB   
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

Device     Boot Start     End Sectors  Size Id Type
/dev/sdd1  *        0 4938303 4938304  2.4G  0 Empty
/dev/sdd2        1496    6721    5226  2.6M ef EFI (FAT-12/16/32)


Disk /dev/loop0: 2.08 GiB, 2237280256 bytes, 4369688 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes

root@debian:~# cryptsetup luksOpen /dev/sdb3 home_sdb3
Enter passphrase for /dev/sdb3: 
root@debian:~# vgchange -ay
  2 logical volume(s) in volume group "User-PC-vg" now active
root@debian:~# vgscan
  Found volume group "User-PC-vg" using metadata type lvm2
root@debian:~# vgscan -ay 
vgscan: invalid option -- 'a'
  Error during parsing of command line.
root@debian:~# vgchange -ay
  2 logical volume(s) in volume group "User-PC-vg" now active
root@debian:~# lvscan
  ACTIVE            '/dev/User-PC-vg/root' [<55.88 GiB] inherit
  ACTIVE            '/dev/User-PC-vg/home' [2.58 TiB] inherit
root@debian:~# mount /dev/User-PC-vg/root /mnt
root@debian:~# modprobe efivars
modprobe: FATAL: Module efivars not found in directory /lib/modules/5.10.0-10-amd64
root@debian:~# mount /dev/sdb1 /mnt/boot/efi
mount: /mnt/boot/efi: mount point does not exist.
root@debian:~# mount /dev/User-PC-vg/root /mnt
mount: /mnt: /dev/mapper/User--PC--vg-root already mounted on /mnt.
root@debian:~# mount /dev/sdb1 /mnt/boot/efi^C
root@debian:~# umount /mnt
root@debian:~# mkdir /media/linux
root@debian:~# mount /dev/User-PC-vg/root /media/linux/
root@debian:~# modprobe efivars
modprobe: FATAL: Module efivars not found in directory /lib/modules/5.10.0-10-amd64
root@debian:~# mount /dev/sdb1 /media/linux/boot/efi
mount: /media/linux/boot/efi: mount point does not exist.
root@debian:~# mount --bind /dev /media/linux/dev/
root@debian:~# mount --bind /dev/pts /media/linux/dev/pts
root@debian:~# mount --bind /proc /media/linux/proc
root@debian:~# mount --bind /sys /media/linux/sys
root@debian:~# chroot /media/linux
root@debian:/# mount /dev/sdb1 /boot/efi
mount: /boot/efi: mount point does not exist.
root@debian:/# mount /dev/sdb2 /boot


root@debian:~# chroot /media/linux
root@debian:/# mount /dev/sdb1 /boot/efi
root@debian:/# mount /dev/sdb2 /boot
mount: /boot: /dev/sdb2 already mounted on /boot.

root@debian:/etc/apt/sources.list.d# apt-get install --reinstall grub-efi-amd64
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
0 upgraded, 0 newly installed, 1 reinstalled, 0 to remove and 0 not upgraded.
Need to get 39.8 kB of archives.
After this operation, 0 B of additional disk space will be used.
Get:1 http://deb.debian.org/debian bullseye/main amd64 grub-efi-amd64 amd64 2.04-20 [39.8 kB]
Fetched 39.8 kB in 0s (271 kB/s)          
Preconfiguring packages ...
(Reading database ... 169682 files and directories currently installed.)
Preparing to unpack .../grub-efi-amd64_2.04-20_amd64.deb ...
Unpacking grub-efi-amd64 (2.04-20) over (2.04-20) ...
Setting up grub-efi-amd64 (2.04-20) ...
Installing for x86_64-efi platform.
grub-install: warning: EFI variables are not supported on this system..
Installation finished. No error reported.
Generating grub configuration file ...
Found background image: /usr/share/images/desktop-base/desktop-grub.png
Found linux image: /boot/vmlinuz-5.10.0-11-amd64
Found initrd image: /boot/initrd.img-5.10.0-11-amd64
Found linux image: /boot/vmlinuz-5.10.0-10-amd64
Found initrd image: /boot/initrd.img-5.10.0-10-amd64
grub-probe: error: cannot find a GRUB drive for /dev/sdd1.  Check your device.map.
done
Processing triggers for shim-signed:amd64 (1.38+15.4-7) ...
root@debian:/etc/apt/sources.list.d#     apt-get install --reinstall grub-efi
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following NEW packages will be installed:
  grub-efi
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 2,536 B of archives.
After this operation, 16.4 kB of additional disk space will be used.
Get:1 http://deb.debian.org/debian bullseye/main amd64 grub-efi amd64 2.04-20 [2,536 B]
Fetched 2,536 B in 0s (13.6 kB/s)    
Selecting previously unselected package grub-efi.
(Reading database ... 169682 files and directories currently installed.)
Preparing to unpack .../grub-efi_2.04-20_amd64.deb ...
Unpacking grub-efi (2.04-20) ...
Setting up grub-efi (2.04-20) ...
root@debian:/etc/apt/sources.list.d# update-grub
Generating grub configuration file ...
Found background image: /usr/share/images/desktop-base/desktop-grub.png
Found linux image: /boot/vmlinuz-5.10.0-11-amd64
Found initrd image: /boot/initrd.img-5.10.0-11-amd64
Found linux image: /boot/vmlinuz-5.10.0-10-amd64
Found initrd image: /boot/initrd.img-5.10.0-10-amd64
grub-probe: error: cannot find a GRUB drive for /dev/sdd1.  Check your device.map.
done
root@debian:/etc/apt/sources.list.d# cat /boot/grub/device.map 
cat: /boot/grub/device.map: No such file or directory
root@debian:/etc/apt/sources.list.d# grub-mkdevicemap
root@debian:/etc/apt/sources.list.d# lsblk
NAME                    MAJ:MIN RM   SIZE RO TYPE  MOUNTPOINT
loop0                     7:0    0   2.1G  1 loop  
sda                       8:0    0 931.5G  0 disk  
├─sda1                    8:1    0   2.9G  0 part  
├─sda2                    8:2    0 771.2G  0 part  
├─sda3                    8:3    0     1K  0 part  
└─sda5                    8:5    0 157.4G  0 part  
sdb                       8:16   0   3.6T  0 disk  
├─sdb1                    8:17   0   512M  0 part  /boot/efi
├─sdb2                    8:18   0   1.9G  0 part  /boot
├─sdb3                    8:19   0   2.6T  0 part  
│ └─home_sdb3           253:0    0   2.6T  0 crypt 
│   ├─User--PC--vg-root 253:1    0  55.9G  0 lvm   /
│   └─User--PC--vg-home 253:2    0   2.6T  0 lvm   
├─sdb4                    8:20   0   100M  0 part  
├─sdb5                    8:21   0    16M  0 part  
├─sdb6                    8:22   0 101.5G  0 part  
├─sdb7                    8:23   0   644M  0 part  
├─sdb8                    8:24   0   100M  0 part  
└─sdb9                    8:25   0   100M  0 part  
sdc                       8:32   0 232.9G  0 disk  
├─sdc1                    8:33   0   529M  0 part  
├─sdc2                    8:34   0   100M  0 part  
├─sdc3                    8:35   0    16M  0 part  
├─sdc4                    8:36   0  87.7G  0 part  
└─sdc5                    8:37   0 144.5G  0 part  
sdd                       8:48   1   7.5G  0 disk  
├─sdd1                    8:49   1   2.4G  0 part  
└─sdd2                    8:50   1   2.6M  0 part  
root@debian:/etc/apt/sources.list.d# grub-install /dev/sdb
Installing for x86_64-efi platform.
grub-install: warning: EFI variables are not supported on this system..
Installation finished. No error reported.
root@debian:/etc/apt/sources.list.d# cat  /boot/grub/device.map 
(hd0)   /dev/disk/by-id/lvm-pv-uuid-kgnDO4-VKw7-Vw8c-71N3-ez6U-GoGj-T9lueq
(hd1)   /dev/disk/by-id/ata-ST1000VX000-1ES162_Z4YE5K37
(hd2)   /dev/disk/by-id/ata-WDC_WD40EJRX-89AKWY0_WD-WX32D21CZ08S
(hd3)   /dev/disk/by-id/ata-Samsung_SSD_850_EVO_250GB_S2R6NB0H926126V
(hd4)   /dev/disk/by-id/usb-JetFlash_Transcend_8GB_64E2V0LU-0:0
2
  • You should only have one ESP - efi system partition per device. You are now showing 3 ESP on sdb. But you may have different system set to boot from each? And need to reinstall boot loaders from all systems into the one ESP you keep. You do have to boot live installer or any Windows repair flash drive in UEFI mode to make UEFI repairs.
    – oldfred
    Mar 6, 2022 at 14:51
  • I got that same error grub-install: warning: EFI variables are not supported on this system. Pointing grub-install on a boot partition prepared by gnu parted and or fdisk on a USB stick according to the gentoo handbook. Solution here: pass the --removable flag to grub-install src instructions: superuser.com/questions/1738694/… Oct 25, 2022 at 2:36

2 Answers 2

14

When bind mounting /sys for the chroot, use --rbind instead of --bind, i.e.

mount --rbind /sys /media/linux/sys

Alternatively, manually mount the efivarfs virtual filesystem to /sys/firmware/efi/efivars after you've chrooted:

mount -t efivarfs none /sys/firmware/efi/efivars

grub-install will need that filesystem to manipulate EFI boot variables. mount --rbind includes any submounts of the original, while regular --bind omits them.

If the efivarfs filesystem does not seem to be available, make sure you have booted the live media in UEFI mode. If you've accidentally booted the live media in legacy BIOS mode, the firmware API for manipulating EFI boot variables (which is used by efivarfs) will not be available.

1
0

to me, I create another fat32 512MB partition with flag boot and efi and install linux again

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .