]> CyberLeo.Net >> Repos - FreeBSD/releng/10.2.git/blob - release/i386/make-memstick.sh
- Copy stable/10@285827 to releng/10.2 in preparation for 10.2-RC1
[FreeBSD/releng/10.2.git] / release / i386 / make-memstick.sh
1 #!/bin/sh
2 #
3 # This script generates a "memstick image" (image that can be copied to a
4 # USB memory stick) from a directory tree.  Note that the script does not
5 # clean up after itself very well for error conditions on purpose so the
6 # problem can be diagnosed (full filesystem most likely but ...).
7 #
8 # Usage: make-memstick.sh <directory tree> <image filename>
9 #
10 # $FreeBSD$
11 #
12
13 PATH=/bin:/usr/bin:/sbin:/usr/sbin
14 export PATH
15
16 if [ $# -ne 2 ]; then
17         echo "make-memstick.sh /path/to/directory /path/to/image/file"
18         exit 1
19 fi
20
21 if [ ! -d ${1} ]; then
22         echo "${1} must be a directory"
23         exit 1
24 fi
25
26 if [ -e ${2} ]; then
27         echo "won't overwrite ${2}"
28         exit 1
29 fi
30
31 echo '/dev/ufs/FreeBSD_Install / ufs ro,noatime 1 1' > ${1}/etc/fstab
32 makefs -B little -o label=FreeBSD_Install ${2}.part ${1}
33 if [ $? -ne 0 ]; then
34         echo "makefs failed"
35         exit 1
36 fi
37 rm ${1}/etc/fstab
38
39 mkimg -s gpt -b ${1}/boot/pmbr -p freebsd-boot:=${1}/boot/gptboot -p freebsd-ufs:=${2}.part -p freebsd-swap::1M -o ${2}
40 rm ${2}.part
41