From owner-svn-src-all@FreeBSD.ORG Fri Apr 25 21:11:00 2014 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id C07105DE; Fri, 25 Apr 2014 21:11:00 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 9464417E8; Fri, 25 Apr 2014 21:11:00 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.8/8.14.8) with ESMTP id s3PLB0c5043707; Fri, 25 Apr 2014 21:11:00 GMT (envelope-from gjb@svn.freebsd.org) Received: (from gjb@localhost) by svn.freebsd.org (8.14.8/8.14.8/Submit) id s3PLB00Q043705; Fri, 25 Apr 2014 21:11:00 GMT (envelope-from gjb@svn.freebsd.org) Message-Id: <201404252111.s3PLB00Q043705@svn.freebsd.org> From: Glen Barber Date: Fri, 25 Apr 2014 21:11:00 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r264935 - head/release/amd64 X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 25 Apr 2014 21:11:00 -0000 Author: gjb Date: Fri Apr 25 21:11:00 2014 New Revision: 264935 URL: http://svnweb.freebsd.org/changeset/base/264935 Log: Add a separate script to build the memstick.img and the mini-memstick.img with UEFI support. As the comments in the file suggest, 1) there must be existing ${.OBJDIR}/usr/src/release/{release,bootonly}; 2) TARGET/TARGET_ARCH must be amd64; and 3) it must be a vt(4)-enabled kernel with vt_efifb (*not* vt_vga). This script is not hooked into release/Makefile in any way until further testing is complete. Sponsored by: The FreeBSD Foundation Added: head/release/amd64/make-uefi-memstick.sh (contents, props changed) Added: head/release/amd64/make-uefi-memstick.sh ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/release/amd64/make-uefi-memstick.sh Fri Apr 25 21:11:00 2014 (r264935) @@ -0,0 +1,73 @@ +#!/bin/sh +# +# This script generates a "memstick image" for UEFI-capable systems. +# +# Prerequisites: +# - 'make release' +# - KERNCONF *must* be VT (or vt_efifb(4) compiled into the kernel) +# +# Note: This only works for amd64, because i386 lacks the EFI boot bits. +# +# Usage: make-memstick.sh +# +# $FreeBSD$ +# + +PATH=/bin:/usr/bin:/sbin:/usr/sbin +export PATH + +if [ $# -ne 2 ]; then + echo "make-memstick.sh /path/to/directory /path/to/image/file" + exit 1 +fi + +if [ ! -d ${1} ]; then + echo "${1} must be a directory" + exit 1 +fi + +if [ -e ${2} ]; then + echo "won't overwrite ${2}" + exit 1 +fi + +dirsize=$(du -shLm ${1} | awk '{print $1}') +dirsize=$(( $(( $(( ${dirsize} + 256 )) * 1024 * 1024 )) )) +truncate -s ${dirsize} ${2} + +unit=$(mdconfig -a -t vnode -f ${2}) +gpart create -s mbr /dev/${unit} +gpart add -t '!0xEF' -s 32M /dev/${unit} +gpart add -t freebsd /dev/${unit} +gpart set -a active -i 2 /dev/${unit} +gpart bootcode -b ${1}/boot/boot0 /dev/${unit} +gpart create -s bsd -n 20 /dev/${unit}s2 +gpart add -t freebsd-ufs /dev/${unit}s2 +gpart bootcode -b ${1}/boot/boot /dev/${unit}s2 +newfs_msdos /dev/${unit}s1 +newfs -L rootfs /dev/${unit}s2a +mkdir -p ${1}/mnt +mount -t msdosfs /dev/${unit}s1 ${1}/mnt +mkdir -p ${1}/mnt/efi/boot +cp -p ${1}/boot/boot1.efi ${1}/mnt/efi/boot/BOOTx64.efi + +while ! umount ${1}/mnt; do + sleep 1 +done + +mkdir -p mnt +mount /dev/${unit}s2a mnt +tar -cf - -C ${1} . | tar -xf - -C mnt +echo "/dev/ufs/rootfs / ufs ro,noatime 1 1" > mnt/etc/fstab + +while ! umount mnt; do + sleep 1 +done + +# Default boot selection to MBR so systems that do not support UEFI +# do not fail to boot without human interaction. +boot0cfg -s 2 /dev/${unit} + +mdconfig -d -u ${unit} +rmdir mnt +