git: 26a241a0e2fe - main - stand: Update GELI UFS cases to use ufs labels

From: Warner Losh <imp_at_FreeBSD.org>
Date: Mon, 15 Aug 2022 18:47:36 UTC
The branch main has been updated by imp:

URL: https://cgit.FreeBSD.org/src/commit/?id=26a241a0e2fea980e7506a610b774add9ac07aae

commit 26a241a0e2fea980e7506a610b774add9ac07aae
Author:     Warner Losh <imp@FreeBSD.org>
AuthorDate: 2022-08-15 18:20:50 +0000
Commit:     Warner Losh <imp@FreeBSD.org>
CommitDate: 2022-08-15 18:38:32 +0000

    stand: Update GELI UFS cases to use ufs labels
    
    GELI images are created in a different manner than non-GELI
    images. Update them to set the label of 'root' on the UFS partition and
    use that in fstab. Drop comments about needing to do this, as well as
    the 'dev' variable now that it's unused.
    
    Sponsored by:           Netflix
---
 tools/boot/rootgen.sh | 18 +++++++-----------
 1 file changed, 7 insertions(+), 11 deletions(-)

diff --git a/tools/boot/rootgen.sh b/tools/boot/rootgen.sh
index 3146b06216a2..bcf0aa92419f 100755
--- a/tools/boot/rootgen.sh
+++ b/tools/boot/rootgen.sh
@@ -7,13 +7,12 @@ iterations=50000
 
 # The smallest FAT32 filesystem is 33292 KB
 espsize=33292
-dev=vtbd0
 
 #
 # Builds all the bat-shit crazy combinations we support booting from,
 # at least for amd64. It assume you have a ~sane kernel in /boot/kernel
 # and copies that into the ~150MB root images we create (we create the du
-# size of the kernel + 20MB
+# size of the kernel + 20MB).
 #
 # Sad panda sez: this runs as root, but could be any user if someone
 # creates userland geli.
@@ -21,9 +20,6 @@ dev=vtbd0
 # This assumes an external program install-boot.sh which will install
 # the appropriate boot files in the appropriate locations.
 #
-# These images assume ${dev} will be the root image. We should likely
-# use labels, but we don't for all cases just yet (see GELI cases)
-#
 # Assumes you've already rebuilt... maybe bad? Also maybe bad: the env
 # vars should likely be conditionally set to allow better automation.
 #
@@ -386,7 +382,7 @@ mk_geli_gpt_ufs_legacy() {
     # install-boot will make this bootable
     echo ${passphrase} | geli init -bg -e AES-XTS -i ${iterations} -J - -l 256 -s 4096 ${md}p2
     echo ${passphrase} | geli attach -j - ${md}p2
-    newfs /dev/${md}p2.eli
+    newfs -L root /dev/${md}p2.eli
     mount /dev/${md}p2.eli ${mntpt}
     cpsys ${src} ${mntpt}
     # need to make a couple of tweaks
@@ -394,7 +390,7 @@ mk_geli_gpt_ufs_legacy() {
 geom_eli_load=YES
 EOF
     cat > ${mntpt}/etc/fstab <<EOF
-/dev/${dev}p2.eli	/		ufs	rw	1	1
+/dev/ufs/root	/		ufs	rw	1	1
 EOF
 
     cp /boot/kernel/geom_eli.ko ${mntpt}/boot/kernel/geom_eli.ko
@@ -422,7 +418,7 @@ mk_geli_gpt_ufs_uefi() {
     # install-boot will make this bootable
     echo ${passphrase} | geli init -bg -e AES-XTS -i ${iterations} -J - -l 256 -s 4096 ${md}p2
     echo ${passphrase} | geli attach -j - ${md}p2
-    newfs /dev/${md}p2.eli
+    newfs -L root /dev/${md}p2.eli
     mount /dev/${md}p2.eli ${mntpt}
     cpsys ${src} ${mntpt}
     # need to make a couple of tweaks
@@ -430,7 +426,7 @@ mk_geli_gpt_ufs_uefi() {
 geom_eli_load=YES
 EOF
     cat > ${mntpt}/etc/fstab <<EOF
-/dev/${dev}p2.eli	/		ufs	rw	1	1
+/dev/ufs/root	/		ufs	rw	1	1
 EOF
 
     cp /boot/kernel/geom_eli.ko ${mntpt}/boot/kernel/geom_eli.ko
@@ -459,7 +455,7 @@ mk_geli_gpt_ufs_both() {
     # install-boot will make this bootable
     echo ${passphrase} | geli init -bg -e AES-XTS -i ${iterations} -J - -l 256 -s 4096 ${md}p3
     echo ${passphrase} | geli attach -j - ${md}p3
-    newfs /dev/${md}p3.eli
+    newfs -L root /dev/${md}p3.eli
     mount /dev/${md}p3.eli ${mntpt}
     cpsys ${src} ${mntpt}
     # need to make a couple of tweaks
@@ -467,7 +463,7 @@ mk_geli_gpt_ufs_both() {
 geom_eli_load=YES
 EOF
     cat > ${mntpt}/etc/fstab <<EOF
-/dev/${dev}p3.eli	/		ufs	rw	1	1
+/dev/ufs/root	/		ufs	rw	1	1
 EOF
 
     cp /boot/kernel/geom_eli.ko ${mntpt}/boot/kernel/geom_eli.ko