0

I have a pastbin URL: pastbin

I have two physical hard drives, Ubuntu 20.04 is installed on the second HD on a LUKS encrypted drive. The bootloader was on the first drive. I deleted the first drive (it had windows installed, I don't need that anymore). But now I cannot boot anymore.

I was asked if I also deleted the uefi partition. I do not know. I used gparted to delete the windows partition. How can I find out?

fdisk -l has the output:

Device       Start      End Sectors  Size Type
/dev/sda1       64  7465119 7465056  3.6G Microsoft basic data
/dev/sda2  7465120  7473615    8496  4.1M EFI System
/dev/sda3  7473616  7474215     600  300K Microsoft basic data
/dev/sda4  7475200 15761440 8286241    4G Linux filesystem

But of course I do not know if this EFI partition contains any data, and I also have a second EFI partition on the second SSD.

I can boot from a live USB stick and mount the encrypted partition.

Second HD has three partitions:

Device           Start        End    Sectors   Size Type
/dev/nvme1n1p1    2048    1050623    1048576   512M EFI System
/dev/nvme1n1p2 1050624    2549759    1499136   732M Linux filesystem
/dev/nvme1n1p3 2549760 2000408575 1997858816 952.7G Linux filesystem

But how can I re-install the bootloader? Should I install it on the first or the second drive?

I tried:

### Mount encrypted rootfs in chroot environment
sudo -i
apt-get update
apt-get install cryptsetup lvm2
fdisk -l
cryptsetup luksOpen /dev/nvme1n1p3 rootcrypt            # device is your root partition
vgchange -ay
vgscan
vgchange -ay vgubuntu                                # From the above command
lvscan
mount /dev/vgubuntu/root /mnt          # LOGICAL VOLUME NAME from above command
modprobe efivars
mount /dev/nvme1n1p2 /mnt/boot
mount /dev/nvme1n1p1 /mnt/boot/efi     # nvme? is your efi partition
for i in /dev /dev/pts /proc /sys /sys/firmware/efi/efivars /run; do sudo mount -B $i /mnt$i; done
cp /etc/resolv.conf /mnt/etc/
chroot /mnt

Reinstall grub

apt-get install --reinstall grub-efi-amd64 grub-install /dev/nvme1n1 update-grub exit

Not tested

umount /mnt/boot/efi umount /mnt/boot umount /mnt vgchange -an chryptsetup luksClose rootcrypt

This fixed my problem.

Lessons learned:

  • the efi and the unencrypted boot partition must be manually mounted in the decrypted root file system
  • also the efivars need to be mounted
  • grub-install on the second drive must be executed

Not yet clear to me: Why unmounting fails.

1 Answers1

0

Boot into the live environment.

Install it on the drive where your OS is.

The command sudo grub-install /dev/sdb will install Grub2 on the second drive.

I cannot see the pastebin as they don't send me an email after making an account. So I'm lacking some information. Also about how the second drive is set up.

See for more information this page: https://help.ubuntu.com/community/Grub2/Installing. Use the commands that fit your setup.

Joepie Es
  • 1,570