Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 3 Oct 2025 16:53:38 GMT
From:      Colin Percival <cperciva@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: b9a0e12f6ea3 - stable/15 - release: Create /firstboot in common VM image creation code
Message-ID:  <202510031653.593Grcnn064051@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch stable/15 has been updated by cperciva:

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

commit b9a0e12f6ea365d38d1813fa4643cd84293453f7
Author:     Mark Johnston <markj@FreeBSD.org>
AuthorDate: 2025-09-11 13:05:31 +0000
Commit:     Colin Percival <cperciva@FreeBSD.org>
CommitDate: 2025-10-03 16:42:21 +0000

    release: Create /firstboot in common VM image creation code
    
    Some services, such as growfs, only run upon the first boot of an image.
    The first boot is indicated by the presence of the file /firstboot,
    which is unlinked after boot.
    
    Individual cloudware types shouldn't be responsible for creating it.  Do
    so in a centralized place.  Aside from simplifying things, this ensures
    that we create a metalog entry for the firstboot file.
    
    Reviewed by:    cperciva, emaste
    MFC after:      2 weeks
    Sponsored by:   The FreeBSD Foundation
    Sponsored by:   Klara, Inc.
    Differential Revision:  https://reviews.freebsd.org/D52450
    
    (cherry picked from commit 1d6b6ea2d0e617d29681da3cf121abec309d272f)
---
 release/tools/azure.conf           |  2 --
 release/tools/basic-ci.conf        |  2 --
 release/tools/basic-cloudinit.conf |  2 --
 release/tools/ec2.conf             |  3 ---
 release/tools/gce.conf             |  2 --
 release/tools/openstack.conf       |  1 -
 release/tools/oracle.conf          |  2 --
 release/tools/vmimage.subr         | 11 +++++------
 tests/ci/tools/ci.conf             |  1 -
 9 files changed, 5 insertions(+), 21 deletions(-)

diff --git a/release/tools/azure.conf b/release/tools/azure.conf
index dfb90f1cd4f6..7975e1db0822 100644
--- a/release/tools/azure.conf
+++ b/release/tools/azure.conf
@@ -58,7 +58,5 @@ mlx5en_load="YES"
 EOF
 	metalog_add_data ./boot/loader.conf
 
-	touch ${DESTDIR}/firstboot
-
 	return 0
 }
diff --git a/release/tools/basic-ci.conf b/release/tools/basic-ci.conf
index 4bcb87aec791..e235c03d39fe 100644
--- a/release/tools/basic-ci.conf
+++ b/release/tools/basic-ci.conf
@@ -30,7 +30,5 @@ PermitEmptyPasswords yes
 UsePAM no
 EOF
 
-	touch_firstboot
-
 	return 0
 }
diff --git a/release/tools/basic-cloudinit.conf b/release/tools/basic-cloudinit.conf
index 7088c0a5f72a..f8554c42f49c 100644
--- a/release/tools/basic-cloudinit.conf
+++ b/release/tools/basic-cloudinit.conf
@@ -34,7 +34,5 @@ PasswordAuthentication yes
 UsePAM no
 EOF
 
-	touch ${DESTDIR}/firstboot
-
 	return 0
 }
diff --git a/release/tools/ec2.conf b/release/tools/ec2.conf
index aecaabfcd277..335db6cca93a 100644
--- a/release/tools/ec2.conf
+++ b/release/tools/ec2.conf
@@ -136,9 +136,6 @@ EOF
 	chmod 755 ${DESTDIR}/etc/autofs/special_efs
 	metalog_add_data ./etc/autofs/special_efs 0755
 
-	# The first time the AMI boots, run "first boot" scripts.
-	touch ${DESTDIR}/firstboot
-
 	return 0
 }
 
diff --git a/release/tools/gce.conf b/release/tools/gce.conf
index e1c208e69fe5..a7ccfc27a75c 100644
--- a/release/tools/gce.conf
+++ b/release/tools/gce.conf
@@ -113,8 +113,6 @@ EOF
 	## of the image prior to packaging for upload to GCE.
 	#sed -E -i '' 's/^([^#].*[[:space:]])on/\1off/' ${DESTDIR}/etc/ttys
 
-	touch ${DESTDIR}/firstboot
-
 	return 0
 }
 
diff --git a/release/tools/openstack.conf b/release/tools/openstack.conf
index 05d2d13bbb39..b73734a4fd04 100644
--- a/release/tools/openstack.conf
+++ b/release/tools/openstack.conf
@@ -47,6 +47,5 @@ vm_extra_pre_umount() {
 	echo 'debug.debugger_on_panic=0' >> ${DESTDIR}/etc/sysctl.conf
 	echo 'kern.panic_reboot_wait_time=0' >> ${DESTDIR}/etc/sysctl.conf
 
-	touch ${DESTDIR}/firstboot
 	return 0
 }
diff --git a/release/tools/oracle.conf b/release/tools/oracle.conf
index debc5c1352dd..ebda3b3d6e61 100644
--- a/release/tools/oracle.conf
+++ b/release/tools/oracle.conf
@@ -89,7 +89,5 @@ EOF
 	sed -i '' -E -e 's/^pool.*iburst/server 169.254.169.254 iburst/' \
             ${DESTDIR}/etc/ntp.conf
 
-	touch ${DESTDIR}/firstboot
-
 	return 0
 }
diff --git a/release/tools/vmimage.subr b/release/tools/vmimage.subr
index dbec38485fec..577abaac73cf 100644
--- a/release/tools/vmimage.subr
+++ b/release/tools/vmimage.subr
@@ -185,7 +185,6 @@ vm_extra_enable_services() {
 			${DESTDIR}/etc/rc.conf
 		# Expand the filesystem to fill the disk.
 		echo 'growfs_enable="YES"' >> ${DESTDIR}/etc/rc.conf
-		touch ${DESTDIR}/firstboot
 	fi
 
 	return 0
@@ -396,6 +395,11 @@ vm_create_disk() {
 			>> ${DESTDIR}/etc/fstab
 	fi
 
+	# Add a marker file which indicates that this image has never
+	# been booted.  Some services run only upon the first boot.
+	touch ${DESTDIR}/firstboot
+	metalog_add_data ./firstboot
+
 	echo "Building filesystem...  Please wait."
 	buildfs
 
@@ -420,8 +424,3 @@ vm_extra_create_disk() {
 
 	return 0
 }
-
-touch_firstboot() {
-	touch ${DESTDIR}/firstboot
-	metalog_add_data ./firstboot
-}
diff --git a/tests/ci/tools/ci.conf b/tests/ci/tools/ci.conf
index 1d2921ab75f3..2302fc479a47 100644
--- a/tests/ci/tools/ci.conf
+++ b/tests/ci/tools/ci.conf
@@ -119,7 +119,6 @@ fdesc                      /dev/fd fdescfs   rw      0       0
 EOF
 	mkdir -p ${DESTDIR}/usr/local/etc/rc.d
 	cp -p ${scriptdir}/../../tests/ci/tools/freebsdci ${DESTDIR}/usr/local/etc/rc.d/
-	touch ${DESTDIR}/firstboot
 
 	return 0
 }



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202510031653.593Grcnn064051>