Moving a Hard Drive Between UEFI Systems

Posted on Sat 11 February 2017 in doc

If you swap your hard drive from one Linux system to another, and you were setup to boot your system with UEFI, you may need to configure the new system to know how to boot your new hard drive.

I recently ran into this on a Lenovo Thinkpad X230 which showed the hard drive in the BIOS’ boot menu, but would simply not boot from it.

I started by looking at the configuration on another, working, system. This sytem should, in theory, be identical to the system I was moving a hard drive from. It looked like this:

# efibootmgr -v  | grep ubuntu
Boot0018* ubuntu    HD(1,GPT,ebe71066-4535-4318-a508-fe32690221e6,0x800,0x100000)/File(\EFI\ubuntu\shimx64.efi)

To reproduce the above entry in the new system, using efibootmgr, the required command looks like this:

# efibootmgr --create --disk /dev/sda --part 1 --loader "\EFI\ubuntu\shimx64.efi" --label "ubuntu"

After adding the UEFI entry, the system booted happily from a boot menu option that appears as ubuntu. For an indepth explanation of UEFI, have a look at this article (by another Adam).