This repository contains a collection of tools and scripts to build FreeBSD
images using Packer
for a variety of target providers.
To use this set of Packer
templates, the following prerequisites is required:
Install a recent version of
Vagrant
(you're on your own for this one)Install a recent version of
Packer
:make install-packer
Install a recent version of
cfgt(1)
:make install-cfgt
Install one or more providers:
Vagrant
- VMware Fusion
8.5.7
or newer - VirtualBox
Important
If you are using VMware Fusion, VMware Fusion Pro is required in order to have headless booting of FreeBSD images. With VMware Fusion Pro, a new setting will appear under
Preferences
->Network
-> Uncheck theRequire authentication to enter promiscuous mode
box.The alternative is to add the following to your
Vagrantfile
:Vagrant.configure("2") do |config| # ... config.vm.provider "vmware_fusion" do |v| v.gui = true end # ... end
Install the
sudo
command aliases to enable NFS synced folders. OnmacOS
:make install-nfs-mac
Patch
Vagrant
:make patch-vagrant
Verify dependencies are correctly installed:
make verify
Optional:
reST
doc tools. Assumesvirtualenv(1)
andpip(1)
have been installed and are available inPATH
:make install-rst2pdf
See the
README.rst
in one of the top-level directories for details (e.g. 11/README, 12/README)To see the latest snapshot from a given release, run
show-latest.sh
with the version number you want (and optionally the architecture as the 2nd argument, defaults toamd64
):$ sh show-latest.sh 12.0 arch: amd64 checksum_url: https://download.FreeBSD.org/ftp/snapshots/ISO-IMAGES/12.0/CHECKSUM.SHA512-FreeBSD-12.0-CURRENT-amd64-20170526-r318945 iso_checksum: 8c76c3b4b7daf75bbaa100b3062a336a3df3a44d53bdce3912394e7c3512a4b51209fa27e857cec35a868725ca27e4c5b176159ccfe81252f25679b9bc059d98 iso_filename: FreeBSD-12.0-CURRENT-amd64-20170526-r318945-disc1.iso iso_url: https://download.FreeBSD.org/ftp/snapshots/ISO-IMAGES/12.0/FreeBSD-12.0-CURRENT-amd64-20170526-r318945-disc1.iso iso_version: 12.0 $ sh show-latest.sh 11.1 arch: amd64 checksum_url: https://download.FreeBSD.org/ftp/snapshots/ISO-IMAGES/11.1/CHECKSUM.SHA512-FreeBSD-11.1-PRERELEASE-amd64-20170525-r318893 iso_checksum: fa0467019f4b899f08b0567767597bb72c328cdeea131d1cd3d3cfc9971c1451c946a581a13fb37e19aadbd6dda925015c84e94578d585d252646da0ff3e715a iso_filename: FreeBSD-11.1-PRERELEASE-amd64-20170525-r318893-disc1.iso iso_url: https://download.FreeBSD.org/ftp/snapshots/ISO-IMAGES/11.1/FreeBSD-11.1-PRERELEASE-amd64-20170525-r318893-disc1.iso iso_version: 11.1 $ sh show-latest.sh 11.0 arch: amd64 checksum_url: https://download.FreeBSD.org/ftp/snapshots/ISO-IMAGES/11.0/CHECKSUM.SHA512-FreeBSD-11.0-STABLE-amd64-20170510-r318134 iso_checksum: 257d4fa23d4b0d6f3dbe5e1ffce2f834eecee92d2102911993346a663bd377037a10ca451bb4048eed67a4ed4fe3328b106eda647c5fb3a28414b6e306eb4a64 iso_filename: FreeBSD-11.0-STABLE-amd64-20170510-r318134-disc1.iso iso_url: https://download.FreeBSD.org/ftp/snapshots/ISO-IMAGES/11.0/FreeBSD-11.0-STABLE-amd64-20170510-r318134-disc1.iso iso_version: 11.0
- The VM is set to have 1024MB of RAM and a 20GB drive
- Vagrant NFS synced folders are enabled by
default and exported to the guest as
/local
. - EFI bootloader doesn't work
Install
sudo(8)
command specs for NFS shared folders:make install-nfs-mac
Vagrant NFS Shared Folders: There is a bug in Vagrant that prevents NFS shared folders from working. To apply a patch to work around this bug:
make patch-vagrant
Initialize Vagrant using:
vagrant init --minimal <box name>
Initialize Vagrant boxes using a specific
provider
and clean up if there's a failure:vagrant up --provider=vmware_fusion --destroy-on-error
Start the Vagrant VM:
vagrant up
Connect to the VM:
vagrant ssh
Hack away
Tip
cd /local
assuming NFS synced folders is workingSuspend the Vagrant VM:
vagrant suspend
Destroy a suspended VM:
vagrant destroy
See all images:
vagrant global-status
Packer
config files are written using JSON5 and translated to regular JSON usingcfgt(1)
.To change the provider used to build an image, pass PROVIDER=<MY_PROVIDER_NAME> Defaults to
vmware-iso
butvirtualbox
,parallels
,triton
, and others may work for a given template.Packer
may fail because thebsdinstall
menus have changed when building a-CURRENT
or-STABLE
image. To identify and fix this, pass in a populatedEXTRA_OPTS
variable to GNUmake(1)
:make 11.1-20170519-zfs TARGET=vmware-iso EXTRA_OPTS="-var headless=false -debug"
(and submit a patch fixing the menu change).
If
Packer
fails to connect via SSH to the instance to do the post-install it is possible there are too many SSH keys loaded in your agent. Prefix your GNUmake(1)
command with env SSH_AUTH_SOCK=/dev/null ... or look at the output fromssh-add -l
to see if you have more than 3x keys loaded.Joyent maintains a branch of Packer that supports native JSON5 (
f-json5
). It periodically lags behindmaster
but should be reasonably up to date.
Patches welcome! Specifically, as new snapshots or releases are made, please feel free to submit PRs.