From mboxrd@z Thu Jan 1 00:00:00 1970 From: Carlos Santos Date: Sat, 29 Sep 2018 00:16:09 -0300 Subject: [Buildroot] [PATCH v2] configs/pc: add a configuration to build a UEFI+GPT image Message-ID: <20180929031609.8939-1-casantos@datacom.com.br> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: buildroot@busybox.net This is an example of how to craft a disk image with GPT partitioning instead of MBR. This is achieved by means of a post-image script which uses mkdosfs+mcopy+sfdisk, since genimage is unable to deal with GPT. The script was kept as simple as possible to make it easy to understand and adapt for other purposes. The root filesystem location is passed to the kernel by a partition UUID, so it is possible to boot on QEMU, directly from the disk image, or dump the image to a physical device. Signed-off-by: Carlos Santos Acked-by: Thomas Petazzoni --- Changes v1->v2: Fix commit message ("ane", spurious "the"). --- board/pc/post-image-efi-gpt.sh | 62 ++++++++++++++++++++++++++++ board/pc/readme.txt | 6 ++- configs/pc_x86_64_efi_gpt_defconfig | 64 +++++++++++++++++++++++++++++ 3 files changed, 131 insertions(+), 1 deletion(-) create mode 100755 board/pc/post-image-efi-gpt.sh create mode 100644 configs/pc_x86_64_efi_gpt_defconfig diff --git a/board/pc/post-image-efi-gpt.sh b/board/pc/post-image-efi-gpt.sh new file mode 100755 index 0000000000..d2acd8f852 --- /dev/null +++ b/board/pc/post-image-efi-gpt.sh @@ -0,0 +1,62 @@ +#!/bin/sh + +set -e + +cd ${BINARIES_DIR} + +# GPT partition type UUIDs +esp_type=c12a7328-f81f-11d2-ba4b-00a0c93ec93b +linux_type=44479540-f297-41b2-9af7-d131d5f0458a + +# Partition UUIDs +efi_part_uuid=$(uuidgen) +root_part_uuid=$(uuidgen) + +# Boot partition offset and size, in 512-byte sectors +efi_part_start=64 +efi_part_size=32768 + +# Rootfs partition offset and size, in 512-byte sectors +root_part_start=$(( efi_part_start + efi_part_size )) +root_part_size=$(( $(stat -c %s rootfs.ext2) / 512 )) + +first_lba=34 +last_lba=$(( root_part_start + root_part_size )) + +# Disk image size in 512-byte sectors +image_size=$(( last_lba + first_lba )) + +cat > efi-part/EFI/BOOT/grub.cfg <