1264935Sgjb#!/bin/sh 2264935Sgjb# 3264992Snwhitehorn# This script generates a "memstick image" (image that can be copied to a 4264992Snwhitehorn# USB memory stick) from a directory tree. Note that the script does not 5264992Snwhitehorn# clean up after itself very well for error conditions on purpose so the 6264992Snwhitehorn# problem can be diagnosed (full filesystem most likely but ...). 7264935Sgjb# 8264935Sgjb# Usage: make-memstick.sh <directory tree> <image filename> 9264935Sgjb# 10264935Sgjb# $FreeBSD: stable/11/release/amd64/make-memstick.sh 334444 2018-05-31 20:01:58Z gjb $ 11264935Sgjb# 12264935Sgjb 13323476Semasteset -e 14323476Semaste 15264935SgjbPATH=/bin:/usr/bin:/sbin:/usr/sbin 16264935Sgjbexport PATH 17264935Sgjb 18264935Sgjbif [ $# -ne 2 ]; then 19264935Sgjb echo "make-memstick.sh /path/to/directory /path/to/image/file" 20264935Sgjb exit 1 21264935Sgjbfi 22264935Sgjb 23264935Sgjbif [ ! -d ${1} ]; then 24264935Sgjb echo "${1} must be a directory" 25264935Sgjb exit 1 26264935Sgjbfi 27264935Sgjb 28264935Sgjbif [ -e ${2} ]; then 29264935Sgjb echo "won't overwrite ${2}" 30264935Sgjb exit 1 31264935Sgjbfi 32264935Sgjb 33264992Snwhitehornecho '/dev/ufs/FreeBSD_Install / ufs ro,noatime 1 1' > ${1}/etc/fstab 34293188Sgjbecho 'root_rw_mount="NO"' > ${1}/etc/rc.conf.local 35324395Semastemakefs -B little -o label=FreeBSD_Install -o version=2 ${2}.part ${1} 36264992Snwhitehornrm ${1}/etc/fstab 37293188Sgjbrm ${1}/etc/rc.conf.local 38264935Sgjb 39334444Sgjbmkimg -s mbr \ 40334444Sgjb -b ${1}/boot/mbr \ 41332639Semaste -p efi:=${1}/boot/boot1.efifat \ 42334444Sgjb -p freebsd:-"mkimg -s bsd -b ${1}/boot/boot -p freebsd-ufs:=${2}.part" \ 43334444Sgjb -a 2 \ 44332639Semaste -o ${2} 45264992Snwhitehornrm ${2}.part 46264935Sgjb 47