Wireless Army
This is a blog / tips and tricks website for web developers and security researchers.
follow us in feedly


Switch Debian 8 from bios to UEFI
by admin
 at 2016-10-30 20:37:39.

We will install a Debian ISO on a usb or hard drive. And then convert the bios to UEFI
(This example can also be entirely done in a with Virtualization)

Tools you may need:

  • A USB or cd for putting the OS on it
  • and other USB or hard drive as your main installation drive.
  • uefi compatible motherboard


After writing the iso on a usb and booting from it and install it on a hard drive with the graphical interface.
Because you can’t (easily) build uefi if you are not booted from it, we will download and iso from a linux distro that provides iso with uefi already on it(evolve os, manjaro, semplice 6, Slackel,…) and rewrite on the first usb. Boot from it.
With gparted GUI resize your main boot partition from 243 to 200.
create a fat32 primary partition for 43mb. Give it the boot and esp flag

gdisk /dev/sdb
r
f
w


and now gdisk -l /dev/sda


should give you:
MBR: protective
BSD: not present
APM: not present
GPT: present


Mount your hard drive on /mnt (sda is bootable usb and sdb is your hard drive and it may differ in your case)
mount -t ext4 /dev/sdc5 /mnt


or if it is encrypted:


cryptsetup luksOpen /dev/sdb5 sdb5_crypt
mount -t ext4 /dev/mapper/example-root /mnt
mount /dev/sda1 /mnt/boot
mount /dev/sda2 /mnt/boot/efi
for i in /dev/ /dev/pts /proc /sys ; do mount -B $i /mnt/$i ; done


get a chroot environment:


chroot /mnt
type blkid to get the UUID of your fat32 partition
edit /etc/fstab and add the following line with your UUID


UUID=94D0-2462 /boot/efi vfat defaults 0 2


For internet access inside chroot:
cp /etc/resolv.conf /mnt/etc/resolv.conf


apt-get remove grub-pc && apt-get install grub-efi-amd64
grub-install /dev/sdb –target=x86_64-efi
update grub
cd /boot/efi/EFI
mkdir boot
cp debian/grubx64.efi boot/bootx64.efi
exit
for i in /sys /proc /dev; do umount /target$i; done
umount /mnt/boot/efi
file /boot/efi/EFI/debian/grubx64.efi
efibootmgr

and now you should be able to boot to uefi
if you have any question or if you get any other problems, just leave a comment down below and I'll try to answer it if i can.