How do I create a bootable GPT UEFI Linux disk?

8,463

Please use Gparted to create a gpt based disk (not ms-dos, older partitions).

  • Create a new partition table (gpt type).
  • Have a EFI system partition (ESP)
  • Create the remaining partitions needed for the OS and boot the installation media in UEFI mode. To boot linux: usually /boot, /, and swap.

Please read:

UEFI partitioning for dummies
EFI System Partition

Share:
8,463

Related videos on Youtube

Duke Dougal
Author by

Duke Dougal

Updated on September 18, 2022

Comments

  • Duke Dougal
    Duke Dougal over 1 year

    Aaargh. After days of reading and trying everything I'm still stuck in a maze. It should be simple but I cannot work it out.

    I need to create one bootable UEFI disk partition that contains all the space on the disk. The steps must work in a shell script. Ideally with syslinux/extlinux but if not possible then grub.

    How to do this? Surely it should be dead easy, a handful of lines? Nothing I do works.

    This is what I have so far:

    DISK_DEVICE_NAME_CURRENT_OS=hda
    echo remove all partitions
    sudo /usr/local/sbin/sgdisk -Z /dev/${DISK_DEVICE_NAME_CURRENT_OS}
    echo create GPT partition
    sudo /usr/local/sbin/sgdisk -n 1:: /dev/${DISK_DEVICE_NAME_CURRENT_OS}
    echo format file system
    sudo mkfs.ext4 -F /dev/${DISK_DEVICE_NAME_CURRENT_OS}1
    sudo mkdir -p /mnt/target
    sudo mount /dev/${DISK_DEVICE_NAME_CURRENT_OS}1 /mnt/target
    sudo mkdir -p  /mnt/target/boot
    sudo /usr/local/sbin/extlinux --install /mnt/target/boot
    sudo dd if=/usr/local/share/syslinux/gptmbr.bin of=/dev/${DISK_DEVICE_NAME_CURRENT_OS}
    

    When I boot, it says:

    Booting from Hard Disk. Missing OS. No bootable device.

    Any suggestions please as to how I can get this disk to boot?

    thanks

    • Razzlero
      Razzlero over 7 years
      I think that a UEFI boot partition cannot be ext4, I may be wrong about this though.
    • done
      done over 7 years
      It is correct, a UEFI boot partition must be "based on the FAT file system" (usually contains a FAT32 file system) and could not use the whole disk.