1082c6764SWarner Losh#!/bin/sh 2082c6764SWarner Losh 37b4b55e5SIan Leporepassphrase=passphrase 47b4b55e5SIan Leporeiterations=50000 5595deaf7SIan Lepore 6db8b5613SRebecca Cran# The smallest FAT32 filesystem is 33292 KB 7db8b5613SRebecca Cranespsize=33292 8d050cd6bSWarner Losh 9082c6764SWarner Losh# 10082c6764SWarner Losh# Builds all the bat-shit crazy combinations we support booting from, 11082c6764SWarner Losh# at least for amd64. It assume you have a ~sane kernel in /boot/kernel 12082c6764SWarner Losh# and copies that into the ~150MB root images we create (we create the du 1326a241a0SWarner Losh# size of the kernel + 20MB). 14082c6764SWarner Losh# 15159b158aSWarner Losh# Sad panda sez: this runs as root, but could be any user if someone 16159b158aSWarner Losh# creates userland geli. 17082c6764SWarner Losh# 18db8b5613SRebecca Cran# This assumes an external program install-boot.sh which will install 19082c6764SWarner Losh# the appropriate boot files in the appropriate locations. 20082c6764SWarner Losh# 21db8b5613SRebecca Cran# Assumes you've already rebuilt... maybe bad? Also maybe bad: the env 22082c6764SWarner Losh# vars should likely be conditionally set to allow better automation. 23082c6764SWarner Losh# 24082c6764SWarner Losh 250661cd79SRebecca Cran. $(dirname $0)/install-boot.sh 260661cd79SRebecca Cran 27082c6764SWarner Loshcpsys() { 28082c6764SWarner Losh src=$1 29082c6764SWarner Losh dst=$2 30082c6764SWarner Losh 31082c6764SWarner Losh # Copy kernel + boot loader 32082c6764SWarner Losh (cd $src ; tar cf - .) | (cd $dst; tar xf -) 33082c6764SWarner Losh} 34082c6764SWarner Losh 35729c458bSWarner Loshufs_fstab() { 363d3f2fb0SWarner Losh dir=$1 37082c6764SWarner Losh 383d3f2fb0SWarner Losh cat > ${dir}/etc/fstab <<EOF 39159b158aSWarner Losh/dev/ufs/root / ufs rw 1 1 4022cf6021SWarner LoshEOF 41729c458bSWarner Losh} 42729c458bSWarner Losh 43729c458bSWarner Loshmk_nogeli_gpt_ufs_legacy() { 44729c458bSWarner Losh src=$1 45729c458bSWarner Losh img=$2 46729c458bSWarner Losh 47729c458bSWarner Losh ufs_fstab ${src} 48159b158aSWarner Losh makefs -t ffs -B little -s 200m -o label=root ${img}.p2 ${src} 49082c6764SWarner Losh mkimg -s gpt -b ${src}/boot/pmbr \ 50082c6764SWarner Losh -p freebsd-boot:=${src}/boot/gptboot \ 51082c6764SWarner Losh -p freebsd-ufs:=${img}.p2 -o ${img} 5222cf6021SWarner Losh rm -f ${src}/etc/fstab 53082c6764SWarner Losh} 54082c6764SWarner Losh 55082c6764SWarner Loshmk_nogeli_gpt_ufs_uefi() { 56082c6764SWarner Losh src=$1 57082c6764SWarner Losh img=$2 58082c6764SWarner Losh 59729c458bSWarner Losh ufs_fstab ${src} 600661cd79SRebecca Cran make_esp_file ${img}.p1 ${espsize} ${src}/boot/loader.efi 61159b158aSWarner Losh makefs -t ffs -B little -s 200m -o label=root ${img}.p2 ${src} 62f438a143SAllan Jude mkimg -s gpt \ 6322cf6021SWarner Losh -p efi:=${img}.p1 \ 64082c6764SWarner Losh -p freebsd-ufs:=${img}.p2 -o ${img} 6522cf6021SWarner Losh rm -f ${src}/etc/fstab 66082c6764SWarner Losh} 67082c6764SWarner Losh 68082c6764SWarner Loshmk_nogeli_gpt_ufs_both() { 69082c6764SWarner Losh src=$1 70082c6764SWarner Losh img=$2 71082c6764SWarner Losh 72729c458bSWarner Losh ufs_fstab ${src} 730661cd79SRebecca Cran make_esp_file ${img}.p1 ${espsize} ${src}/boot/loader.efi 74159b158aSWarner Losh makefs -t ffs -B little -s 200m -o label=root ${img}.p3 ${src} 75082c6764SWarner Losh # p1 is boot for uefi, p2 is boot for gpt, p3 is / 76082c6764SWarner Losh mkimg -b ${src}/boot/pmbr -s gpt \ 77d050cd6bSWarner Losh -p efi:=${img}.p1 \ 78082c6764SWarner Losh -p freebsd-boot:=${src}/boot/gptboot \ 79082c6764SWarner Losh -p freebsd-ufs:=${img}.p3 \ 80082c6764SWarner Losh -o ${img} 8122cf6021SWarner Losh rm -f ${src}/etc/fstab 82082c6764SWarner Losh} 83082c6764SWarner Losh 843d3f2fb0SWarner Losh# XXX should not assume host == target 853d3f2fb0SWarner Loshzfs_extra() 863d3f2fb0SWarner Losh{ 873d3f2fb0SWarner Losh src=$1 883d3f2fb0SWarner Losh dst=$2 893d3f2fb0SWarner Losh 903d3f2fb0SWarner Losh mkdir -p $dst 913d3f2fb0SWarner Losh mkdir -p $dst/boot/kernel 923d3f2fb0SWarner Losh cat > ${dst}/boot/loader.conf.local <<EOF 933d3f2fb0SWarner Loshcryptodev_load=YES 943d3f2fb0SWarner Loshzfs_load=YES 953d3f2fb0SWarner LoshEOF 963d3f2fb0SWarner Losh cp /boot/kernel/acl_nfs4.ko ${dst}/boot/kernel/acl_nfs4.ko 973d3f2fb0SWarner Losh cp /boot/kernel/cryptodev.ko ${dst}/boot/kernel/cryptodev.ko 983d3f2fb0SWarner Losh cp /boot/kernel/zfs.ko ${dst}/boot/kernel/zfs.ko 993d3f2fb0SWarner Losh} 1003d3f2fb0SWarner Losh 101082c6764SWarner Loshmk_nogeli_gpt_zfs_legacy() { 102082c6764SWarner Losh src=$1 103082c6764SWarner Losh img=$2 104082c6764SWarner Losh mntpt=$3 105082c6764SWarner Losh geli=$4 106082c6764SWarner Losh scheme=$5 107082c6764SWarner Losh fs=$6 108082c6764SWarner Losh bios=$7 109082c6764SWarner Losh pool=nogeli-gpt-zfs-legacy 1103d3f2fb0SWarner Losh dst=$img.extra 111082c6764SWarner Losh 1123d3f2fb0SWarner Losh zfs_extra $src $dst 1133d3f2fb0SWarner Losh makefs -t zfs -s 200m \ 1143d3f2fb0SWarner Losh -o poolname=${pool} -o bootfs=${pool} -o rootpath=/ \ 1153d3f2fb0SWarner Losh ${img}.p2 ${src} ${dst} 1163d3f2fb0SWarner Losh mkimg -b ${src}/boot/pmbr -s gpt \ 1173d3f2fb0SWarner Losh -p freebsd-boot:=/boot/gptzfsboot \ 1183d3f2fb0SWarner Losh -p freebsd-zfs:=${img}.p2 \ 1193d3f2fb0SWarner Losh -o ${img} 1203d3f2fb0SWarner Losh rm -rf ${dst} 121082c6764SWarner Losh} 122082c6764SWarner Losh 123082c6764SWarner Loshmk_nogeli_gpt_zfs_uefi() { 124712b4ca9SAllan Jude src=$1 125712b4ca9SAllan Jude img=$2 126712b4ca9SAllan Jude mntpt=$3 127712b4ca9SAllan Jude geli=$4 128712b4ca9SAllan Jude scheme=$5 129712b4ca9SAllan Jude fs=$6 130712b4ca9SAllan Jude bios=$7 131712b4ca9SAllan Jude pool=nogeli-gpt-zfs-uefi 1323d3f2fb0SWarner Losh dst=$img.extra 133712b4ca9SAllan Jude 1343d3f2fb0SWarner Losh zfs_extra $src $dst 1353d3f2fb0SWarner Losh make_esp_file ${img}.p1 ${espsize} ${src}/boot/loader.efi 1363d3f2fb0SWarner Losh makefs -t zfs -s 200m \ 1373d3f2fb0SWarner Losh -o poolname=${pool} -o bootfs=${pool} -o rootpath=/ \ 1383d3f2fb0SWarner Losh ${img}.p2 ${src} ${dst} 1393d3f2fb0SWarner Losh mkimg -b ${src}/boot/pmbr -s gpt \ 1403d3f2fb0SWarner Losh -p efi:=${img}.p1 \ 1413d3f2fb0SWarner Losh -p freebsd-zfs:=${img}.p2 \ 1423d3f2fb0SWarner Losh -o ${img} 1433d3f2fb0SWarner Losh rm -rf ${dst} 144082c6764SWarner Losh} 145082c6764SWarner Losh 146082c6764SWarner Loshmk_nogeli_gpt_zfs_both() { 147712b4ca9SAllan Jude src=$1 148712b4ca9SAllan Jude img=$2 149712b4ca9SAllan Jude mntpt=$3 150712b4ca9SAllan Jude geli=$4 151712b4ca9SAllan Jude scheme=$5 152712b4ca9SAllan Jude fs=$6 153712b4ca9SAllan Jude bios=$7 154712b4ca9SAllan Jude pool=nogeli-gpt-zfs-both 1553d3f2fb0SWarner Losh dst=$img.extra 156712b4ca9SAllan Jude 1573d3f2fb0SWarner Losh zfs_extra $src $dst 1583d3f2fb0SWarner Losh make_esp_file ${img}.p2 ${espsize} ${src}/boot/loader.efi 1593d3f2fb0SWarner Losh makefs -t zfs -s 200m \ 1603d3f2fb0SWarner Losh -o poolname=${pool} -o bootfs=${pool} -o rootpath=/ \ 1613d3f2fb0SWarner Losh ${img}.p3 ${src} ${dst} 1623d3f2fb0SWarner Losh mkimg -b ${src}/boot/pmbr -s gpt \ 1633d3f2fb0SWarner Losh -p freebsd-boot:=/boot/gptzfsboot \ 1643d3f2fb0SWarner Losh -p efi:=${img}.p2 \ 1653d3f2fb0SWarner Losh -p freebsd-zfs:=${img}.p3 \ 1663d3f2fb0SWarner Losh -o ${img} 1673d3f2fb0SWarner Losh rm -rf ${dst} 168082c6764SWarner Losh} 169082c6764SWarner Losh 170082c6764SWarner Loshmk_nogeli_mbr_ufs_legacy() { 17122cf6021SWarner Losh src=$1 17222cf6021SWarner Losh img=$2 17322cf6021SWarner Losh 174729c458bSWarner Losh ufs_fstab ${src} 175159b158aSWarner Losh makefs -t ffs -B little -s 200m -o label=root ${img}.s1a ${src} 17622cf6021SWarner Losh mkimg -s bsd -b ${src}/boot/boot -p freebsd-ufs:=${img}.s1a -o ${img}.s1 177f438a143SAllan Jude mkimg -a 1 -s mbr -b ${src}/boot/boot0sio -p freebsd:=${img}.s1 -o ${img} 17822cf6021SWarner Losh rm -f ${src}/etc/fstab 179082c6764SWarner Losh} 180082c6764SWarner Losh 181082c6764SWarner Loshmk_nogeli_mbr_ufs_uefi() { 182f438a143SAllan Jude src=$1 183f438a143SAllan Jude img=$2 184f438a143SAllan Jude 185729c458bSWarner Losh ufs_fstab ${src} 1860661cd79SRebecca Cran make_esp_file ${img}.s1 ${espsize} ${src}/boot/loader.efi 187159b158aSWarner Losh makefs -t ffs -B little -s 200m -o label=root ${img}.s2a ${src} 188f438a143SAllan Jude mkimg -s bsd -p freebsd-ufs:=${img}.s2a -o ${img}.s2 189f438a143SAllan Jude mkimg -a 1 -s mbr -p efi:=${img}.s1 -p freebsd:=${img}.s2 -o ${img} 190f438a143SAllan Jude rm -f ${src}/etc/fstab 191082c6764SWarner Losh} 192082c6764SWarner Losh 193082c6764SWarner Loshmk_nogeli_mbr_ufs_both() { 194f438a143SAllan Jude src=$1 195f438a143SAllan Jude img=$2 196f438a143SAllan Jude 197729c458bSWarner Losh ufs_fstab ${src} 1980661cd79SRebecca Cran make_esp_file ${img}.s1 ${espsize} ${src}/boot/loader.efi 199159b158aSWarner Losh makefs -t ffs -B little -s 200m -o label=root ${img}.s2a ${src} 200f438a143SAllan Jude mkimg -s bsd -b ${src}/boot/boot -p freebsd-ufs:=${img}.s2a -o ${img}.s2 201f438a143SAllan Jude mkimg -a 2 -s mbr -b ${src}/boot/mbr -p efi:=${img}.s1 -p freebsd:=${img}.s2 -o ${img} 202f438a143SAllan Jude rm -f ${src}/etc/fstab 203082c6764SWarner Losh} 204082c6764SWarner Losh 205082c6764SWarner Loshmk_nogeli_mbr_zfs_legacy() { 206f438a143SAllan Jude src=$1 207f438a143SAllan Jude img=$2 208f438a143SAllan Jude mntpt=$3 209f438a143SAllan Jude geli=$4 210f438a143SAllan Jude scheme=$5 211f438a143SAllan Jude fs=$6 212f438a143SAllan Jude bios=$7 213f438a143SAllan Jude pool=nogeli-mbr-zfs-legacy 214f438a143SAllan Jude 215*ef8b8723SWarner Losh zfs_extra $src $dst 216*ef8b8723SWarner Losh makefs -t zfs -s 200m \ 217*ef8b8723SWarner Losh -o poolname=${pool} -o bootfs=${pool} -o rootpath=/ \ 218*ef8b8723SWarner Losh ${img}.s1a ${src} ${dst} 219*ef8b8723SWarner Losh # The old boot1/boot2 boot split is also used by zfs. We need to extract zfsboot1 220*ef8b8723SWarner Losh # from this image. Since there's no room in the mbr format for the rest of the loader, 221*ef8b8723SWarner Losh # it will load the zfsboot loader from the reserved for bootloader area of the ZFS volume 222*ef8b8723SWarner Losh # being booted, hence the need to dd it into the raw img later. 223*ef8b8723SWarner Losh # Please note: zfsboot only works with partition 'a' which must be the root 224*ef8b8723SWarner Losh # partition / zfs volume 225*ef8b8723SWarner Losh dd if=${src}/boot/zfsboot of=${dst}/zfsboot1 count=1 226*ef8b8723SWarner Losh mkimg -s bsd -b ${dst}zfsboot1 -p freebsd-zfs:=${img}.s1a -o ${img}.s1 227*ef8b8723SWarner Losh dd if=${src}/boot/zfsboot of=${img}.s1a skip=1 seek=1024 228*ef8b8723SWarner Losh mkimg -a 1 -s mbr -b ${src}/boot/mbr -p freebsd:=${img}.s1 -o ${img} 229*ef8b8723SWarner Losh rm -rf ${dst} 230082c6764SWarner Losh} 231082c6764SWarner Losh 232082c6764SWarner Loshmk_nogeli_mbr_zfs_uefi() { 233f438a143SAllan Jude src=$1 234f438a143SAllan Jude img=$2 235f438a143SAllan Jude mntpt=$3 236f438a143SAllan Jude geli=$4 237f438a143SAllan Jude scheme=$5 238f438a143SAllan Jude fs=$6 239f438a143SAllan Jude bios=$7 240f438a143SAllan Jude pool=nogeli-mbr-zfs-uefi 241f438a143SAllan Jude 242*ef8b8723SWarner Losh zfs_extra $src $dst 243*ef8b8723SWarner Losh make_esp_file ${img}.s1 ${espsize} ${src}/boot/loader.efi 244*ef8b8723SWarner Losh makefs -t zfs -s 200m \ 245*ef8b8723SWarner Losh -o poolname=${pool} -o bootfs=${pool} -o rootpath=/ \ 246*ef8b8723SWarner Losh ${img}.s2a ${src} ${dst} 247*ef8b8723SWarner Losh mkimg -s bsd -b ${dst}zfsboot1 -p freebsd-zfs:=${img}.s2a -o ${img}.s2 248*ef8b8723SWarner Losh mkimg -a 1 -s mbr -b ${src}/boot/mbr -p efi:=${img}.s1 -p freebsd:=${img}.s2 -o ${img} 249*ef8b8723SWarner Losh rm -rf ${dst} 250082c6764SWarner Losh} 251082c6764SWarner Losh 252082c6764SWarner Loshmk_nogeli_mbr_zfs_both() { 253f438a143SAllan Jude src=$1 254f438a143SAllan Jude img=$2 255f438a143SAllan Jude mntpt=$3 256f438a143SAllan Jude geli=$4 257f438a143SAllan Jude scheme=$5 258f438a143SAllan Jude fs=$6 259f438a143SAllan Jude bios=$7 260f438a143SAllan Jude pool=nogeli-mbr-zfs-both 261f438a143SAllan Jude 262*ef8b8723SWarner Losh zfs_extra $src $dst 263*ef8b8723SWarner Losh make_esp_file ${img}.s1 ${espsize} ${src}/boot/loader.efi 264*ef8b8723SWarner Losh makefs -t zfs -s 200m \ 265*ef8b8723SWarner Losh -o poolname=${pool} -o bootfs=${pool} -o rootpath=/ \ 266*ef8b8723SWarner Losh ${img}.s2a ${src} ${dst} 267*ef8b8723SWarner Losh # The old boot1/boot2 boot split is also used by zfs. We need to extract zfsboot1 268*ef8b8723SWarner Losh # from this image. Since there's no room in the mbr format for the rest of the loader, 269*ef8b8723SWarner Losh # it will load the zfsboot loader from the reserved for bootloader area of the ZFS volume 270*ef8b8723SWarner Losh # being booted, hence the need to dd it into the raw img later. 271*ef8b8723SWarner Losh # Please note: zfsboot only works with partition 'a' which must be the root 272*ef8b8723SWarner Losh # partition / zfs volume 273*ef8b8723SWarner Losh dd if=${src}/boot/zfsboot of=${dst}/zfsboot1 count=1 274*ef8b8723SWarner Losh mkimg -s bsd -b ${dst}zfsboot1 -p freebsd-zfs:=${img}.s2a -o ${img}.s2 275*ef8b8723SWarner Losh dd if=${src}/boot/zfsboot of=${img}.s1a skip=1 seek=1024 276*ef8b8723SWarner Losh mkimg -a 1 -s mbr -b ${src}/boot/mbr -p efi:=${img}.s1 -p freebsd:=${img}.s2 -o ${img} 277082c6764SWarner Losh} 278082c6764SWarner Losh 279082c6764SWarner Loshmk_geli_gpt_ufs_legacy() { 280f438a143SAllan Jude src=$1 281f438a143SAllan Jude img=$2 282f438a143SAllan Jude mntpt=$3 283f438a143SAllan Jude geli=$4 284f438a143SAllan Jude scheme=$5 285f438a143SAllan Jude fs=$6 286f438a143SAllan Jude bios=$7 287f438a143SAllan Jude 288f438a143SAllan Jude dd if=/dev/zero of=${img} count=1 seek=$(( 200 * 1024 * 1024 / 512 )) 289f438a143SAllan Jude md=$(mdconfig -f ${img}) 290f438a143SAllan Jude gpart create -s gpt ${md} 291f438a143SAllan Jude gpart add -t freebsd-boot -s 400k -a 4k ${md} # <= ~540k 292f438a143SAllan Jude gpart add -t freebsd-ufs -l root $md 293f438a143SAllan Jude # install-boot will make this bootable 294595deaf7SIan Lepore echo ${passphrase} | geli init -bg -e AES-XTS -i ${iterations} -J - -l 256 -s 4096 ${md}p2 295595deaf7SIan Lepore echo ${passphrase} | geli attach -j - ${md}p2 29626a241a0SWarner Losh newfs -L root /dev/${md}p2.eli 297f438a143SAllan Jude mount /dev/${md}p2.eli ${mntpt} 298f438a143SAllan Jude cpsys ${src} ${mntpt} 299f438a143SAllan Jude # need to make a couple of tweaks 300f438a143SAllan Jude cat > ${mntpt}/boot/loader.conf <<EOF 301f438a143SAllan Judegeom_eli_load=YES 302f438a143SAllan JudeEOF 303729c458bSWarner Losh ufs_fstab ${mntpt} 304f438a143SAllan Jude 305f438a143SAllan Jude cp /boot/kernel/geom_eli.ko ${mntpt}/boot/kernel/geom_eli.ko 306f438a143SAllan Jude # end tweaks 307f438a143SAllan Jude umount -f ${mntpt} 308f438a143SAllan Jude geli detach ${md}p2 309f438a143SAllan Jude ${SRCTOP}/tools/boot/install-boot.sh -g ${geli} -s ${scheme} -f ${fs} -b ${bios} -d ${src} ${md} 310f438a143SAllan Jude mdconfig -d -u ${md} 311082c6764SWarner Losh} 312082c6764SWarner Losh 313082c6764SWarner Loshmk_geli_gpt_ufs_uefi() { 314f438a143SAllan Jude src=$1 315f438a143SAllan Jude img=$2 316f438a143SAllan Jude mntpt=$3 317f438a143SAllan Jude geli=$4 318f438a143SAllan Jude scheme=$5 319f438a143SAllan Jude fs=$6 320f438a143SAllan Jude bios=$7 321f438a143SAllan Jude 322f438a143SAllan Jude dd if=/dev/zero of=${img} count=1 seek=$(( 200 * 1024 * 1024 / 512 )) 323f438a143SAllan Jude md=$(mdconfig -f ${img}) 324f438a143SAllan Jude gpart create -s gpt ${md} 325db8b5613SRebecca Cran gpart add -t efi -s ${espsize}k -a 4k ${md} 326f438a143SAllan Jude gpart add -t freebsd-ufs -l root $md 327f438a143SAllan Jude # install-boot will make this bootable 328595deaf7SIan Lepore echo ${passphrase} | geli init -bg -e AES-XTS -i ${iterations} -J - -l 256 -s 4096 ${md}p2 329595deaf7SIan Lepore echo ${passphrase} | geli attach -j - ${md}p2 33026a241a0SWarner Losh newfs -L root /dev/${md}p2.eli 331f438a143SAllan Jude mount /dev/${md}p2.eli ${mntpt} 332f438a143SAllan Jude cpsys ${src} ${mntpt} 333f438a143SAllan Jude # need to make a couple of tweaks 334f438a143SAllan Jude cat > ${mntpt}/boot/loader.conf <<EOF 335f438a143SAllan Judegeom_eli_load=YES 336f438a143SAllan JudeEOF 337729c458bSWarner Losh ufs_fstab ${mntpt} 338f438a143SAllan Jude 339f438a143SAllan Jude cp /boot/kernel/geom_eli.ko ${mntpt}/boot/kernel/geom_eli.ko 340f438a143SAllan Jude # end tweaks 341f438a143SAllan Jude umount -f ${mntpt} 342f438a143SAllan Jude geli detach ${md}p2 343f438a143SAllan Jude ${SRCTOP}/tools/boot/install-boot.sh -g ${geli} -s ${scheme} -f ${fs} -b ${bios} -d ${src} ${md} 344f438a143SAllan Jude mdconfig -d -u ${md} 345082c6764SWarner Losh} 346082c6764SWarner Losh 347082c6764SWarner Loshmk_geli_gpt_ufs_both() { 348f438a143SAllan Jude src=$1 349f438a143SAllan Jude img=$2 350f438a143SAllan Jude mntpt=$3 351f438a143SAllan Jude geli=$4 352f438a143SAllan Jude scheme=$5 353f438a143SAllan Jude fs=$6 354f438a143SAllan Jude bios=$7 355f438a143SAllan Jude 356f438a143SAllan Jude dd if=/dev/zero of=${img} count=1 seek=$(( 200 * 1024 * 1024 / 512 )) 357f438a143SAllan Jude md=$(mdconfig -f ${img}) 358f438a143SAllan Jude gpart create -s gpt ${md} 359db8b5613SRebecca Cran gpart add -t efi -s ${espsize}k -a 4k ${md} 360f438a143SAllan Jude gpart add -t freebsd-boot -s 400k -a 4k ${md} # <= ~540k 361f438a143SAllan Jude gpart add -t freebsd-ufs -l root $md 362f438a143SAllan Jude # install-boot will make this bootable 363595deaf7SIan Lepore echo ${passphrase} | geli init -bg -e AES-XTS -i ${iterations} -J - -l 256 -s 4096 ${md}p3 364595deaf7SIan Lepore echo ${passphrase} | geli attach -j - ${md}p3 36526a241a0SWarner Losh newfs -L root /dev/${md}p3.eli 366f438a143SAllan Jude mount /dev/${md}p3.eli ${mntpt} 367f438a143SAllan Jude cpsys ${src} ${mntpt} 368f438a143SAllan Jude # need to make a couple of tweaks 369f438a143SAllan Jude cat > ${mntpt}/boot/loader.conf <<EOF 370f438a143SAllan Judegeom_eli_load=YES 371f438a143SAllan JudeEOF 372729c458bSWarner Losh ufs_fstab ${mntpt} 373f438a143SAllan Jude 374f438a143SAllan Jude cp /boot/kernel/geom_eli.ko ${mntpt}/boot/kernel/geom_eli.ko 375f438a143SAllan Jude # end tweaks 376f438a143SAllan Jude umount -f ${mntpt} 377f438a143SAllan Jude geli detach ${md}p3 378f438a143SAllan Jude ${SRCTOP}/tools/boot/install-boot.sh -g ${geli} -s ${scheme} -f ${fs} -b ${bios} -d ${src} ${md} 379f438a143SAllan Jude mdconfig -d -u ${md} 380082c6764SWarner Losh} 381082c6764SWarner Losh 382082c6764SWarner Loshmk_geli_gpt_zfs_legacy() { 383f438a143SAllan Jude src=$1 384f438a143SAllan Jude img=$2 385f438a143SAllan Jude mntpt=$3 386f438a143SAllan Jude geli=$4 387f438a143SAllan Jude scheme=$5 388f438a143SAllan Jude fs=$6 389f438a143SAllan Jude bios=$7 390f438a143SAllan Jude pool=geli-gpt-zfs-legacy 391f438a143SAllan Jude 3920c0ffba5SIan Lepore # Note that in this flavor we create an empty p2 ufs partition, and put 3930c0ffba5SIan Lepore # the bootable zfs stuff on p3, just to test the ability of the zfs probe 3940c0ffba5SIan Lepore # probe routines to find a pool on a partition other than the first one. 3950c0ffba5SIan Lepore 3960c0ffba5SIan Lepore dd if=/dev/zero of=${img} count=1 seek=$(( 300 * 1024 * 1024 / 512 )) 397f438a143SAllan Jude md=$(mdconfig -f ${img}) 398f438a143SAllan Jude gpart create -s gpt ${md} 399f438a143SAllan Jude gpart add -t freebsd-boot -s 400k -a 4k ${md} # <= ~540k 4000c0ffba5SIan Lepore gpart add -t freebsd-ufs -s 100m ${md} 401f438a143SAllan Jude gpart add -t freebsd-zfs -l root $md 402f438a143SAllan Jude # install-boot will make this bootable 4030c0ffba5SIan Lepore echo ${passphrase} | geli init -bg -e AES-XTS -i ${iterations} -J - -l 256 -s 4096 ${md}p3 4040c0ffba5SIan Lepore echo ${passphrase} | geli attach -j - ${md}p3 4050c0ffba5SIan Lepore zpool create -O mountpoint=none -R ${mntpt} ${pool} ${md}p3.eli 406f438a143SAllan Jude zpool set bootfs=${pool} ${pool} 407f438a143SAllan Jude zfs create -po mountpoint=/ ${pool}/ROOT/default 408f438a143SAllan Jude # NB: The online guides go nuts customizing /var and other mountpoints here, no need 409f438a143SAllan Jude cpsys ${src} ${mntpt} 410f438a143SAllan Jude # need to make a couple of tweaks 411d050cd6bSWarner Losh cat >> ${mntpt}/boot/loader.conf <<EOF 4129e5787d2SMatt Macycryptodev_load=YES 413f438a143SAllan Judezfs_load=YES 414f438a143SAllan Judegeom_eli_load=YES 415f438a143SAllan JudeEOF 416827f1973SIan Lepore cp /boot/kernel/acl_nfs4.ko ${mntpt}/boot/kernel/acl_nfs4.ko 4179e5787d2SMatt Macy cp /boot/kernel/cryptodev.ko ${mntpt}/boot/kernel/cryptodev.ko 418f438a143SAllan Jude cp /boot/kernel/zfs.ko ${mntpt}/boot/kernel/zfs.ko 419f438a143SAllan Jude cp /boot/kernel/geom_eli.ko ${mntpt}/boot/kernel/geom_eli.ko 420f438a143SAllan Jude # end tweaks 421f438a143SAllan Jude zfs umount -f ${pool}/ROOT/default 422f438a143SAllan Jude zfs set mountpoint=none ${pool}/ROOT/default 423f438a143SAllan Jude zpool set bootfs=${pool}/ROOT/default ${pool} 424f438a143SAllan Jude zpool set autoexpand=on ${pool} 425f438a143SAllan Jude zpool export ${pool} 4260c0ffba5SIan Lepore geli detach ${md}p3 427f438a143SAllan Jude ${SRCTOP}/tools/boot/install-boot.sh -g ${geli} -s ${scheme} -f ${fs} -b ${bios} -d ${src} ${md} 428f438a143SAllan Jude mdconfig -d -u ${md} 429082c6764SWarner Losh} 430082c6764SWarner Losh 431082c6764SWarner Loshmk_geli_gpt_zfs_uefi() { 432f438a143SAllan Jude src=$1 433f438a143SAllan Jude img=$2 434f438a143SAllan Jude mntpt=$3 435f438a143SAllan Jude geli=$4 436f438a143SAllan Jude scheme=$5 437f438a143SAllan Jude fs=$6 438f438a143SAllan Jude bios=$7 439f438a143SAllan Jude pool=geli-gpt-zfs-uefi 440f438a143SAllan Jude 4410c0ffba5SIan Lepore # Note that in this flavor we create an empty p2 ufs partition, and put 4420c0ffba5SIan Lepore # the bootable zfs stuff on p3, just to test the ability of the zfs probe 4430c0ffba5SIan Lepore # probe routines to find a pool on a partition other than the first one. 4440c0ffba5SIan Lepore 4450c0ffba5SIan Lepore dd if=/dev/zero of=${img} count=1 seek=$(( 300 * 1024 * 1024 / 512 )) 446f438a143SAllan Jude md=$(mdconfig -f ${img}) 447f438a143SAllan Jude gpart create -s gpt ${md} 448db8b5613SRebecca Cran gpart add -t efi -s ${espsize}k -a 4k ${md} 4490c0ffba5SIan Lepore gpart add -t freebsd-ufs -s 100m ${md} 450f438a143SAllan Jude gpart add -t freebsd-zfs -l root $md 451f438a143SAllan Jude # install-boot will make this bootable 4520c0ffba5SIan Lepore echo ${passphrase} | geli init -bg -e AES-XTS -i ${iterations} -J - -l 256 -s 4096 ${md}p3 4530c0ffba5SIan Lepore echo ${passphrase} | geli attach -j - ${md}p3 4540c0ffba5SIan Lepore zpool create -O mountpoint=none -R ${mntpt} ${pool} ${md}p3.eli 455f438a143SAllan Jude zpool set bootfs=${pool} ${pool} 456f438a143SAllan Jude zfs create -po mountpoint=/ ${pool}/ROOT/default 457f438a143SAllan Jude # NB: The online guides go nuts customizing /var and other mountpoints here, no need 458f438a143SAllan Jude cpsys ${src} ${mntpt} 459f438a143SAllan Jude # need to make a couple of tweaks 460d050cd6bSWarner Losh cat >> ${mntpt}/boot/loader.conf <<EOF 4619e5787d2SMatt Macycryptodev_load=YES 462f438a143SAllan Judezfs_load=YES 463f438a143SAllan Judegeom_eli_load=YES 464f438a143SAllan JudeEOF 465827f1973SIan Lepore cp /boot/kernel/acl_nfs4.ko ${mntpt}/boot/kernel/acl_nfs4.ko 4669e5787d2SMatt Macy cp /boot/kernel/cryptodev.ko ${mntpt}/boot/kernel/cryptodev.ko 467f438a143SAllan Jude cp /boot/kernel/zfs.ko ${mntpt}/boot/kernel/zfs.ko 468f438a143SAllan Jude cp /boot/kernel/geom_eli.ko ${mntpt}/boot/kernel/geom_eli.ko 469f438a143SAllan Jude # end tweaks 470f438a143SAllan Jude zfs umount -f ${pool}/ROOT/default 471f438a143SAllan Jude zfs set mountpoint=none ${pool}/ROOT/default 472f438a143SAllan Jude zpool set bootfs=${pool}/ROOT/default ${pool} 473f438a143SAllan Jude zpool set autoexpand=on ${pool} 474f438a143SAllan Jude zpool export ${pool} 4750c0ffba5SIan Lepore geli detach ${md}p3 476f438a143SAllan Jude ${SRCTOP}/tools/boot/install-boot.sh -g ${geli} -s ${scheme} -f ${fs} -b ${bios} -d ${src} ${md} 477f438a143SAllan Jude mdconfig -d -u ${md} 478082c6764SWarner Losh} 479082c6764SWarner Losh 480082c6764SWarner Loshmk_geli_gpt_zfs_both() { 481f438a143SAllan Jude src=$1 482f438a143SAllan Jude img=$2 483f438a143SAllan Jude mntpt=$3 484f438a143SAllan Jude geli=$4 485f438a143SAllan Jude scheme=$5 486f438a143SAllan Jude fs=$6 487f438a143SAllan Jude bios=$7 488f438a143SAllan Jude pool=geli-gpt-zfs-both 489f438a143SAllan Jude 490f438a143SAllan Jude dd if=/dev/zero of=${img} count=1 seek=$(( 200 * 1024 * 1024 / 512 )) 491f438a143SAllan Jude md=$(mdconfig -f ${img}) 492f438a143SAllan Jude gpart create -s gpt ${md} 493db8b5613SRebecca Cran gpart add -t efi -s ${espsize}k -a 4k ${md} 494f438a143SAllan Jude gpart add -t freebsd-boot -s 400k -a 4k ${md} # <= ~540k 495f438a143SAllan Jude gpart add -t freebsd-zfs -l root $md 496f438a143SAllan Jude # install-boot will make this bootable 497595deaf7SIan Lepore echo ${passphrase} | geli init -bg -e AES-XTS -i ${iterations} -J - -l 256 -s 4096 ${md}p3 498595deaf7SIan Lepore echo ${passphrase} | geli attach -j - ${md}p3 499f438a143SAllan Jude zpool create -O mountpoint=none -R ${mntpt} ${pool} ${md}p3.eli 500f438a143SAllan Jude zpool set bootfs=${pool} ${pool} 501f438a143SAllan Jude zfs create -po mountpoint=/ ${pool}/ROOT/default 502f438a143SAllan Jude # NB: The online guides go nuts customizing /var and other mountpoints here, no need 503f438a143SAllan Jude cpsys ${src} ${mntpt} 504f438a143SAllan Jude # need to make a couple of tweaks 505f438a143SAllan Jude cat > ${mntpt}/boot/loader.conf <<EOF 5069e5787d2SMatt Macycryptodev_load=YES 507f438a143SAllan Judezfs_load=YES 508f438a143SAllan Judegeom_eli_load=YES 509f438a143SAllan JudeEOF 510827f1973SIan Lepore cp /boot/kernel/acl_nfs4.ko ${mntpt}/boot/kernel/acl_nfs4.ko 5119e5787d2SMatt Macy cp /boot/kernel/cryptodev.ko ${mntpt}/boot/kernel/cryptodev.ko 512f438a143SAllan Jude cp /boot/kernel/zfs.ko ${mntpt}/boot/kernel/zfs.ko 513f438a143SAllan Jude cp /boot/kernel/geom_eli.ko ${mntpt}/boot/kernel/geom_eli.ko 514f438a143SAllan Jude # end tweaks 515f438a143SAllan Jude zfs umount -f ${pool}/ROOT/default 516f438a143SAllan Jude zfs set mountpoint=none ${pool}/ROOT/default 517f438a143SAllan Jude zpool set bootfs=${pool}/ROOT/default ${pool} 518f438a143SAllan Jude zpool set autoexpand=on ${pool} 519f438a143SAllan Jude zpool export ${pool} 520f438a143SAllan Jude geli detach ${md}p3 521f438a143SAllan Jude ${SRCTOP}/tools/boot/install-boot.sh -g ${geli} -s ${scheme} -f ${fs} -b ${bios} -d ${src} ${md} 522f438a143SAllan Jude mdconfig -d -u ${md} 523082c6764SWarner Losh} 524082c6764SWarner Losh 525f438a143SAllan Jude# GELI+MBR is not a valid configuration 526082c6764SWarner Loshmk_geli_mbr_ufs_legacy() { 527082c6764SWarner Losh} 528082c6764SWarner Losh 529082c6764SWarner Loshmk_geli_mbr_ufs_uefi() { 530082c6764SWarner Losh} 531082c6764SWarner Losh 532082c6764SWarner Loshmk_geli_mbr_ufs_both() { 533082c6764SWarner Losh} 534082c6764SWarner Losh 535082c6764SWarner Loshmk_geli_mbr_zfs_legacy() { 536082c6764SWarner Losh} 537082c6764SWarner Losh 538082c6764SWarner Loshmk_geli_mbr_zfs_uefi() { 539082c6764SWarner Losh} 540082c6764SWarner Losh 541082c6764SWarner Loshmk_geli_mbr_zfs_both() { 542082c6764SWarner Losh} 543082c6764SWarner Losh 544082c6764SWarner Losh# iso 545082c6764SWarner Losh# pxeldr 546082c6764SWarner Losh# u-boot 54722cf6021SWarner Losh# powerpc 54822cf6021SWarner Losh 5493d3f2fb0SWarner Loshqser="-monitor telnet::4444,server,nowait -serial stdio -nographic" 55022cf6021SWarner Losh 55122cf6021SWarner Losh# https://wiki.freebsd.org/QemuRecipes 55222cf6021SWarner Losh# aarch64 55322cf6021SWarner Loshqemu_aarch64_uefi() 55422cf6021SWarner Losh{ 55522cf6021SWarner Losh img=$1 55622cf6021SWarner Losh sh=$2 55722cf6021SWarner Losh 55822cf6021SWarner Losh echo "qemu-system-aarch64 -m 4096M -cpu cortex-a57 -M virt \ 55922cf6021SWarner Losh -bios QEMU_EFI.fd ${qser} \ 56022cf6021SWarner Losh -drive if=none,file=${img},id=hd0 \ 56122cf6021SWarner Losh -device virtio-blk-device,drive=hd0" > $sh 562dfe34ceaSIan Lepore chmod 755 $sh 56322cf6021SWarner Losh# https://wiki.freebsd.org/arm64/QEMU also has 56422cf6021SWarner Losh# -device virtio-net-device,netdev=net0 56522cf6021SWarner Losh# -netdev user,id=net0 56622cf6021SWarner Losh} 56722cf6021SWarner Losh 5683d3f2fb0SWarner Loshlog_for() 5693d3f2fb0SWarner Losh{ 5703d3f2fb0SWarner Losh dir=$(dirname $1) 5713d3f2fb0SWarner Losh fn=$(basename $1 .sh) 5723d3f2fb0SWarner Losh echo $dir/$fn.log 5733d3f2fb0SWarner Losh} 5743d3f2fb0SWarner Losh 57522cf6021SWarner Losh# Amd64 qemu 57622cf6021SWarner Loshqemu_amd64_legacy() 57722cf6021SWarner Losh{ 57822cf6021SWarner Losh img=$1 57922cf6021SWarner Losh sh=$2 5803d3f2fb0SWarner Losh log=$(log_for $2) 58122cf6021SWarner Losh 5823d3f2fb0SWarner Losh echo "echo -n $(basename $sh .sh):' '" > $sh 5833d3f2fb0SWarner Losh echo "(qemu-system-x86_64 -m 256m --drive file=${img},format=raw ${qser} | tee $log 2>&1 | grep -q SUCCESS) && echo legacy pass || echo legacy fail" >> $sh 584dfe34ceaSIan Lepore chmod 755 $sh 58522cf6021SWarner Losh} 58622cf6021SWarner Losh 58722cf6021SWarner Loshqemu_amd64_uefi() 58822cf6021SWarner Losh{ 58922cf6021SWarner Losh img=$1 59022cf6021SWarner Losh sh=$2 5913d3f2fb0SWarner Losh log=$(log_for $2) 59222cf6021SWarner Losh 5933d3f2fb0SWarner Losh echo "echo -n $(basename $sh .sh):' '" > $sh 5943d3f2fb0SWarner Losh echo "(qemu-system-x86_64 -m 256m -bios ~/bios/OVMF-X64.fd --drive file=${img},format=raw ${qser} | tee $log 2>&1 | grep -q SUCCESS) && echo uefi pass || echo uefi fail" >> $sh 595dfe34ceaSIan Lepore chmod 755 $sh 59622cf6021SWarner Losh} 59722cf6021SWarner Losh 59822cf6021SWarner Loshqemu_amd64_both() 59922cf6021SWarner Losh{ 60022cf6021SWarner Losh img=$1 60122cf6021SWarner Losh sh=$2 6023d3f2fb0SWarner Losh log=$(log_for $2) 60322cf6021SWarner Losh 6043d3f2fb0SWarner Losh echo "echo -n $(basename $sh .sh):' '" > $sh 6053d3f2fb0SWarner Losh echo "(qemu-system-x86_64 -m 256m --drive file=${img},format=raw ${qser} | tee $log 2>&1 | grep -q SUCCESS) && echo legacy pass || echo legacy fail" >> $sh 6063d3f2fb0SWarner Losh echo "echo -n $(basename $sh .sh):' '" >> $sh 6073d3f2fb0SWarner Losh echo "(qemu-system-x86_64 -m 256m -bios ~/bios/OVMF-X64.fd --drive file=${img},format=raw ${qser} | tee -a $log 2>&1 | grep -q SUCCESS) && echo uefi pass || echo uefi fail" >> $sh 608dfe34ceaSIan Lepore chmod 755 $sh 60922cf6021SWarner Losh} 61022cf6021SWarner Losh 61122cf6021SWarner Losh# arm 61222cf6021SWarner Losh# nothing listed? 61322cf6021SWarner Losh 61422cf6021SWarner Losh# i386 61522cf6021SWarner Loshqemu_i386_legacy() 61622cf6021SWarner Losh{ 61722cf6021SWarner Losh img=$1 61822cf6021SWarner Losh sh=$2 61922cf6021SWarner Losh 62022cf6021SWarner Losh echo "qemu-system-i386 --drive file=${img},format=raw ${qser}" > $sh 621dfe34ceaSIan Lepore chmod 755 $sh 62222cf6021SWarner Losh} 62322cf6021SWarner Losh 62422cf6021SWarner Losh# Not yet supported 62522cf6021SWarner Loshqemu_i386_uefi() 62622cf6021SWarner Losh{ 62722cf6021SWarner Losh img=$1 62822cf6021SWarner Losh sh=$2 62922cf6021SWarner Losh 63022cf6021SWarner Losh echo "qemu-system-i386 -bios ~/bios/OVMF-X32.fd --drive file=${img},format=raw ${qser}" > $sh 631dfe34ceaSIan Lepore chmod 755 $sh 63222cf6021SWarner Losh} 63322cf6021SWarner Losh 63422cf6021SWarner Losh# Needs UEFI to be supported 63522cf6021SWarner Loshqemu_i386_both() 63622cf6021SWarner Losh{ 63722cf6021SWarner Losh img=$1 63822cf6021SWarner Losh sh=$2 63922cf6021SWarner Losh 64022cf6021SWarner Losh echo "qemu-system-i386 --drive file=${img},format=raw ${qser}" > $sh 641712b4ca9SAllan Jude echo "qemu-system-i386 -bios ~/bios/OVMF-X32.fd --drive file=${img},format=raw ${qser}" >> $sh 642dfe34ceaSIan Lepore chmod 755 $sh 64322cf6021SWarner Losh} 64422cf6021SWarner Losh 645432b4921SIan Leporemake_one_image() 646432b4921SIan Lepore{ 647432b4921SIan Lepore local arch=${1?} 648432b4921SIan Lepore local geli=${2?} 649432b4921SIan Lepore local scheme=${3?} 650432b4921SIan Lepore local fs=${4?} 651432b4921SIan Lepore local bios=${5?} 652432b4921SIan Lepore 653432b4921SIan Lepore # Create sparse file and mount newly created filesystem(s) on it 654432b4921SIan Lepore img=${IMGDIR}/${arch}-${geli}-${scheme}-${fs}-${bios}.img 655432b4921SIan Lepore sh=${IMGDIR}/${arch}-${geli}-${scheme}-${fs}-${bios}.sh 6563d3f2fb0SWarner Losh echo "$sh" >> ${IMGDIR}/all.sh 6573d3f2fb0SWarner Losh echo date >> ${IMGDIR}/all.sh 658432b4921SIan Lepore echo "vvvvvvvvvvvvvv Creating $img vvvvvvvvvvvvvvv" 659432b4921SIan Lepore rm -f ${img}* 660432b4921SIan Lepore eval mk_${geli}_${scheme}_${fs}_${bios} ${DESTDIR} ${img} ${MNTPT} ${geli} ${scheme} ${fs} ${bios} 661432b4921SIan Lepore eval qemu_${arch}_${bios} ${img} ${sh} 662432b4921SIan Lepore [ -n "${SUDO_USER}" ] && chown ${SUDO_USER} ${img}* 663432b4921SIan Lepore echo "^^^^^^^^^^^^^^ Created $img ^^^^^^^^^^^^^^^" 664432b4921SIan Lepore} 665432b4921SIan Lepore 66622cf6021SWarner Losh# Powerpc -- doesn't work but maybe it would enough for testing -- needs details 66722cf6021SWarner Losh# powerpc64 66822cf6021SWarner Losh# qemu-system-ppc64 -drive file=/path/to/disk.img,format=raw 66922cf6021SWarner Losh 670082c6764SWarner Losh# Misc variables 671082c6764SWarner LoshSRCTOP=$(make -v SRCTOP) 672082c6764SWarner Loshcd ${SRCTOP}/stand 673082c6764SWarner LoshOBJDIR=$(make -v .OBJDIR) 674082c6764SWarner LoshIMGDIR=${OBJDIR}/boot-images 675082c6764SWarner Loshmkdir -p ${IMGDIR} 676082c6764SWarner LoshMNTPT=$(mktemp -d /tmp/stand-test.XXXXXX) 677082c6764SWarner Losh 678082c6764SWarner Losh# Setup the installed tree... 679082c6764SWarner LoshDESTDIR=${OBJDIR}/boot-tree 680082c6764SWarner Loshrm -rf ${DESTDIR} 681082c6764SWarner Loshmkdir -p ${DESTDIR}/boot/defaults 682082c6764SWarner Loshmkdir -p ${DESTDIR}/boot/kernel 683082c6764SWarner Loshcp /boot/kernel/kernel ${DESTDIR}/boot/kernel 684328884aeSWarner Loshecho -h -D -S115200 > ${DESTDIR}/boot.config 685d050cd6bSWarner Loshcat > ${DESTDIR}/boot/loader.conf <<EOF 686d050cd6bSWarner Loshcomconsole_speed=115200 6873d3f2fb0SWarner Loshautoboot_delay=0 688d050cd6bSWarner LoshEOF 689082c6764SWarner Losh# XXX 690082c6764SWarner Loshcp /boot/device.hints ${DESTDIR}/boot/device.hints 691082c6764SWarner Losh# Assume we're already built 692f576caacSIan Leporemake install DESTDIR=${DESTDIR} MK_MAN=no MK_INSTALL_AS_USER=yes WITHOUT_DEBUG_FILES=yes 693f576caacSIan Leporeif [ $? -ne 0 ]; then 694f576caacSIan Lepore echo "make install failed" 695f576caacSIan Lepore exit 1 696f576caacSIan Leporefi 69722cf6021SWarner Losh# Copy init, /bin/sh, minimal libraries and testing /etc/rc 69822cf6021SWarner Loshmkdir -p ${DESTDIR}/sbin ${DESTDIR}/bin \ 69922cf6021SWarner Losh ${DESTDIR}/lib ${DESTDIR}/libexec \ 70022cf6021SWarner Losh ${DESTDIR}/etc ${DESTDIR}/dev 701d050cd6bSWarner Loshfor f in /sbin/halt /sbin/init /bin/sh /sbin/sysctl $(ldd /bin/sh | awk 'NF == 4 { print $3; }') /libexec/ld-elf.so.1; do 702082c6764SWarner Losh cp $f ${DESTDIR}/$f 703082c6764SWarner Loshdone 70422cf6021SWarner Loshcat > ${DESTDIR}/etc/rc <<EOF 70522cf6021SWarner Losh#!/bin/sh 70622cf6021SWarner Losh 707d050cd6bSWarner Loshsysctl machdep.bootmethod 70822cf6021SWarner Loshecho "RC COMMAND RUNNING -- SUCCESS!!!!!" 70922cf6021SWarner Loshhalt -p 71022cf6021SWarner LoshEOF 711082c6764SWarner Losh 712432b4921SIan Lepore# If we were given exactly 5 args, go make that one image. 713432b4921SIan Lepore 7143d3f2fb0SWarner Loshrm -f ${IMGDIR}/all.sh 7153d3f2fb0SWarner Loshecho date > ${IMGDIR}/all.sh 7163d3f2fb0SWarner Loshchmod +x ${IMGDIR}/all.sh 7173d3f2fb0SWarner Losh 718432b4921SIan Leporeif [ $# -eq 5 ]; then 719432b4921SIan Lepore make_one_image $* 7203d3f2fb0SWarner Losh echo ${IMGDIR}/all.sh 721432b4921SIan Lepore exit 722432b4921SIan Leporefi 723432b4921SIan Lepore 724082c6764SWarner Losh# OK. Let the games begin 725082c6764SWarner Losh 72622cf6021SWarner Loshfor arch in amd64; do 7273d3f2fb0SWarner Losh for geli in nogeli; do # geli 728082c6764SWarner Losh for scheme in gpt mbr; do 729*ef8b8723SWarner Losh for fs in ufs zfs; do 730082c6764SWarner Losh for bios in legacy uefi both; do 731432b4921SIan Lepore make_one_image ${arch} ${geli} ${scheme} ${fs} ${bios} 732082c6764SWarner Losh done 733082c6764SWarner Losh done 734082c6764SWarner Losh done 735082c6764SWarner Losh done 73622cf6021SWarner Loshdone 737*ef8b8723SWarner Losh # We should also do a cd image for amd64 here 7383d3f2fb0SWarner Loshecho ${IMGDIR}/all.sh 739082c6764SWarner Losh 740082c6764SWarner Loshrmdir ${MNTPT} 74122cf6021SWarner Losh 74222cf6021SWarner Loshexit 0 74322cf6021SWarner Losh 74422cf6021SWarner Losh# Notes for the future 74522cf6021SWarner Losh 74622cf6021SWarner Loshfor arch in i386; do 74722cf6021SWarner Losh for geli in nogeli geli; do 74822cf6021SWarner Losh for scheme in gpt mbr; do 74922cf6021SWarner Losh for fs in ufs zfs; do 75022cf6021SWarner Losh for bios in legacy; do 751*ef8b8723SWarner Losh # The legacy boot is shared with amd64 so those routines could 752*ef8b8723SWarner Losh # likely be used here. 753432b4921SIan Lepore make_one_image ${arch} ${geli} ${scheme} ${fs} ${bios} 75422cf6021SWarner Losh done 75522cf6021SWarner Losh done 75622cf6021SWarner Losh done 75722cf6021SWarner Losh done 75822cf6021SWarner Loshdone 759*ef8b8723SWarner Losh # We should also do a cd image for i386 here 76022cf6021SWarner Losh 76122cf6021SWarner Loshfor arch in arm aarch64; do 762*ef8b8723SWarner Losh geli=nogeli # I don't think geli boot works / is supported on arm 76322cf6021SWarner Losh for scheme in gpt mbr; do 764*ef8b8723SWarner Losh for fs in ufs zfs; do 765*ef8b8723SWarner Losh bios=efi # Note: arm has some uboot support with ufs, what to do? 766432b4921SIan Lepore make_one_image ${arch} ${geli} ${scheme} ${fs} ${bios} 76722cf6021SWarner Losh done 76822cf6021SWarner Losh done 769*ef8b8723SWarner Loshdone 77022cf6021SWarner Losh 771*ef8b8723SWarner Losh# It's not clear that the nested looping paradigm is best for powerpc 772*ef8b8723SWarner Losh# due to its diversity. 773*ef8b8723SWarner Loshfor arch in powerpc powerpc64 powerpc64le; do 774*ef8b8723SWarner Losh geli=nogeli 775*ef8b8723SWarner Losh for scheme in apm gpt; do 776*ef8b8723SWarner Losh fs=ufs # zfs + gpt might be supported? 77722cf6021SWarner Losh for bios in ofw uboot chrp; do 778432b4921SIan Lepore make_one_image ${arch} ${geli} ${scheme} ${fs} ${bios} 77922cf6021SWarner Losh done 78022cf6021SWarner Losh done 78122cf6021SWarner Loshdone 78222cf6021SWarner Losh 783aff95057SWarner Loshfor arch in riscv; do 784aff95057SWarner Losh geli=nogeli 785*ef8b8723SWarner Losh fs=ufs # Generic ZFS booting support with efi? 786aff95057SWarner Losh scheme=gpt 787aff95057SWarner Losh bios=efi 788432b4921SIan Lepore make_one_image ${arch} ${geli} ${scheme} ${fs} ${bios} 78922cf6021SWarner Loshdone 790