make-memstick.sh revision 264922
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 6264922Sgjb# problem can be diagnosed (full filesystem most likely but ...). 7204044Skensmith# 8204044Skensmith# Usage: make-memstick.sh <directory tree> <image filename> 9204044Skensmith# 10204044Skensmith# $FreeBSD: head/release/i386/make-memstick.sh 264922 2014-04-25 18:46:54Z gjb $ 11204044Skensmith# 12204044Skensmith 13204044SkensmithPATH=/bin:/usr/bin:/sbin:/usr/sbin 14204044Skensmithexport PATH 15204044Skensmith 16204044Skensmithif [ $# -ne 2 ]; then 17264922Sgjb echo "make-memstick.sh /path/to/directory /path/to/image/file" 18264922Sgjb exit 1 19204044Skensmithfi 20204044Skensmith 21204044Skensmithif [ ! -d ${1} ]; then 22264922Sgjb echo "${1} must be a directory" 23264922Sgjb exit 1 24204044Skensmithfi 25204044Skensmith 26204044Skensmithif [ -e ${2} ]; then 27264922Sgjb echo "won't overwrite ${2}" 28264922Sgjb exit 1 29204044Skensmithfi 30204044Skensmith 31264922Sgjbecho '/dev/ufs/FreeBSD_Install / ufs ro,noatime 1 1' > ${1}/etc/fstab 32264922Sgjbmakefs -B little -o label=FreeBSD_Install ${2} ${1} 33204044Skensmithif [ $? -ne 0 ]; then 34264922Sgjb echo "makefs failed" 35264922Sgjb exit 1 36204044Skensmithfi 37219856Snwhitehornrm ${1}/etc/fstab 38204044Skensmith 39204044Skensmithunit=`mdconfig -a -t vnode -f ${2}` 40204044Skensmithif [ $? -ne 0 ]; then 41264922Sgjb echo "mdconfig failed" 42264922Sgjb exit 1 43204044Skensmithfi 44264922Sgjbgpart create -s BSD ${unit} 45264922Sgjbgpart bootcode -b ${1}/boot/boot ${unit} 46264922Sgjbgpart add -t freebsd-ufs ${unit} 47204044Skensmithmdconfig -d -u ${unit} 48204044Skensmith 49