Skip to content

Commit

Permalink
rootgen.sh: complete all profiles except GELI+MBR (not supported)
Browse files Browse the repository at this point in the history
This extends the test suite to generate images for every combination of:
amd64: mbr/gpt geli/nogeli ufs/zfs legacy/uefi/both

Except for mbr+geli, which is not currently possible.

Reviewed by:	imp (previous version)
Sponsored by:	Klara Systems
Differential Revision:	https://reviews.freebsd.org/D15846
  • Loading branch information
allanjude committed Jun 17, 2018
1 parent 041a40c commit 75f082b
Show file tree
Hide file tree
Showing 2 changed files with 476 additions and 43 deletions.
148 changes: 115 additions & 33 deletions tools/boot/install-boot.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,28 +27,42 @@ find-part() {
gpart show $dev | tail +2 | awk '$4 == "'$part'" { print $3; }'
}

boot_nogeli_gpt_zfs_legacy() {
boot_nogeli_gpt_ufs_legacy() {
dev=$1
dst=$2

idx=$(find-part $dev "freebsd-boot")
if [ -z "$idx" ] ; then
die "No freebsd-boot partition found"
fi
doit gpart bootcode -b ${gpt0} -p ${gptzfs2} -i $idx $dev
exit 0
doit gpart bootcode -b ${gpt0} -p ${gpt2} -i $idx $dev
}

boot_nogeli_gpt_ufs_legacy() {
boot_nogeli_gpt_ufs_uefi() {
dev=$1
dst=$2

idx=$(find-part $dev "efi")
if [ -z "$idx" ] ; then
die "No ESP partition found"
fi
doit gpart bootcode -p ${efi2} -i $idx $dev
}

boot_nogeli_gpt_ufs_both() {
boot_nogeli_gpt_ufs_legacy $1 $2 $3
boot_nogeli_gpt_ufs_uefi $1 $2 $3
}

boot_nogeli_gpt_zfs_legacy() {
dev=$1
dst=$2

idx=$(find-part $dev "freebsd-boot")
if [ -z "$idx" ] ; then
die "No freebsd-boot partition found"
fi
doit gpart bootcode -b ${gpt0} -p ${gpt2} -i $idx $dev
exit 0
doit gpart bootcode -b ${gpt0} -p ${gptzfs2} -i $idx $dev
}

boot_nogeli_gpt_zfs_uefi() {
Expand All @@ -57,62 +71,130 @@ boot_nogeli_gpt_zfs_uefi() {

idx=$(find-part $dev "efi")
if [ -z "$idx" ] ; then
die "No efi ESP partition found"
die "No ESP partition found"
fi
doit gpart bootcode -p ${efi2} -i $idx $dev
exit 0
}

boot_nogeli_gpt_zfs_both() {
boot_nogeli_gpt_zfs_legacy $1 $2 $3
boot_nogeli_gpt_zfs_uefi $1 $2 $3
}

boot_nogeli_mbr_ufs_legacy() {
dev=$1
dst=$2

# XXX: Should this be copy/pasted, or should it call both _uefi and _legacy
idx=$(find-part $dev "efi")
if [ -z "$idx" ] ; then
die "No efi ESP partition found"
doit gpart bootcode -b ${mbr0} ${dev}
s=$(find-part $dev "freebsd")
if [ -z "$s" ] ; then
die "No freebsd slice found"
fi
doit gpart bootcode -p ${efi2} -i $idx $dev
doit gpart bootcode -p ${mbr2} ${dev}s${s}
}

idx=$(find-part $dev "freebsd-boot")
if [ -z "$idx" ] ; then
die "No freebsd-boot partition found"
boot_nogeli_mbr_ufs_uefi() {
dev=$1
dst=$2

s=$(find-part ${dev} "!239")
if [ -z "$s" ] ; then
die "No ESP slice found"
fi
doit gpart bootcode -b ${gpt0} -p ${gptzfs2} -i $idx $dev
exit 0
doit gpart bootcode -p ${efi2} -i ${s} ${dev}
}

boot_nogeli_mbr_ufs_both() {
boot_nogeli_mbr_ufs_legacy $1 $2 $3
boot_nogeli_mbr_ufs_uefi $1 $2 $3
}

boot_nogeli_mbr_zfs_legacy() {
dev=$1
dst=$2

# search to find the BSD slice
s=$(findpart $dev "freebsd-zfs")
s=$(find-part $dev "freebsd")
if [ -z "$s" ] ; then
die "No BSD slice found"
fi
idx=$(find-part ${dev}s${s} "freebsd-zfs")
if [ -z "$idx" ] ; then
die "No freebsd-zfs slice found"
fi
# search to find the freebsd-zfs partition within the slice
# Or just assume it is 'a' because it has to be since it fails otherwise
doit gpart bootcode -b ${dst}/boot/mbr ${dev}
dd if=${dst}/boot/zfsboot of=/tmp/zfsboot1 count=1
doit gpart bootcode -b /tmp/zfsboo1 ${dev}s${s} # Put boot1 into the start of part
doit gpart bootcode -b /tmp/zfsboot1 ${dev}s${s} # Put boot1 into the start of part
sysctl kern.geom.debugflags=0x10 # Put boot2 into ZFS boot slot
doit dd if=${dst}/boot/zfsboot of=/dev/${dev}s${s} iseek=1 seek=1024
doit dd if=${dst}/boot/zfsboot of=/dev/${dev}s${s}a skip=1 seek=1024
sysctl kern.geom.debugflags=0x0

exit 0
}

boot_nogeli_mbr_ufs_legacy() {
boot_nogeli_mbr_zfs_uefi() {
dev=$1
dst=$2

doit gpart bootcode -b ${mbr0} ${dev}
s=$(findpart $dev "freebsd-ufs")
s=$(find-part $dev "!239")
if [ -z "$s" ] ; then
die "No freebsd-ufs slice found"
die "No ESP slice found"
fi
doit gpart bootcode -p ${mbr2} ${dev}s${s}
exit 0
doit gpart bootcode -p ${efi2} -i ${s} ${dev}
}

boot_nogeli_mbr_zfs_both() {
boot_nogeli_mbr_zfs_legacy $1 $2 $3
boot_nogeli_mbr_zfs_uefi $1 $2 $3
}

boot_geli_gpt_ufs_legacy() {
boot_nogeli_gpt_ufs_legacy $1 $2 $3
}

boot_geli_gpt_ufs_uefi() {
boot_nogeli_gpt_ufs_uefi $1 $2 $3
}

boot_geli_gpt_ufs_both() {
boot_nogeli_gpt_ufs_both $1 $2 $3
}

boot_geli_gpt_zfs_legacy() {
boot_nogeli_gpt_zfs_legacy $1 $2 $3
}

boot_geli_gpt_zfs_uefi() {
boot_nogeli_gpt_zfs_uefi $1 $2 $3
}

boot_geli_gpt_zfs_both() {
boot_nogeli_gpt_zfs_both $1 $2 $3
}

# GELI+MBR is not a valid configuration
boot_geli_mbr_ufs_legacy() {
exit 1
}

boot_geli_mbr_ufs_uefi() {
exit 1
}

boot_geli_mbr_ufs_both() {
exit 1
}

boot_geli_mbr_zfs_legacy() {
exit 1
}

boot_geli_mbr_zfs_uefi() {
exit 1
}

boot_geli_mbr_zfs_both() {
exit 1
}

boot_nogeli_vtoc8_ufs_ofw() {
Expand All @@ -122,7 +204,6 @@ boot_nogeli_vtoc8_ufs_ofw() {
# For non-native builds, ensure that geom_part(4) supports VTOC8.
kldload geom_part_vtoc8.ko
doit gpart bootcode -p ${vtoc8} ${dev}
exit 0
}

DESTDIR=/
Expand Down Expand Up @@ -166,11 +247,12 @@ gpt2=${DESTDIR}/boot/gptboot
gptzfs2=${DESTDIR}/boot/gptzfsboot

# For gpt + EFI we install the ESP
# XXX This should use newfs or makefs, but it deosn't yet
# XXX This should use newfs or makefs, but it doesn't yet
efi1=${DESTDIR}/boot/boot1.efi
efi2=${DESTDIR}/boot/boot1.efifat

# For MBR, we have lots of choices, but select boot0
mbr0=${DESTDIR}/boot/boot0
# For MBR, we have lots of choices, but select mbr, boot0 has issues with UEFI
mbr0=${DESTDIR}/boot/mbr
mbr2=${DESTDIR}/boot/boot

# VTOC8
Expand Down
Loading

0 comments on commit 75f082b

Please sign in to comment.