diff options
author | mr <mr@FreeBSD.org> | 2011-03-20 12:40:17 +0000 |
---|---|---|
committer | mr <mr@FreeBSD.org> | 2011-03-20 12:40:17 +0000 |
commit | 44066768550a660729a4a0eb48c30ddd6246069e (patch) | |
tree | c34bf26b69ebd7b6dd24480e119c94be3b0e3ef5 | |
parent | 133a80d1fdc3990a561d900255623bed91a7b880 (diff) | |
download | FreeBSD-src-44066768550a660729a4a0eb48c30ddd6246069e.zip FreeBSD-src-44066768550a660729a4a0eb48c30ddd6246069e.tar.gz |
- Add script for preparing disks in GPT/ZFS boot environment
- Add merge script for integrating amd64 slice into i386 disk image
-rwxr-xr-x | tools/tools/nanobsd/rescue/Files/root/GPT4ZFS_Create.sh | 53 | ||||
-rwxr-xr-x | tools/tools/nanobsd/rescue/merge.sh | 11 |
2 files changed, 64 insertions, 0 deletions
diff --git a/tools/tools/nanobsd/rescue/Files/root/GPT4ZFS_Create.sh b/tools/tools/nanobsd/rescue/Files/root/GPT4ZFS_Create.sh new file mode 100755 index 0000000..f8a4ef7 --- /dev/null +++ b/tools/tools/nanobsd/rescue/Files/root/GPT4ZFS_Create.sh @@ -0,0 +1,53 @@ +#!/bin/sh +# $FreeBSD$ + +# some default sizes +align=2048 +swapsize=$(expr 1 \* 1024 \* 2048 + 1024) +zfssize=0 + +# define our bail out shortcut +exerr () { echo -e "$*" >&2 ; exit 1; } + +usage="Usage: $0 <dsk> [ -s <swap size> ] [ -z <zfs size> ]\n\ + \tswap size: if no -s size in blocks is given, default is $swapsize blocks\n\ + \tzfs size: if no -z size in blocks is given, default is the rest of the disk" + +dsk=$1 +if [ -z "$dsk" -o \! -c "/dev/$dsk" ]; then + exerr ${usage}; + exit; +fi + +shift; while getopts :s:z: arg; do case ${arg} in + s) swapsize=${OPTARG};; + z) zfssize=${OPTARG};; + #?) exerr ${usage};; +esac; done; shift $(( ${OPTIND} - 1 )) + +gpart delete -i 3 $dsk +gpart delete -i 2 $dsk +gpart delete -i 1 $dsk +gpart destroy $dsk +gpart create -s gpt $dsk + +# Boot +siz=$(expr 1024 \- 34) +gpart add -i 1 -b 34 -s $siz -t freebsd-boot $dsk +gpart bootcode -b /boot/pmbr -p /boot/gptzfsboot -i 1 $dsk + +# Swap +off=$align +siz=$swapsize +gpart add -i 2 -b $off -s $siz -t freebsd-swap $dsk + +# ZFS +off=$(expr $align + $swapsize) +if [ "$zfssize" -gt 0 ]; then + siz="-s $zfssize" +else + siz="" +fi +gpart add -i 3 -b $off $siz -t freebsd-zfs $dsk + +gpart show $dsk diff --git a/tools/tools/nanobsd/rescue/merge.sh b/tools/tools/nanobsd/rescue/merge.sh new file mode 100755 index 0000000..c4f7c79 --- /dev/null +++ b/tools/tools/nanobsd/rescue/merge.sh @@ -0,0 +1,11 @@ +#!/bin/sh +# $FreeBSD$ + +D1="/usr/obj/nanobsd.rescue_i386" +D2="/usr/obj/nanobsd.rescue_amd64" + +MD=`mdconfig -a -t vnode -f ${D1}/_.disk.full` + +dd if=${D2}/_.disk.image of=/dev/${MD}s2 bs=128k + +mdconfig -d -u ${MD} |