ec2.conf revision 287802
12061Sjkh#!/bin/sh 233611Sjb# 32061Sjkh# $FreeBSD: stable/10/release/tools/ec2.conf 287802 2015-09-14 19:37:51Z cperciva $ 433611Sjb# 532427Sjb 632427Sjb# Packages to install into the image we're creating. This is a deliberately 733611Sjb# minimalist set, providing only the packages necessary to bootstrap further 833611Sjb# package installation as specified via EC2 user-data. 932427Sjbexport VM_EXTRA_PACKAGES="ec2-scripts firstboot-freebsd-update firstboot-pkgs" 1032427Sjb 112061Sjkh# Set to a list of third-party software to enable in rc.conf(5). 1215603Smarkmexport VM_RC_LIST="ec2_configinit ec2_fetchkey ec2_ephemeralswap ec2_loghostkey firstboot_freebsd_update firstboot_pkgs" 1330169Sjkh 1420710Sasami# Build with a 1.5 GB UFS partition; the growfs rc.d script will expand 1520710Sasami# the partition to fill the root disk after the EC2 instance is launched. 163197Scsgr# Note that if this is set to <N>G, we will end up with an <N+1> GB disk 172061Sjkh# image since VMSIZE is the size of the UFS partition, not the disk which 1812483Speter# it resides within. 1933133Sadamexport VMSIZE=1536M 202160Scsgr 212834Swollman# No swap space; the ec2_ephemeralswap rc.d script will allocate swap 222061Sjkh# space on EC2 ephemeral disks. (If they exist -- the T2 low-cost instances 232061Sjkh# and the C4 compute-optimized instances don't have ephemeral disks. But 242160Scsgr# it would be silly to bloat the image and increase costs for every instance 2517308Speter# just for those two families, especially since instances ranging in size 2619320Sadam# from 1 GB of RAM to 60 GB of RAM would need different sizes of swap space 2727788Sasami# anyway.) 2830169Sjkhexport NOSWAP=YES 2925980Sasami 301594Srgrimesvm_extra_pre_umount() { 3117308Speter # The firstboot_pkgs rc.d script will download the repository 3217308Speter # catalogue and install or update pkg when the instance first 3327910Sasami # launches, so these files would just be replaced anyway; removing 3427910Sasami # them from the image allows it to boot faster. 3527910Sasami env ASSUME_ALWAYS_YES=yes pkg -c ${DESTDIR} delete -f -y pkg 3617308Speter rm ${DESTDIR}/var/db/pkg/repo-*.sqlite 3717308Speter 3817308Speter # The size of the EC2 root disk can be configured at instance launch 3919175Sbde # time; expand our filesystem to fill the disk. 4019175Sbde echo 'growfs_enable="YES"' >> ${DESTDIR}/etc/rc.conf 4119175Sbde 4219175Sbde # EC2 instances use DHCP to get their network configuration. 4317308Speter echo 'ifconfig_DEFAULT="SYNCDHCP"' >> ${DESTDIR}/etc/rc.conf 4427910Sasami 4525647Sbde # Unless the system has been configured via EC2 user-data, the user 4627910Sasami # will need to SSH in to do anything. 4717308Speter echo 'sshd_enable="YES"' >> ${DESTDIR}/etc/rc.conf 482061Sjkh 492061Sjkh # The AWS CLI tools are generally useful, and small enough that they 501594Srgrimes # will download quickly; but users will often override this setting 5130169Sjkh # via EC2 user-data. 5230169Sjkh echo 'firstboot_pkgs_list="awscli"' >> ${DESTDIR}/etc/rc.conf 5330169Sjkh 5430169Sjkh # The EC2 console is output-only, so while printing a backtrace can 5530169Sjkh # be useful, there's no point dropping into a debugger or waiting 5630169Sjkh # for a keypress. 5730169Sjkh echo 'debug.trace_on_panic=1' >> ${DESTDIR}/etc/sysctl.conf 5830169Sjkh echo 'debug.debugger_on_panic=0' >> ${DESTDIR}/etc/sysctl.conf 597407Srgrimes echo 'kern.panic_reboot_wait_time=0' >> ${DESTDIR}/etc/sysctl.conf 607108Sphk 617108Sphk # The console is not interactive, so we might as well boot quickly. 627108Sphk echo 'autoboot_delay="-1"' >> ${DESTDIR}/boot/loader.conf 637407Srgrimes echo 'beastie_disable="YES"' >> ${DESTDIR}/boot/loader.conf 647407Srgrimes 657407Srgrimes # The EC2 console is an emulated serial port. 667108Sphk echo 'console="comconsole"' >> ${DESTDIR}/boot/loader.conf 672061Sjkh 682061Sjkh # Some older EC2 hardware used a version of Xen with a bug in its 692061Sjkh # emulated serial port. It is not clear if EC2 still has any such 7017308Speter # nodes, but apply the workaround just in case. 712061Sjkh echo 'hw.broken_txfifo="1"' >> ${DESTDIR}/boot/loader.conf 722061Sjkh 732061Sjkh # Some EC2 instances suffer a significant (~40%) reduction in 742061Sjkh # throughput when using blkif indirect segment I/Os. Disable this 752061Sjkh # by default for now. 7630169Sjkh echo 'hw.xbd.xbd_enable_indirect="0"' >> ${DESTDIR}/boot/loader.conf 7730169Sjkh 782626Scsgr # The first time the AMI boots, the installed "first boot" scripts 792061Sjkh # should be allowed to run: 802061Sjkh # * ec2_configinit (download and process EC2 user-data) 812061Sjkh # * ec2_fetchkey (arrange for SSH using the EC2-provided public key) 822061Sjkh # * growfs (expand the filesystem to fill the provided disk) 832061Sjkh # * firstboot_freebsd_update (install critical updates) 842061Sjkh # * firstboot_pkgs (install packages) 8519320Sadam touch ${DESTDIR}/firstboot 862061Sjkh 872061Sjkh return 0 882061Sjkh} 892061Sjkh