make-memstick.sh revision 264992
1264935Sgjb#!/bin/sh
2264935Sgjb#
3264992Snwhitehorn# This script generates a "memstick image" (image that can be copied to a
4264992Snwhitehorn# USB memory stick) from a directory tree.  Note that the script does not
5264992Snwhitehorn# clean up after itself very well for error conditions on purpose so the
6264992Snwhitehorn# problem can be diagnosed (full filesystem most likely but ...).
7264935Sgjb#
8264935Sgjb# Usage: make-memstick.sh <directory tree> <image filename>
9264935Sgjb#
10264935Sgjb# $FreeBSD: head/release/amd64/make-uefi-memstick.sh 264992 2014-04-27 00:40:18Z nwhitehorn $
11264935Sgjb#
12264935Sgjb
13264935SgjbPATH=/bin:/usr/bin:/sbin:/usr/sbin
14264935Sgjbexport PATH
15264935Sgjb
16264935Sgjbif [ $# -ne 2 ]; then
17264935Sgjb	echo "make-memstick.sh /path/to/directory /path/to/image/file"
18264935Sgjb	exit 1
19264935Sgjbfi
20264935Sgjb
21264935Sgjbif [ ! -d ${1} ]; then
22264935Sgjb	echo "${1} must be a directory"
23264935Sgjb	exit 1
24264935Sgjbfi
25264935Sgjb
26264935Sgjbif [ -e ${2} ]; then
27264935Sgjb	echo "won't overwrite ${2}"
28264935Sgjb	exit 1
29264935Sgjbfi
30264935Sgjb
31264992Snwhitehornecho '/dev/ufs/FreeBSD_Install / ufs ro,noatime 1 1' > ${1}/etc/fstab
32264992Snwhitehornmakefs -B little -o label=FreeBSD_Install ${2}.part ${1}
33264992Snwhitehornif [ $? -ne 0 ]; then
34264992Snwhitehorn	echo "makefs failed"
35264992Snwhitehorn	exit 1
36264992Snwhitehornfi
37264992Snwhitehornrm ${1}/etc/fstab
38264935Sgjb
39264992Snwhitehornmkimg -s gpt -b ${1}/boot/pmbr -p freebsd-boot:=${1}/boot/gptboot -p efi:=${1}/boot/boot1.efifat -p freebsd-ufs:=${2}.part -o ${2}
40264992Snwhitehornrm ${2}.part
41264935Sgjb
42