Copying should be relatively easy; Linux installations are (almost entirely) just files. The biggest (only?) exception is the bootloader for BIOS; it is installed to the master boot record and the sectors between that and the first partition. UEFI actually gets rid of that exception; the bootloader is now just a file as well.
BIOS boot works (in brief) that the BIOS reads the first sector from the disk (MBR), and executes the code out of that sector. That code has BIOS functions to read sectors available to it, and in the case of grub, it reads the rest of itself out of the remaining sectors between the MBR and the first partition. That needs to provide enough code to let GRUB understand filesystems, so it can read the config and the rest of itself from /boot. It does that, then also reads the kernel and initramfs from there. Then it fires up the kernel.
UEFI boot works (in brief) that the firmware understands partitions (at least GPT, and probably DOS as well) and filesystems (at least FAT). It has NVRAM of some sort (the EFI variables) that stores a command to run—think shell command (UEFI includes a shell). That is, path (disk, partition, path on filesystem) and arguments. It runs that command. In the case of Linux, that'd be one of:
- a bootloader like GRUB (under Debian, probably at
EFI/debian/grubx64.efi
) or several others (refind, systemd-boot, etc.)
- a Linux kernel (supported in Debian since Wheezy)
- a Microsoft-signed shim for secure boot, which then loads one of the above.
The command has full access to the UEFI stack, which includes reading files, network, etc. In the case of GRUB, it includes its own filesystem support which is uses for things like ext4, mdraid, LVM, etc.
Ultimately, from your Linux install, that means the difference it sees is: instead of GRUB being installed in a few special sectors at the start of the disk, its a file in /boot/efi/
. Note that this is a different build of GRUB; under Debian it's grub-efi-amd64 (or -ia32) instead of grub-pc. You'll need to switch out which grub package you have installed.
The only thing that I expect you may run into is that manipulating the EFI variables typically requires you already be booted via UEFI. So it can be hard to get that grub-install to work. A few workarounds:
After copying the system and changing the grub package out, boot to an UEFI-enabled rescue disc (such as the Stretch installer, running in rescue mode) and run grub-install or efibootmgr.
If your system has a boot selection menu, it might find the Debian install even without it being set up as a boot option via the EFI variables.
Copy grub to /boot/efi/EFI/debian/grubx64.efi
to /boot/efi/EFI/BOOT/bootx64.efi
— that's the official UEFI fallback path (at least for 64-bit machines). That might be enough to get it to show up in the firmware boot menu.
If your system makes it available, use the UEFI shell to boot the system. Then you can update the EFI variables with grub-install or efibootmgr.
After you've done that, there shouldn't be anything different between your copied/converted system and one that was installed with UEFI originally.
/boot
partition to the new installation. Can you? – Faheem Mitha Jun 30 '17 at 22:02