From owner-svn-src-head@freebsd.org Wed Jul 11 21:53:05 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 25FEA1049E05; Wed, 11 Jul 2018 21:53:05 +0000 (UTC) (envelope-from imp@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id A5D3F8A03A; Wed, 11 Jul 2018 21:53:04 +0000 (UTC) (envelope-from imp@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 8710B18657; Wed, 11 Jul 2018 21:53:04 +0000 (UTC) (envelope-from imp@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w6BLr4xa073444; Wed, 11 Jul 2018 21:53:04 GMT (envelope-from imp@FreeBSD.org) Received: (from imp@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w6BLr4FB073443; Wed, 11 Jul 2018 21:53:04 GMT (envelope-from imp@FreeBSD.org) Message-Id: <201807112153.w6BLr4FB073443@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: imp set sender to imp@FreeBSD.org using -f From: Warner Losh Date: Wed, 11 Jul 2018 21:53:04 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r336213 - head/tools/boot X-SVN-Group: head X-SVN-Commit-Author: imp X-SVN-Commit-Paths: head/tools/boot X-SVN-Commit-Revision: 336213 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 11 Jul 2018 21:53:05 -0000 Author: imp Date: Wed Jul 11 21:53:04 2018 New Revision: 336213 URL: https://svnweb.freebsd.org/changeset/base/336213 Log: Small refactor of install-boot Use newfs_msdos to create the filesystem for the partition requested and use loader.efi instead of boot1.efi. Modified: head/tools/boot/install-boot.sh Modified: head/tools/boot/install-boot.sh ============================================================================== --- head/tools/boot/install-boot.sh Wed Jul 11 20:11:06 2018 (r336212) +++ head/tools/boot/install-boot.sh Wed Jul 11 21:53:04 2018 (r336213) @@ -27,18 +27,33 @@ find-part() { gpart show $dev | tail +2 | awk '$4 == "'$part'" { print $3; }' } -boot_nogeli_gpt_ufs_legacy() { +make_esp() { + local dev dst mntpt + dev=$1 dst=$2 - idx=$(find-part $dev "freebsd-boot") - if [ -z "$idx" ] ; then - die "No freebsd-boot partition found" + newfs_msdos -a 32 /dev/${dev} + mntpt=$(mktemp -d /tmp/stand-test.XXXXXX) + mount -t msdos /dev/${md} ${mntpt} + mkdir -p ${mntpt}/efi/boot + cp ${dst}/boot/loader.efi ${mntpt}/efi/boot/bootx64.efi + umount ${mntpt} + rmdir ${mntpt} +} + +make_esp_mbr() { + dev=$1 + dst=$2 + + s=$(find-part $dev "!239") + if [ -z "$s" ] ; then + die "No ESP slice found" fi - doit gpart bootcode -b ${gpt0} -p ${gpt2} -i $idx $dev + make_esp /dev/${dev}s${s} ${dst} } -boot_nogeli_gpt_ufs_uefi() { +make_esp_gpt() { dev=$1 dst=$2 @@ -46,9 +61,24 @@ boot_nogeli_gpt_ufs_uefi() { if [ -z "$idx" ] ; then die "No ESP partition found" fi - doit gpart bootcode -p ${efi2} -i $idx $dev + make_esp /dev/${dev}p${idx} ${dst} } +boot_nogeli_gpt_ufs_legacy() { + dev=$1 + dst=$2 + + idx=$(find-part $dev "freebsd-boot") + if [ -z "$idx" ] ; then + die "No freebsd-boot partition found" + fi + doit gpart bootcode -b ${gpt0} -p ${gpt2} -i $idx $dev +} + +boot_nogeli_gpt_ufs_uefi() { + make_esp_gpt $1 $2 +} + boot_nogeli_gpt_ufs_both() { boot_nogeli_gpt_ufs_legacy $1 $2 $3 boot_nogeli_gpt_ufs_uefi $1 $2 $3 @@ -66,14 +96,7 @@ boot_nogeli_gpt_zfs_legacy() { } boot_nogeli_gpt_zfs_uefi() { - dev=$1 - dst=$2 - - idx=$(find-part $dev "efi") - if [ -z "$idx" ] ; then - die "No ESP partition found" - fi - doit gpart bootcode -p ${efi2} -i $idx $dev + make_esp_gpt $1 $2 } boot_nogeli_gpt_zfs_both() { @@ -94,14 +117,7 @@ boot_nogeli_mbr_ufs_legacy() { } boot_nogeli_mbr_ufs_uefi() { - dev=$1 - dst=$2 - - s=$(find-part ${dev} "!239") - if [ -z "$s" ] ; then - die "No ESP slice found" - fi - doit gpart bootcode -p ${efi2} -i ${s} ${dev} + make_esp_mbr $1 $2 } boot_nogeli_mbr_ufs_both() { @@ -133,14 +149,7 @@ boot_nogeli_mbr_zfs_legacy() { } boot_nogeli_mbr_zfs_uefi() { - dev=$1 - dst=$2 - - s=$(find-part $dev "!239") - if [ -z "$s" ] ; then - die "No ESP slice found" - fi - doit gpart bootcode -p ${efi2} -i ${s} ${dev} + make_eps_mbr $1 $2 } boot_nogeli_mbr_zfs_both() { @@ -245,11 +254,6 @@ dev=$1 gpt0=${DESTDIR}/boot/pmbr gpt2=${DESTDIR}/boot/gptboot gptzfs2=${DESTDIR}/boot/gptzfsboot - -# For gpt + EFI we install the ESP -# XXX This should use newfs or makefs, but it doesn't yet -efi1=${DESTDIR}/boot/boot1.efi -efi2=${DESTDIR}/boot/boot1.efifat # For MBR, we have lots of choices, but select mbr, boot0 has issues with UEFI mbr0=${DESTDIR}/boot/mbr