Table of Contents generated with DocToc
Quidquid latine dictum sit, altum viditur.
(Whatever is said in Latin sounds profound.)
I love FreeBSD but it's a lot of work to get it running correctly on Vagrant. That's a shame, because more people should experience the quality of FreeBSD, the convenience of jails and a modern filesystem like ZFS.
Well, now you can! With this Vagrant box you get a fully tuned, latest FreeBSD with ZFS by copying a single file.
Table of Contents
Simply copy the Vagrantfile from this repository to the project you want to run the VM from and you are done. The box will be downloaded for you.
The box comes with a cloned_interface with IP address which can be used for jails. The range 172.23.0.1/16 is already configured for you with a proxy by pf to have internet connectivity in a jail. To start a new jail, all you have to do is:
ezjail-admin install
ezjail-admin create example.com 'lo1|172.23.0.1'
ezjail-admin start example.com
# Jump inside the jail
ezjail-admin console example.com
If you want your jails started at boot, make sure to add ezjail_enable="YES"
to /etc/rc.conf
.
This is for people who want to have their own customized box, instead of the box I made for you with the scripts in this repository.
The FreeBSD boxes are built from the excellent mfsBSD site. Download either the 9.2 or 10.1 special edition ISO and create a new virtual machine.
Create a new Virtual Machine with the following settings:
- System -> Motherboard -> Hardware clock in UTC time
- System -> Acceleration -> VT/x/AMD-V
- System -> Acceleration -> Enable Nested Paging
- Storage -> Attach a .vdi disk (this one we can minimize later)
- Network -> Adapter 1 -> Attached to -> NAT
- Network -> Adapter 1 -> Advanced -> Adapter Type -> Paravirtualized Network (virtio-net)
- Network -> Adapter 2 -> Advanced -> Attached to -> Host-Only Adapter
- Network -> Adapter 2 -> Advanced -> Adapter Type -> Paravirtualized Network (virtio-net)
I would also recommend to disable all the things you are not using, such as audio and usb.
Attach the ISO as a CD and boot it. You can login with root
and password
mfsroot
. After logging in, start the base installation with:
mount_cd9660 /dev/cd0 /cdrom
zfsinstall -d /dev/ada0 -u /cdrom/10.0-RELEASE-amd64 -s 1G
When the installation is done, you can poweroff
and remove the CD from
boot order in the settings.
Boot into your clean FreeBSD installation. You can now run the
vagrant-installation.sh
script from this repository. This will install and
setup everything which is needed for Vagrant to run. First, login as root (no
password required).
Select your keyboard:
kbdmap
Get an IP adress:
dhclient vtnet0
Bootstrap pkg manager by typing:
pkg
Github recently switched to new SSLv1.2 certificates which requires you to install the latest certificates. You can do so by fetching them from my own repository:
fetch https://pkg.wunki.org/10_0-amd64-server-default/All/ca_root_nss-3.17.3_1.txz
pkg add ca_root_nss-3.15.3.1.txz
In your FreeBSD box, fetch the installation script:
fetch -o /tmp/vagrant-setup.sh https://raw.github.com/wunki/vagrant-freebsd/master/bin/vagrant-setup.sh
Run it:
cd /tmp
chmod +x vagrant-setup.sh
./vagrant-setup.sh
Before packaging, I would recommend trying to reduce the size of the disk a bit more. In Linux you can do:
VBoxManage modifyvdi <freebsd-virtual-machine>.vdi compact
You can now package the box by running the following on your local machine:
vagrant package --base <name-of-your-virtual-machine> --output <name-of-your-box>
You can find the TODO's in the TODO.org at the root of this repository.
I got lots of useful configuration from xironix freebsd builds.
The above is released under the BSD license -- who would have thought! Meaning, do whatever you want, but I would sure appreciate if you contribute any improvements back to this repository.