Which commands to convert a Ubuntu BIOS install to EFI/UEFI without boot-repair on single boot hardware?
Solution 1:
Start a Ubuntu Linux (14.04) Live CD in UEFI mode. In case of a USB boot device, disable "Fast Boot" in UEFI.
Open a terminal window (Ctrl+Alt+T)
To verify that you are actually running in UEFI mode, use this bash command:
$ [ -d /sys/firmware/efi ] && echo UEFI || echo BIOS
The resulting output should be:
UEFI
In case it says BIOS
, reboot into your firmware and correct the boot device preference.
To do the BIOS to EFI/UEFI conversion enter these commands:
$ sudo mount /dev/sda1 /mnt
$ sudo mkdir -p /mnt/boot/efi
$ sudo mount /dev/sda3 /mnt/boot/efi
$ sudo mount --bind /dev /mnt/dev
$ sudo mount --bind /proc /mnt/proc
$ sudo mount --bind /sys /mnt/sys
$ sudo mount --bind /run /mnt/run
$ modprobe efivars
$ sudo chroot /mnt
# apt-get install grub-efi-amd64
Apt-get networking failure?
# rm /etc/resolv.conf
# ln -s ../run/systemd/resolve/stub-resolv.conf resolv.conf
# apt-get install grub-efi-amd64
No apt-get failure
The following extra packages will be installed:
efibootmgr grub-efi-amd64-bin
The following packages will be removed:
grub-gfxpayload-lists grub-pc
...
After this operation, 2,399 kB of additional disk space will be used.
# grub-install --target=x86_64-efi --efi-directory=/boot/efi --bootloader-id=ubuntu --recheck --no-floppy --debug
Despite ending in error message:
Fatal: Couldn't open either sysfs or procfs directories for accessing EFI variables.
Try 'modprobe efivars' as root.
the next reboot already shows "ubuntu" in the firmware its boot options menu, and boots to the console as before, except for now booting in efi mode:
$ dmesg | grep EFI
efi: EFI v2.31 by American Megatrends
fb0: EFI VGA frame buffer device
EFI Variables Facility v0.08 2004-May-17
fb: switching to inteldrmfb from EFI VGA
In case something goes wrong, https://superuser.com/questions/376470/how-to-reinstall-grub2-efi might help.
Solution 2:
Small correction:
sudo apt-get install -y grub-efi-amd64
sudo mount /dev/sda1 /mnt
sudo mkdir -p /mnt/boot/efi
sudo mount /dev/sda3 /mnt/boot/efi
for d in dev sys proc usr run; do sudo mount -B /$d /mnt/$d; done
sudo modprobe efivars
sudo chroot /mnt
grub-install --target=x86_64-efi --efi-directory=/boot/efi --bootloader-id=ubuntu --recheck --no-floppy --debug
Done.
Solution 3:
This worked for me too with one small alteration. Even though the network was working I couldn't get the apt-get install grub-efi-amd64
to find any of the package servers.
I got around this by booting up in BIOS mode one final time and installing grub-efi-amd64.
I could then follow the procedures here with exception of omitting apt-get install grub-efi-amd64
.