├── .gitignore ├── LICENSE ├── README.md ├── TODO.org ├── Vagrantfile ├── bin └── vagrant-setup.sh ├── boot └── loader.conf ├── etc ├── make.conf ├── motd ├── pf.conf ├── rc.conf └── resolv.conf └── pkg ├── bash-4.3.42.txz ├── ca_root_nss-3.20.txz ├── indexinfo-0.2.3.txz ├── iocage-1.7.3.txz ├── pkg-1.5.6.txz ├── sudo-1.8.14p3.txz └── virtualbox-ose-additions-4.3.30.txz /.gitignore: -------------------------------------------------------------------------------- 1 | .*.sw? 2 | .vagrant/ 3 | *.box 4 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) Petar Radosevic and individual contributors. 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without modification, 5 | are permitted provided that the following conditions are met: 6 | 7 | 1. Redistributions of source code must retain the above copyright notice, 8 | this list of conditions and the following disclaimer. 9 | 10 | 2. Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | 14 | 3. Neither the name of Django nor the names of its contributors may be used 15 | to endorse or promote products derived from this software without 16 | specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 19 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 20 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 21 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 22 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 23 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 24 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 25 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 27 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Freebsd on Vagrant 2 | 3 | 4 | 5 | > Quidquid latine dictum sit, altum viditur. 6 | > 7 | > _(Whatever is said in Latin sounds profound.)_ 8 | 9 | I love [FreeBSD] but it's a lot of work to get it running correctly on 10 | [Vagrant]. That's a shame, because more people should experience the quality of 11 | FreeBSD, the convenience of [jails] and a modern filesystem like [ZFS]. 12 | 13 | Well, now you can! With this Vagrant box you get a fully tuned, latest FreeBSD 14 | with ZFS by copying a single file. 15 | 16 | **Table of Contents** 17 | 18 | - [Freebsd on Vagrant](#freebsd-on-vagrant) 19 | - [Quickstart](#quickstart) 20 | - [Jails](#jails) 21 | - [Create your own FreeBSD Box](#create-your-own-freebsd-box) 22 | - [Virtualbox Settings](#virtualbox-settings) 23 | - [Installation from mfsBSD ISO](#installation-from-mfsbsd-iso) 24 | - [Configuration](#configuration) 25 | - [Package for Vagrant](#package-for-vagrant) 26 | - [What's Next?](#whats-next) 27 | - [Credits](#credits) 28 | - [License](#license) 29 | 30 | ## Quickstart 31 | 32 | Simply copy the [Vagrantfile] from this repository to the project you want to 33 | run the VM from and you are done. The box will be downloaded for you. 34 | 35 | ## Jails 36 | 37 | The box comes with a *cloned_interface* with IP address which can be used for 38 | jails. The range 172.23.0.1/16 is already configured for you with a proxy by 39 | pf to have internet connectivity in a jail. To start a new jail, all you have 40 | to do is: 41 | 42 | ezjail-admin install 43 | ezjail-admin create example.com 'lo1|172.23.0.1' 44 | ezjail-admin start example.com 45 | 46 | # Jump inside the jail 47 | ezjail-admin console example.com 48 | 49 | If you want your jails started at boot, make sure to add `ezjail_enable="YES"` 50 | to `/etc/rc.conf`. 51 | 52 | ## Create your own FreeBSD Box 53 | 54 | This is for people who want to have their own customized box, instead of the 55 | box I made for you with the scripts in this repository. 56 | 57 | The FreeBSD boxes are built from the excellent [mfsBSD] site. Download the 58 | 10.2 special edition ISO and create a new virtual machine. 59 | 60 | ### Virtualbox Settings 61 | 62 | Create a new Virtual Machine (minimal 1024MB Memory) with the following settings: 63 | 64 | - System -> Motherboard -> **Hardware clock in UTC time** 65 | - System -> Acceleration -> **VT/x/AMD-V** 66 | - System -> Acceleration -> **Enable Nested Paging** 67 | - Storage -> Attach a **.vdi** disk (this one we can minimize later) 68 | - Network -> Adapter 1 -> Attached to -> NAT 69 | - Network -> Adapter 1 -> Advanced -> Adapter Type -> **Paravirtualized Network (virtio-net)** 70 | - Network -> Adapter 2 -> Advanced -> Attached to -> **Host-Only Adapter** 71 | - Network -> Adapter 2 -> Advanced -> Adapter Type -> **Paravirtualized Network (virtio-net)** 72 | 73 | I would also recommend to disable all the things you are not using, such as 74 | *audio* and *usb*. 75 | 76 | ### Installation from mfsBSD ISO 77 | 78 | Attach the ISO as a CD and boot it. You can login with `root` and password 79 | `mfsroot`. After logging in, start the base installation with: 80 | 81 | mkdir /cdrom 82 | mount_cd9660 /dev/cd0 /cdrom 83 | zfsinstall -d /dev/ada0 -u /cdrom/10.2-RELEASE-amd64 -p zroot -s 1G 84 | 85 | When the installation is done, you can `poweroff` and **remove the CD from 86 | boot order in the settings.** 87 | 88 | ### Configuration 89 | 90 | Boot into your clean FreeBSD installation. You can now run the 91 | `vagrant-installation.sh` script from this repository. This will install and 92 | setup everything which is needed for Vagrant to run. First, login as root (no 93 | password required). 94 | 95 | Select your keyboard: 96 | 97 | kbdmap 98 | 99 | Get an IP adress: 100 | 101 | dhclient vtnet0 102 | 103 | Bootstrap pkg manager by typing: 104 | 105 | pkg 106 | 107 | [Github recently switched to new SSLv1.2 certificates] which requires you to 108 | install the latest certificates. You can do so by fetching them from my own 109 | repository: 110 | 111 | fetch --no-verify-peer https://raw.github.com/wunki/vagrant-freebsd/master/pkg/ca_root_nss-3.20.txz 112 | pkg add ca_root_nss-3.20.txz 113 | 114 | In your FreeBSD box, fetch the installation script: 115 | 116 | fetch -o /tmp/vagrant-setup.sh https://raw.github.com/wunki/vagrant-freebsd/master/bin/vagrant-setup.sh 117 | 118 | Run it: 119 | 120 | cd /tmp 121 | chmod +x vagrant-setup.sh 122 | ./vagrant-setup.sh 123 | 124 | ### Package for Vagrant 125 | 126 | Before packaging, I would recommend trying to reduce the size of the disk a 127 | bit more. In Linux you can do: 128 | 129 | VBoxManage modifyvdi .vdi compact 130 | 131 | You can now package the box by running the following on your local machine: 132 | 133 | vagrant package --base --output 134 | 135 | ## What's Next? 136 | 137 | You can find the TODO's in the [TODO.org] at the root of this repository. 138 | 139 | ## Credits 140 | 141 | I got lots of useful configuration from [xironix freebsd] builds. 142 | 143 | ## License 144 | 145 | The above is released under the BSD license -- who would have thought! 146 | Meaning, do whatever you want, but I would sure appreciate if you contribute 147 | any improvements back to this repository. 148 | 149 | [FreeBSD]: http://www.freebsd.org/ 150 | [Vagrant]: http://www.vagrantup.com/ 151 | [jails]: http://www.freebsd.org/doc/handbook/jails.html 152 | [ZFS]: http://en.wikipedia.org/wiki/ZFS 153 | [Vagrantfile]: https://github.com/wunki/vagrant-freebsd/blob/master/Vagrantfile 154 | [mfsBSD]: http://mfsbsd.vx.sk/ 155 | [9.2-RELEASE-amd64 special edition]: http://mfsbsd.vx.sk/ 156 | [TODO.org]: https://github.com/wunki/vagrant-freebsd/blob/master/TODO.org 157 | [xironix freebsd]: https://github.com/xironix/freebsd-vagrant 158 | [Github recently switched to new SSLv1.2 certificates]: https://github.com/blog/1734-improving-our-ssl-setup 159 | -------------------------------------------------------------------------------- /TODO.org: -------------------------------------------------------------------------------- 1 | * FreeBSD on Vagrant 2 | ** DONE Restore the pkg configuration to default 3 | CLOSED: [2013-10-26 Sat 11:47] 4 | - State "DONE" from "TODO" [2013-10-26 Sat 11:47] 5 | We are setting the pkg site to the wunki server. This should be restored to 6 | default. 7 | ** DONE Don't show the boot menu 8 | CLOSED: [2013-10-25 Fri 13:13] 9 | - State "DONE" from "TODO" [2013-10-25 Fri 13:13] 10 | The boot menu takes ten seconds to show, that's just a waste of time in a 11 | headless VM. 12 | ** DONE Cleanup pkg's after installation 13 | CLOSED: [2013-10-25 Fri 13:39] 14 | - State "DONE" from "TODO" [2013-10-25 Fri 13:39] 15 | Clean the package cache because it saves some space. 16 | ** DONE Destroy all history 17 | CLOSED: [2013-10-25 Fri 13:35] 18 | - State "DONE" from "TODO" [2013-10-25 Fri 13:35] 19 | Destroy all the shell history. 20 | ** DONE Minimize disk space 21 | CLOSED: [2013-10-25 Fri 13:45] 22 | - State "DONE" from "TODO" [2013-10-25 Fri 13:45] 23 | =dd= all the empty space and remove it again. This also saves space when 24 | packaging the box. 25 | ** DONE Edit the MOTD (/etc/motd) 26 | CLOSED: [2013-10-25 Fri 13:20] 27 | - State "DONE" from "TODO" [2013-10-25 Fri 13:20] 28 | Add a pretty MOTD. 29 | ** DONE Document Virtualbox settings 30 | CLOSED: [2013-10-25 Fri 20:17] 31 | - State "DONE" from "TODO" [2013-10-25 Fri 20:17] 32 | Virtualbox needs some specific settings to boot a FreeBSD ISO. Add that 33 | information to the README so people can start from scratch on their own. 34 | ** DONE Upload the box Vagrantbox.es 35 | CLOSED: [2013-10-25 Fri 20:18] 36 | - State "DONE" from "TODO" [2013-10-25 Fri 20:18] 37 | Add the box to Vagrantbox.es to spread the reach of the most awesome operating 38 | system out there. 39 | -------------------------------------------------------------------------------- /Vagrantfile: -------------------------------------------------------------------------------- 1 | # -*- mode: ruby; -*- 2 | 3 | # Force Virtualbox for those people who have installed vagrant-lxc (e.g.) 4 | ENV['VAGRANT_DEFAULT_PROVIDER'] = 'virtualbox' 5 | 6 | Vagrant.configure("2") do |config| 7 | config.vm.guest = :freebsd 8 | config.vm.network "private_network", ip: "10.0.1.10" 9 | 10 | # Use NFS as a shared folder 11 | config.vm.synced_folder ".", "/vagrant", :nfs => true, id: "vagrant-root" 12 | 13 | config.vm.provider :virtualbox do |vb, override| 14 | override.vm.box_url = "https://wunki.org/files/freebsd-10.2-amd64-wunki.box" 15 | override.vm.box = "freebsd-10.2-amd64-wunki" 16 | 17 | # vb.customize ["startvm", :id, "--type", "gui"] 18 | vb.customize ["modifyvm", :id, "--memory", "512"] 19 | vb.customize ["modifyvm", :id, "--cpus", "2"] 20 | vb.customize ["modifyvm", :id, "--hwvirtex", "on"] 21 | vb.customize ["modifyvm", :id, "--audio", "none"] 22 | vb.customize ["modifyvm", :id, "--nictype1", "virtio"] 23 | vb.customize ["modifyvm", :id, "--nictype2", "virtio"] 24 | end 25 | end 26 | -------------------------------------------------------------------------------- /bin/vagrant-setup.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | ################################################################################ 3 | # CONFIG 4 | ################################################################################ 5 | 6 | # Packages which are pre-installed 7 | INSTALLED_PACKAGES="pkg-1.5.6 indexinfo-0.2.3 ca_root_nss-3.20 virtualbox-ose-additions-4.3.30 bash-4.3.42 sudo-1.8.14p3 iocage-1.7.3" 8 | 9 | # Configuration files 10 | MAKE_CONF="https://raw.github.com/wunki/vagrant-freebsd/master/etc/make.conf" 11 | RC_CONF="https://raw.github.com/wunki/vagrant-freebsd/master/etc/rc.conf" 12 | RESOLV_CONF="https://raw.github.com/wunki/vagrant-freebsd/master/etc/resolv.conf" 13 | LOADER_CONF="https://raw.github.com/wunki/vagrant-freebsd/master/boot/loader.conf" 14 | PF_CONF="https://raw.github.com/wunki/vagrant-freebsd/master/etc/pf.conf" 15 | 16 | # Message of the day 17 | MOTD="https://raw.github.com/wunki/vagrant-freebsd/master/etc/motd" 18 | 19 | # Private key of Vagrant (you probable don't want to change this) 20 | VAGRANT_PRIVATE_KEY="https://raw.github.com/mitchellh/vagrant/master/keys/vagrant.pub" 21 | 22 | ################################################################################ 23 | # PACKAGE INSTALLATION 24 | ################################################################################ 25 | 26 | mkdir /tmp/pkg 27 | cd /tmp/pkg 28 | 29 | # Install required packages 30 | for p in $INSTALLED_PACKAGES; do 31 | fetch -o /tmp/pkg/$p.txz https://raw.github.com/wunki/vagrant-freebsd/master/pkg/$p.txz 32 | done 33 | 34 | for p in $INSTALLED_PACKAGES; do 35 | pkg add /tmp/pkg/$p.txz 36 | done 37 | 38 | ################################################################################ 39 | # Configuration 40 | ################################################################################ 41 | 42 | # Create the vagrant user 43 | pw useradd -n vagrant -s /usr/local/bin/bash -m -G wheel -h 0 <> /usr/local/etc/sudoers 49 | 50 | # Authorize vagrant to login without a key 51 | mkdir /home/vagrant/.ssh 52 | touch /home/vagrant/.ssh/authorized_keys 53 | chown vagrant:vagrant /home/vagrant/.ssh 54 | 55 | # Get the public key and save it in the `authorized_keys` 56 | fetch -o /home/vagrant/.ssh/authorized_keys $VAGRANT_PRIVATE_KEY 57 | chown vagrant:vagrant /home/vagrant/.ssh/authorized_keys 58 | 59 | # make.conf 60 | fetch -o /etc/make.conf $MAKE_CONF 61 | 62 | # rc.conf 63 | fetch -o /etc/rc.conf $RC_CONF 64 | 65 | # resolv.conf 66 | fetch -o /etc/resolv.conf $RESOLV_CONF 67 | 68 | # loader.conf 69 | fetch -o /boot/loader.conf $LOADER_CONF 70 | 71 | # motd 72 | fetch -o /etc/motd $MOTD 73 | 74 | # pf 75 | fetch -o /etc/pf.conf $PF_CONF 76 | 77 | 78 | ################################################################################ 79 | # CLEANUP 80 | ################################################################################ 81 | 82 | # Remove packages 83 | rm -rf /tmp/pkg 84 | 85 | # Remove the history 86 | cat /dev/null > /root/.history 87 | 88 | # Try to make it even smaller 89 | while true; do 90 | read -p "Would you like me to zero out all data to reduce box size? [y/N] " yn 91 | case $yn in 92 | [Yy]* ) dd if=/dev/zero of=/tmp/ZEROES bs=1M; break;; 93 | [Nn]* ) break;; 94 | * ) echo "Please answer yes or no.";; 95 | esac 96 | done 97 | 98 | # Empty out tmp directory 99 | rm -rf /tmp/* 100 | 101 | # DONE! 102 | echo "We are all done. Poweroff the box and package it up with Vagrant." 103 | -------------------------------------------------------------------------------- /boot/loader.conf: -------------------------------------------------------------------------------- 1 | # don't show the boot menu 2 | beastie_disable="YES" 3 | autoboot_delay="-1" 4 | 5 | # boot from ZFS 6 | zfs_load="YES" 7 | vfs.root.mountfrom="zfs:zroot/root" 8 | 9 | # tune ZFS 10 | vm.kmem_size="200M" 11 | vm.kmem_size_max="200M" 12 | vfs.zfs.arc_max="40M" 13 | vfs.zfs.vdev.cache.size="5M" 14 | 15 | # Virtio Kernel Modules 16 | virtio_load="YES" 17 | virtio_pci_load="YES" 18 | -------------------------------------------------------------------------------- /etc/make.conf: -------------------------------------------------------------------------------- 1 | # Stuff we don't need for a headless VM 2 | WITHOUT_BLUETOOTH= YES 3 | WITHOUT_FLOPPY= YES 4 | WITHOUT_GAMES= YES 5 | WITHOUT_USB= YES 6 | WITHOUT_WIRELESS= YES 7 | WITHOUT_WPA_SUPPLICANT_EAPOL= YES 8 | WITHOUT_X11= YES 9 | WITHOUT_GUI= YES 10 | WITHOUT_NTP= YES # time sync is handled by VirtualBox 11 | WITHOUT_CUPS= YES 12 | -------------------------------------------------------------------------------- /etc/motd: -------------------------------------------------------------------------------- 1 | _ _ 2 | __ ___ _ _ __ | | _(_) ___ _ __ __ _ 3 | \ \ /\ / / | | | '_ \| |/ / | / _ \| '__/ _` | 4 | \ V V /| |_| | | | | <| || (_) | | | (_| | 5 | \_/\_/ \__,_|_| |_|_|\_\_(_)___/|_| \__, | 6 | |___/ 7 | 8 | Email: petar@wunki.org 9 | Twitter: @wunki 10 | 11 | Tip of the day: 12 | -------------------------------------------------------------------------------- 13 | -------------------------------------------------------------------------------- /etc/pf.conf: -------------------------------------------------------------------------------- 1 | # Interfaces 2 | ext_if = "em0" 3 | int_if = "lo1" 4 | 5 | jail_net = $int_if:network 6 | 7 | # NAT 8 | set skip on lo1 9 | nat pass on $ext_if from $jail_net to any -> $ext_if -------------------------------------------------------------------------------- /etc/rc.conf: -------------------------------------------------------------------------------- 1 | # Set dumpdev to "AUTO" to enable crash dumps, "NO" to disable 2 | dumpdev="NO" 3 | 4 | # Networking 5 | hostname=vagrant-freebsd-10 6 | ifconfig_vtnet0_name="em0" 7 | ifconfig_vtnet1_name="em1" 8 | ifconfig_em0="DHCP" 9 | 10 | # Aliases for jails 11 | cloned_interfaces="lo1" 12 | ipv4_addrs_lo1="172.23.0.1/16" 13 | 14 | # Firewall 15 | pf_rules="/etc/pf.conf" 16 | pf_enable="YES" 17 | 18 | # ZFS 19 | zfs_enable="YES" 20 | 21 | # SSH 22 | sshd_enable="YES" 23 | 24 | # Virtualbox 25 | vboxguest_enable="YES" 26 | vboxservice_enable="YES" 27 | 28 | # NFS 29 | rpcbind_enable="YES" 30 | nfs_client_enable="YES" 31 | 32 | # fsck to protect against unclean shutdowns 33 | fsck_y_enable="YES" 34 | -------------------------------------------------------------------------------- /etc/resolv.conf: -------------------------------------------------------------------------------- 1 | search vagrant-freebsd-10 2 | nameserver 8.8.8.8 3 | nameserver 8.8.4.4 -------------------------------------------------------------------------------- /pkg/bash-4.3.42.txz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wunki/vagrant-freebsd/5eef726846ac2cade444732ad51340a47a61434e/pkg/bash-4.3.42.txz -------------------------------------------------------------------------------- /pkg/ca_root_nss-3.20.txz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wunki/vagrant-freebsd/5eef726846ac2cade444732ad51340a47a61434e/pkg/ca_root_nss-3.20.txz -------------------------------------------------------------------------------- /pkg/indexinfo-0.2.3.txz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wunki/vagrant-freebsd/5eef726846ac2cade444732ad51340a47a61434e/pkg/indexinfo-0.2.3.txz -------------------------------------------------------------------------------- /pkg/iocage-1.7.3.txz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wunki/vagrant-freebsd/5eef726846ac2cade444732ad51340a47a61434e/pkg/iocage-1.7.3.txz -------------------------------------------------------------------------------- /pkg/pkg-1.5.6.txz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wunki/vagrant-freebsd/5eef726846ac2cade444732ad51340a47a61434e/pkg/pkg-1.5.6.txz -------------------------------------------------------------------------------- /pkg/sudo-1.8.14p3.txz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wunki/vagrant-freebsd/5eef726846ac2cade444732ad51340a47a61434e/pkg/sudo-1.8.14p3.txz -------------------------------------------------------------------------------- /pkg/virtualbox-ose-additions-4.3.30.txz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wunki/vagrant-freebsd/5eef726846ac2cade444732ad51340a47a61434e/pkg/virtualbox-ose-additions-4.3.30.txz --------------------------------------------------------------------------------