1264935Sgjb#!/bin/sh 2264935Sgjb# 3271318Semaste# This script generates a "memstick image" (image that can be copied to a 4271318Semaste# USB memory stick) from a directory tree. Note that the script does not 5271318Semaste# clean up after itself very well for error conditions on purpose so the 6271318Semaste# problem can be diagnosed (full filesystem most likely but ...). 7264935Sgjb# 8264935Sgjb# Usage: make-memstick.sh <directory tree> <image filename> 9264935Sgjb# 10264935Sgjb# $FreeBSD$ 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 31271318Semasteecho '/dev/ufs/FreeBSD_Install / ufs ro,noatime 1 1' > ${1}/etc/fstab 32271318Semastemakefs -B little -o label=FreeBSD_Install ${2}.part ${1} 33271318Semasteif [ $? -ne 0 ]; then 34271318Semaste echo "makefs failed" 35271318Semaste exit 1 36271318Semastefi 37271318Semasterm ${1}/etc/fstab 38264935Sgjb 39271318Semastemkimg -s gpt -b ${1}/boot/pmbr -p efi:=${1}/boot/boot1.efifat -p freebsd-boot:=${1}/boot/gptboot -p freebsd-ufs:=${2}.part -p freebsd-swap::1M -o ${2} 40271318Semasterm ${2}.part 41264935Sgjb 42