Files
Colin Percival 22c4099b04 EC2: Enable autogrowing filesystems post-boot
Enable the new growfs_postboot mechanism.  Note that this also implies
disabling automatic allocation of swap space on the root disk, since we
cannot grow the root filesystem if swap space is allocated after it.

This will not be MFCed since it is a significant behavioural change.

Sponsored by:	Amazon
Relnotes:	yes
2026-08-23 22:06:06 -07:00

52 lines
1.9 KiB
Bash

#!/bin/sh
. ${WORLDDIR}/release/tools/ec2.conf
# Packages to install into the image we're creating. In addition to packages
# present on all EC2 AMIs, we install:
# * amazon-ssm-agent (not enabled by default, but some users need to use
# it on systems not connected to the internet),
# * ec2-scripts, which provides a range of EC2ification startup scripts,
# * firstboot-pkg-upgrade, to install security updates at first boot,
# * firstboot-pkgs, to install packages at first boot, and
# * isc-dhcp44-client, used for IPv6 network setup.
export VM_EXTRA_PACKAGES="${VM_EXTRA_PACKAGES} amazon-ssm-agent ec2-scripts \
firstboot-pkg-upgrade firstboot-pkgs isc-dhcp44-client"
# Services to enable in rc.conf(5).
export VM_RC_LIST="${VM_RC_LIST} ec2_configinit ec2_ephemeral_swap \
ec2_fetchkey ec2_loghostkey firstboot_pkg_upgrade firstboot_pkgs \
growfs growfs_postboot sshd"
vm_extra_pre_umount() {
# The AWS CLI tools are generally useful, and small enough that they
# will download quickly; but users will often override this setting
# via EC2 user-data.
echo 'firstboot_pkgs_list="devel/py-awscli"' >> ${DESTDIR}/etc/rc.conf
# Limit firstboot_pkg_upgrade to the base system.
echo 'firstboot_pkg_upgrade_repos="FreeBSD-base"' >> ${DESTDIR}/etc/rc.conf
# Don't allocate swap space when we first boot; that makes it
# impossible to grow the root filesystem later.
echo 'growfs_swap_size=0' >> ${DESTDIR}/etc/rc.conf
# Any EC2 ephemeral disks seen when the system first boots will
# be "new" disks; there is no "previous boot" when they might have
# been seen and used already.
touch ${DESTDIR}/var/db/ec2_ephemeral_diskseen
metalog_add_data ./var/db/ec2_ephemeral_diskseen
# Configuration common to all EC2 AMIs
ec2_common
# Standard FreeBSD network configuration
ec2_base_networking
# Add files from packages which weren't recorded in metalog
metalog_add_data ./usr/local/etc/dhclient.conf
metalog_add_data ./usr/local/etc/ssl/cert.pem
return 0
}