1204044Skensmith#!/bin/sh 2204044Skensmith# 3204044Skensmith# This script generates a "memstick image" (image that can be copied to a 4204044Skensmith# USB memory stick) from a directory tree. Note that the script does not 5204044Skensmith# clean up after itself very well for error conditions on purpose so the 6204044Skensmith# problem can be diagnosed (full filesystem most likely but ...). 7204044Skensmith# 8204044Skensmith# Usage: make-memstick.sh <directory tree> <image filename> 9204044Skensmith# 10204044Skensmith# $FreeBSD$ 11204044Skensmith# 12204044Skensmith 13204044SkensmithPATH=/bin:/usr/bin:/sbin:/usr/sbin 14204044Skensmithexport PATH 15204044Skensmith 16204044Skensmithif [ $# -ne 2 ]; then 17265296Sgjb echo "make-memstick.sh /path/to/directory /path/to/image/file" 18265296Sgjb exit 1 19204044Skensmithfi 20204044Skensmith 21204044Skensmithif [ ! -d ${1} ]; then 22265296Sgjb echo "${1} must be a directory" 23265296Sgjb exit 1 24204044Skensmithfi 25204044Skensmith 26204044Skensmithif [ -e ${2} ]; then 27265296Sgjb echo "won't overwrite ${2}" 28265296Sgjb exit 1 29204044Skensmithfi 30204044Skensmith 31226170Snwhitehornecho '/dev/ufs/FreeBSD_Install / ufs ro,noatime 1 1' > ${1}/etc/fstab 32293723Sgjbecho 'root_rw_mount="NO"' > ${1}/etc/rc.conf.local 33226170Snwhitehornmakefs -B little -o label=FreeBSD_Install ${2} ${1} 34204044Skensmithif [ $? -ne 0 ]; then 35265296Sgjb echo "makefs failed" 36265296Sgjb exit 1 37204044Skensmithfi 38219856Snwhitehornrm ${1}/etc/fstab 39293723Sgjbrm ${1}/etc/rc.conf.local 40204044Skensmith 41265296Sgjbunit=$(mdconfig -a -t vnode -f ${2}) 42204044Skensmithif [ $? -ne 0 ]; then 43265296Sgjb echo "mdconfig failed" 44265296Sgjb exit 1 45204044Skensmithfi 46226170Snwhitehorngpart create -s BSD ${unit} 47226170Snwhitehorngpart bootcode -b ${1}/boot/boot ${unit} 48226170Snwhitehorngpart add -t freebsd-ufs ${unit} 49204044Skensmithmdconfig -d -u ${unit} 50204044Skensmith 51