Skip to content

Instantly share code, notes, and snippets.

@finnigja
Last active September 6, 2016 22:27
Show Gist options
  • Save finnigja/4b1401a622c4bcc52f872bdb5b07a402 to your computer and use it in GitHub Desktop.
Save finnigja/4b1401a622c4bcc52f872bdb5b07a402 to your computer and use it in GitHub Desktop.
Create and customize Vagrantfile, for example:
Vagrant.configure("2") do |config|
config.vm.guest = :freebsd
config.vm.synced_folder ".", "/vagrant", id: "vagrant-root", disabled: true
config.vm.box = "freebsd/FreeBSD-10.3-RELEASE"
config.ssh.shell = "sh"
config.vm.base_mac = "080027D15C66"
config.vm.provider :virtualbox do |vb|
vb.customize ["modifyvm", :id, "--memory", "2048"]
vb.customize ["modifyvm", :id, "--cpus", "2"]
vb.customize ["modifyvm", :id, "--hwvirtex", "on"]
vb.customize ["modifyvm", :id, "--audio", "none"]
vb.customize ["modifyvm", :id, "--nictype1", "virtio"]
vb.customize ["modifyvm", :id, "--nictype2", "virtio"]
end
end
Bring up the Vagrant box:
$ vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
default: Box 'freebsd/FreeBSD-10.3-RELEASE' could not be found. Attempting to find and install...
default: Box Provider: virtualbox
[... time passes while the image is download, VM is initialized, etc...]
Connect to the system, check OS version, and test network connectivity:
$ vagrant ssh
vagrant@:~ % uname -av
FreeBSD 10.3-RELEASE-p7 FreeBSD 10.3-RELEASE-p7 #0: Thu Aug 11 18:38:15 UTC 2016 root@amd64-builder.daemonology.net:/usr/obj/usr/src/sys/GENERIC amd64
vagrant@:~ % ping google.com
PING google.com (216.58.216.174): 56 data bytes
64 bytes from 216.58.216.174: icmp_seq=0 ttl=63 time=25.365 ms
64 bytes from 216.58.216.174: icmp_seq=1 ttl=63 time=23.409 ms
^C
--- google.com ping statistics ---
2 packets transmitted, 2 packets received, 0.0% packet loss
round-trip min/avg/max/stddev = 23.409/24.387/25.365/0.978 ms
Check for FreeBSD updates:
vagrant@:~ % sudo csh
root@:/home/vagrant # freebsd-update fetch
src component not installed, skipped
Looking up update.FreeBSD.org mirrors... 4 mirrors found.
Fetching metadata signature for 10.3-RELEASE from update6.freebsd.org... done.
[...]
Installing Software
===================
You have the option of installing software using packages (pre-compiled binaries) or ports (compile your own binaries). See https://www.freebsd.org/doc/en/articles/linux-users/software.html for more information.
Packages
--------
It's easy:
vagrant@:~ % su -
Password: vagrant
root@:~ # port install sudo
[..]
root@:~ # port install apache24
[..]
root@:~ # port update # check for package updates
Ports
-----
Initialize the ports collection with portsnap (https://www.freebsd.org/doc/handbook/ports-using.html):
vagrant@:~ % sudo csh
root@:/home/vagrant # portsnap fetch
[...]
root@:/home/vagrant # portsnap extract
[...]
root@:/home/vagrant # ls -al /usr/ports
total 72024
drwxr-xr-x 69 root wheel 1536 Sep 4 21:43 .
drwxr-xr-x 15 root wheel 512 Sep 4 21:41 ..
-rw-r--r-- 1 root wheel 115 Apr 21 04:33 .arcconfig
-rw-r--r-- 1 root wheel 898 Mar 24 12:47 .gitattributes
-rw-r--r-- 1 root wheel 71 Jan 2 2015 .gitignore
-rw-r--r-- 1 root wheel 2270292 Sep 4 21:43 .portsnap.INDEX
-rw-r--r-- 1 root wheel 112217 Aug 26 20:07 CHANGES
-rw-r--r-- 1 root wheel 314 Mar 15 2014 CONTRIBUTING.md
-rw-r--r-- 1 root wheel 1493 Dec 31 2015 COPYRIGHT
[...]
Check for updated ports:
root@:/home/vagrant # portsnap fetch update
[...]
Install a port, vim for example:
root@:/home/vagrant # cd /usr/ports/editors/vim-lite # don't make mistake of installing 'vim' with its many dependencies
root@:/usr/ports/editors/vim-lite # make install clean
[... follow the prompts ...]
Install a port with a number of dependencies, doing configuration prior to build/install to front-load interaction:
root@:/home/vagrant # cd /usr/ports/www/apache24
root@:/usr/ports/www/apache24 # make config-recursive
[... select various options ...]
[... repeat command until no output occurs ...]
root@:/usr/ports/www/apache24 # make install clean
[...]
[remember to add apache24_enable="YES" to /etc/rc.conf to enable service at system startup]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment