1#!/bin/sh 2# 3# This script generates a "memstick image" (image that can be copied to a 4# USB memory stick) from a directory tree. Note that the script does not 5# clean up after itself very well for error conditions on purpose so the 6# problem can be diagnosed (full filesystem most likely but ...). 7# 8# Usage: make-memstick.sh <directory tree> <image filename> 9# 10# $FreeBSD$ 11# 12 13set -e 14 15PATH=/bin:/usr/bin:/sbin:/usr/sbin 16export PATH 17 18BLOCKSIZE=10240 19 20if [ $# -ne 2 ]; then 21 echo "make-memstick.sh /path/to/directory /path/to/image/file" 22 exit 1 23fi 24 25tempfile="${2}.$$" 26 27if [ ! -d ${1} ]; then 28 echo "${1} must be a directory" 29 exit 1 30fi 31 32if [ -e ${2} ]; then 33 echo "won't overwrite ${2}" 34 exit 1 35fi 36 37echo '/dev/da0s3 / ufs ro,noatime 1 1' > ${1}/etc/fstab 38echo 'root_rw_mount="NO"' > ${1}/etc/rc.conf.local 39rm -f ${tempfile} 40makefs -B big -o version=2 ${tempfile} ${1} 41rm ${1}/etc/fstab 42rm ${1}/etc/rc.conf.local 43 44mkimg -s apm \ 45 -p freebsd-boot:=${1}/boot/boot1.hfs \ 46 -p freebsd-ufs/FreeBSD_Install:=${tempfile} \ 47 -o ${2} 48 49rm -f ${tempfile} 50 51