From dcbbe588621cee9833871f571275cdcf64fe2e43 Mon Sep 17 00:00:00 2001 From: kn Date: Tue, 6 Sep 2022 19:35:21 +0000 Subject: [PATCH] Use multi-chunk RAID 1C with keydisk on softraid enabled archs Keydisks requires special treatment and should not be touched by installboot. In real setups they are probably offline (temporary USB stick, only present during boot to unlock), but when they are around (keydisk chunk on same disk as crypto volume)... installboot currently installs treats keydisk like any other chunk, which must be fixed. Thus change the tests into a should-work-but-currently-broken setup so an installboot fix can be immediately tested against it. --- regress/usr.sbin/installboot/Makefile | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/regress/usr.sbin/installboot/Makefile b/regress/usr.sbin/installboot/Makefile index 7a74b353337..653600e0f43 100644 --- a/regress/usr.sbin/installboot/Makefile +++ b/regress/usr.sbin/installboot/Makefile @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile,v 1.20 2022/09/05 19:32:50 kn Exp $ +# $OpenBSD: Makefile,v 1.21 2022/09/06 19:35:21 kn Exp $ INSTALLBOOT ?= /usr/sbin/installboot DRY_RUN = ${INSTALLBOOT} -n @@ -43,7 +43,12 @@ STAGEDIR = /usr/mdec STAGEFILES = ${STAGENAMES:=${STAGEDIR}/%} .if ${USE_SOFTRAID:L} == "yes" +# install on multi-chunk RAID 1C with keydisk so installboot(8) must +# - iterate over chunks +# - ignore the keydisk/not install to it NDISKS ?= 1 2 +KEYDISKFILE = keydisk.img +KEYDEVFILE = keydev.txt .else NDISKS = 1 .endif @@ -60,6 +65,10 @@ create-disks: dd if=/dev/zero of=disk${n}.img bs=1m count=0 seek=64 status=none ${SUDO} vnconfig -- disk${n}.img 1>diskdev${n}.txt .endfor +.if ${USE_SOFTRAID:L} == "yes" + dd if=/dev/zero of=${KEYDISKFILE} bs=1m count=0 seek=2 status=none + ${SUDO} vnconfig -- ${KEYDISKFILE} 1>${KEYDEVFILE} +.endif format-disks: create-disks .for devfile in ${DISKDEVFILES} @@ -69,11 +78,15 @@ format-disks: create-disks ${SUDO} disklabel -wAT/dev/stdin -- "$$(<${devfile})" 1>/dev/null . endif .endfor +.if ${USE_SOFTRAID:L} == "yes" + echo 'RAID 1M' | \ + ${SUDO} disklabel -wAT/dev/stdin -- "$$(<${KEYDEVFILE})" 1>/dev/null +.endif create-root: format-disks .if ${USE_SOFTRAID:L} == "yes" ${SUDO} bioctl -l"$$(sed -- s/$$/a/ ${DISKDEVFILES} | paste -sd, -- -)" \ - -cc -- softraid0 | \ + -c1C -k"$$(<${KEYDEVFILE})"a -- softraid0 | \ awk -- '{ print $$NF }' 1>${ROOTDEVFILE} .else ln -s -- ${DISKDEVFILES} ${ROOTDEVFILE} @@ -148,6 +161,9 @@ dry-toomany: CLEANFILES = ${DISKFILES} ${DISKDEVFILES} ${ROOTDEVFILE} +.if ${USE_SOFTRAID:L} == "yes" +CLEANFILES += ${KEYDISKFILE} ${KEYDEVFILE} +.endif REGRESS_CLEANUP = cleanup # allow failure to always cleanup as much as possible @@ -156,6 +172,7 @@ cleanup: -rmdir -- ${MOUNTPOINT} 2>/dev/null .if ${USE_SOFTRAID:L} == "yes" -${SUDO} bioctl -d -- "$$(<${ROOTDEVFILE})" 2>/dev/null + -${SUDO} vnconfig -u -- "$$(<${KEYDEVFILE})" 2>/dev/null .endif .for devfile in ${DISKDEVFILES} -${SUDO} vnconfig -u -- "$$(<${devfile})" 2>/dev/null -- 2.20.1