make-memstick.sh revision 324395
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: stable/11/release/i386/make-memstick.sh 324395 2017-10-07 20:14:30Z emaste $ 11204044Skensmith# 12204044Skensmith 13323476Semasteset -e 14323476Semaste 15204044SkensmithPATH=/bin:/usr/bin:/sbin:/usr/sbin 16204044Skensmithexport PATH 17204044Skensmith 18204044Skensmithif [ $# -ne 2 ]; then 19264933Sgjb echo "make-memstick.sh /path/to/directory /path/to/image/file" 20264933Sgjb exit 1 21204044Skensmithfi 22204044Skensmith 23204044Skensmithif [ ! -d ${1} ]; then 24264933Sgjb echo "${1} must be a directory" 25264933Sgjb exit 1 26204044Skensmithfi 27204044Skensmith 28204044Skensmithif [ -e ${2} ]; then 29264933Sgjb echo "won't overwrite ${2}" 30264933Sgjb exit 1 31204044Skensmithfi 32204044Skensmith 33264922Sgjbecho '/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} 36219856Snwhitehornrm ${1}/etc/fstab 37293188Sgjbrm ${1}/etc/rc.conf.local 38204044Skensmith 39283307Sgjbmkimg -s gpt -b ${1}/boot/pmbr -p freebsd-boot:=${1}/boot/gptboot -p freebsd-ufs:=${2}.part -p freebsd-swap::1M -o ${2} 40283307Sgjbrm ${2}.part 41204044Skensmith 42