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 ...).
8 # Usage: make-memstick.sh <directory tree or manifest> <image filename>
15 if [ "$(uname -s)" = "FreeBSD" ]; then
16 PATH=/bin:/usr/bin:/sbin:/usr/sbin
21 echo "make-memstick.sh /path/to/directory/or/manifest /path/to/image/file"
27 if [ -f ${MAKEFSARG} ]; then
28 BASEBITSDIR=`dirname ${MAKEFSARG}`
30 elif [ -d ${MAKEFSARG} ]; then
31 BASEBITSDIR=${MAKEFSARG}
34 echo "${MAKEFSARG} must exist"
39 echo "won't overwrite ${2}"
43 echo '/dev/ufs/FreeBSD_Install / ufs ro,noatime 1 1' > ${BASEBITSDIR}/etc/fstab
44 echo 'root_rw_mount="NO"' > ${BASEBITSDIR}/etc/rc.conf.local
45 if [ -n "${METALOG}" ]; then
46 metalogfilename=$(mktemp /tmp/metalog.XXXXXX)
47 cat ${METALOG} > ${metalogfilename}
48 echo "./etc/fstab type=file uname=root gname=wheel mode=0644" >> ${metalogfilename}
49 echo "./etc/rc.conf.local type=file uname=root gname=wheel mode=0644" >> ${metalogfilename}
50 MAKEFSARG=${metalogfilename}
52 makefs -D -N ${BASEBITSDIR}/etc -B little -o label=FreeBSD_Install -o version=2 ${2}.part ${MAKEFSARG}
53 rm ${BASEBITSDIR}/etc/fstab
54 rm ${BASEBITSDIR}/etc/rc.conf.local
55 if [ -n "${METALOG}" ]; then
60 -b ${BASEBITSDIR}/boot/mbr \
61 -p freebsd:-"mkimg -s bsd -b ${BASEBITSDIR}/boot/boot -p freebsd-ufs:=${2}.part" \