make-memstick.sh revision 293188
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: head/release/arm64/make-memstick.sh 293188 2016-01-05 03:20:45Z gjb $ 11264935Sgjb# 12264935Sgjb 13264935SgjbPATH=/bin:/usr/bin:/sbin:/usr/sbin 14264935Sgjbexport PATH 15264935Sgjb 16264935Sgjbif [ $# -ne 2 ]; then 17264935Sgjb echo "make-memstick.sh /path/to/directory /path/to/image/file" 18264935Sgjb exit 1 19264935Sgjbfi 20264935Sgjb 21264935Sgjbif [ ! -d ${1} ]; then 22264935Sgjb echo "${1} must be a directory" 23264935Sgjb exit 1 24264935Sgjbfi 25264935Sgjb 26264935Sgjbif [ -e ${2} ]; then 27264935Sgjb echo "won't overwrite ${2}" 28264935Sgjb exit 1 29264935Sgjbfi 30264935Sgjb 31264992Snwhitehornecho '/dev/ufs/FreeBSD_Install / ufs ro,noatime 1 1' > ${1}/etc/fstab 32293188Sgjbecho 'root_rw_mount="NO"' > ${1}/etc/rc.conf.local 33264992Snwhitehornmakefs -B little -o label=FreeBSD_Install ${2}.part ${1} 34264992Snwhitehornif [ $? -ne 0 ]; then 35264992Snwhitehorn echo "makefs failed" 36264992Snwhitehorn exit 1 37264992Snwhitehornfi 38264992Snwhitehornrm ${1}/etc/fstab 39293188Sgjbrm ${1}/etc/rc.conf.local 40264935Sgjb 41282107Sgjbmkimg -s mbr -p efi:=${1}/boot/boot1.efifat -p freebsd:=${2}.part -o ${2} 42264992Snwhitehornrm ${2}.part 43264935Sgjb 44