From patchwork Sat Sep 29 03:16:09 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Carlos Santos X-Patchwork-Id: 976538 Return-Path: X-Original-To: incoming-buildroot@patchwork.ozlabs.org Delivered-To: patchwork-incoming-buildroot@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=busybox.net (client-ip=140.211.166.133; helo=hemlock.osuosl.org; envelope-from=buildroot-bounces@busybox.net; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=datacom.com.br Received: from hemlock.osuosl.org (smtp2.osuosl.org [140.211.166.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 42MYc45GMkz9sBq for ; Sat, 29 Sep 2018 13:16:36 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by hemlock.osuosl.org (Postfix) with ESMTP id C3E2E88D2F; Sat, 29 Sep 2018 03:16:34 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from hemlock.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 6HvwANgMifTJ; Sat, 29 Sep 2018 03:16:33 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by hemlock.osuosl.org (Postfix) with ESMTP id 66FA388D42; Sat, 29 Sep 2018 03:16:33 +0000 (UTC) X-Original-To: buildroot@lists.busybox.net Delivered-To: buildroot@osuosl.org Received: from fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137]) by ash.osuosl.org (Postfix) with ESMTP id 6E1F51BFBD2 for ; Sat, 29 Sep 2018 03:16:32 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id 6B2DF87A77 for ; Sat, 29 Sep 2018 03:16:32 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from fraxinus.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id NZjN7Le4PiO3 for ; Sat, 29 Sep 2018 03:16:31 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail.datacom.com.br (mx.datacom.ind.br [177.66.5.10]) by fraxinus.osuosl.org (Postfix) with ESMTPS id 7370C87A58 for ; Sat, 29 Sep 2018 03:16:30 +0000 (UTC) Received: from mail.datacom.com.br (localhost [127.0.0.1]) by mail.datacom.com.br (Postfix) with ESMTPS id CDE111BA56DE; Sat, 29 Sep 2018 00:16:31 -0300 (-03) Received: from localhost (localhost [127.0.0.1]) by mail.datacom.com.br (Postfix) with ESMTP id BBB4D1BA567D; Sat, 29 Sep 2018 00:16:31 -0300 (-03) Received: from mail.datacom.com.br ([127.0.0.1]) by localhost (mail.datacom.com.br [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id jfZuwyrEuNw0; Sat, 29 Sep 2018 00:16:31 -0300 (-03) Received: from p7-1130br.casantos.org (unknown [191.35.198.200]) by mail.datacom.com.br (Postfix) with ESMTPSA id 5F3BC1BA567B; Sat, 29 Sep 2018 00:16:31 -0300 (-03) From: Carlos Santos To: buildroot@buildroot.org Date: Sat, 29 Sep 2018 00:16:09 -0300 Message-Id: <20180929031609.8939-1-casantos@datacom.com.br> X-Mailer: git-send-email 2.17.1 Subject: [Buildroot] [PATCH v2] configs/pc: add a configuration to build a UEFI+GPT image X-BeenThere: buildroot@busybox.net X-Mailman-Version: 2.1.24 Precedence: list List-Id: Discussion and development of buildroot List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: buildroot-bounces@busybox.net Sender: "buildroot" 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 <