How to turn legacy/MBR LVM encrypted disk into UEFI?

Hello, the Latest Debian 11 setup confused me into not forcing UEFI setup on possibly UEFI-only computer.

And upon boot attempt it shows “no such cryptodisk” kind of grub rescue error. I Have tried to use Debian installation EFI USB drive to boot into rescue mode, mount cryptodisk, /boot using GUI and initiated grub reinstall on a /dev/sdX that i have verified using lsblk/df commands is correct drive. But mentioned boot error does not go away.
Which commands do You suggest please?

i have found some articles, but do not understand which/if apply on my issue case. Thank You

For UEFI you need to create a partition named /boot/efi. It must be vfat type. Here is how it looks on my Debian 11 server:

Filesystem               Type     1K-blocks      Used Available Use% Mounted on
udev                     devtmpfs  16354880         0  16354880   0% /dev
tmpfs                    tmpfs      3274780      1200   3273580   1% /run
/dev/mapper/md1_vg0-root ext4     950619836 325204964 577056268  37% /
tmpfs                    tmpfs     16373896         0  16373896   0% /dev/shm
tmpfs                    tmpfs         5120         0      5120   0% /run/lock
/dev/md0                 ext4        944120    134500    744444  16% /boot
/dev/sda1                vfat        973952      3484    970468   1% /boot/efi
tmpfs                    tmpfs      3274776         0   3274776   0% /run/user/0

So you need two partitions for booting:

  • /dev/sdb1 - vfat mounted at /boot/efi
  • /dev/sdb2 - ext4 mounted at /boot/

Rest you can configure as per your needs.

1 Like

This is what i have. Is it doable, what do you suggest?

and after i create it, i should grub-install (being chroot into my encrypted /root part. right?

Btw. here is some tutorial that is using gdisk, partprobe, mkfs commands, but i am unsure if it can apply on my case or which steps to omit etc.

If you have data, back it up. Then format everything and make partition schema for /boot and /boot/efi and rest of / fs and then install it.

Thanks for help :+1:, also what may work is something like following. If you are having different distribution, steps may be similar, not same. You are doing this on your own risk:

Use gparted to resize /boot partition to make room for new 40MB fat32 partition with esp, boot flags.
Boot Debian installer, Advanced options, Graphical rescue, …, answer passphrase (if have LVM encrypted drive), select /dev/hostname-vg/root as your root FS (or other appropriate /root). Confirm to mount /boot
Select to execute shell in above mentioned root path and run:

lsblk # to discover your small esp/efi partition path according to displayed size (lets say it is /dev/sda3 - used below)
mkdir /boot/efi && mount /dev/sda3 /boot/efi
DEBIAN_FRONTEND=dialog apt install grub-efi-amd64
grub-install --force-extra-removable --target=x86_64-efi --efi-directory=/boot/efi --recheck /dev/sdX # sdX being your Debian drive displayed by “lsblk”

some commands or switches may be redundant, i do not know which