Vagrant - Creating a base box
Updated at 2015-04-01 06:38
This is a checklist for creating a custom Vagrant base box using VirtualBox.
- Download Ubuntu 14.04 64bit server image.
- Create virtual machine.
- Start with 512MB of memory and go higher if needed.
- Create dynamically resizing drive with a large maximum size.
- Use the downloaded server image.
- Use root password
vagrant
. Create user "vagrant" with password "vagrant". - Place Vagrant public SSH key to
~/.ssh/authorized_keys
# Make sure that `~/.ssh` is `0700`. # Make sure that `authorized_keys` is `0600`. mkdir -p /home/vagrant/.ssh chmod 0700 /home/vagrant/.ssh wget --no-check-certificate \ https://raw.github.com/mitchellh/vagrant/master/keys/vagrant.pub \ -O /home/vagrant/.ssh/authorized_keys chmod 0600 /home/vagrant/.ssh/authorized_keys chown -R vagrant /home/vagrant/.ssh
- Initial virtual machine must have:
- The first network interface (adapter 1) must be a NAT adapter.
- The MAC address of the first network interface, set by
config.vm.base_mac
. - Use SSH key from Vagrant git repo.
https://github.com/mitchellh/vagrant/tree/master/keys
- Add vagrant user to the list of sudoers.
/etc/sudoers.d/vagrant vagrant ALL=(ALL) NOPASSWD: ALL
- To keep SSH speedy, set UseDNS to
no
is SSH server configuration. - Install Guest Additions for folder sharing between host and slave.
sudo apt-get install linux-headers-generic build-essential dkms sudo apt-get install -y gcc build-essential linux-headers-server
- Disable audio, disable USB.
- Enable SSH authorized keys configuration.
sudo nano /etc/ssh/sshd_config AuthorizedKeysFile %h/.ssh/authorized_keys # uncomment sudo service ssh restart
- Package the virtual machine.
vagrant box add my-box /path/to/the/new.box vagrant init my-box vagrant up vagrant package --base my-virtual-machine-in-virtual-box