Skip to content

Instantly share code, notes, and snippets.

@neofob
Last active December 14, 2015 15:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save neofob/5111499 to your computer and use it in GitHub Desktop.
Save neofob/5111499 to your computer and use it in GitHub Desktop.
issue with vagrant on Debian Wheezy
all: vagrant-note.html vagrant-base.html
vagrant-note.html: vagrant-note.md
maruku --html --output vagrant-note.html vagrant-note.md
vagrant-base.html: vagrant-base.md
maruku --html --output vagrant-base.html vagrant-base.md

Setting up a vagrant base box from scratch

Setting up a vagrant base box consists of two steps:

  • Setting up virtual machine in virtualbox
  • Packaging the virtual machine to the .box file

Setting up virtual machine in virtualbox:

  • Install/remove packages that you want

  • Install vim and set it to default editor (personal reference)
    # apt-get -y install vim && update-alternatives --config editor

  • Setup tmpfs for /tmp and /var/log (personal reference)
    # echo "tmpfs /tmp tmpfs defaults 0 0" >> /etc/fstab
    # echo "tmpfs /var/log tmpfs defaults 0 0" >> /etc/fstab

  • Create accounts for vagrant
    # groupadd admin
    # mkdir /home/vagrant
    # useradd -G admin -d /home/vagrant -s /bin/bash vagrant
    # usermod -G admin vagrant

  • Edit sudoers so everyone can sudo with visudo so we have these lines
    Defaults env_keep="SSH_AUTH_SOCK"
    %admin ALL=NOPASSWD: ALL

  • Install VirtualBox Linux Addition (Devices->Install Guest Additions)
    # apt-get install linux-headers-$(uname -r) build-essential dkms
    # mkdir /mnt/cdrom
    # mount /dev/cdrom /mnt/cdrom
    # /mnt/cdrom/VBoxLinuxAdditions.run

  • If you want to use your own key then cp your ~/.ssh/id_rsa of the host that you will launch vagrant VMs to ~/.vagrant.d/insecure_private_key and ~/.ssh/id_rsa.pub to ~/.ssh/authorized_keys of vagrant account in VM.

  • If you use the default vagrant insecure_private_key at $HOME/.vagrant.d then you need to use the vagrant public key.
    vagrant$ mkdir .ssh && cd .ssh
    vagrant$ wget http://github.com/mitchellh/vagrant/raw/master/keys/vagrant.pub
    vagrant$ mv vagrant.pub authorized_keys

  • SSH Tweak from docs.vagrantup.com
    # echo "UseDNS no" >> /etc/ssh/sshd_config

  • Clean up cache and system packages
    # apt-get autoclean && apt-get autoremove

  • Remove logs of the virtual machine at host machine:
    $rm $HOME/VirtualBox\ VMs/DebianWheezy64/Logs/*

Packaging the virtual machine to .box file:

  • Change CWD
    $ cd /path/to/VirtualBox\ VMs/DebianWheezy64

  • If you have a lot of RAM, use /tmp with tmpfs. Notice the name after --base must be the same name of your VM that you are using with VirtualBox.
    $ time vagrant package --base DebianWheezy64 --output /tmp/DebianWheezy64.box
    This should take less than 3 minutes if you have SSD and plenty of memory.

References:
Creating a vagrant base box for ubuntu 12.04 32bit server
How I setup Ubuntu 11.04 Server using VirtualBox on a MacBook Air
Base Boxes
Creating base box from scratch for Vagrant

Disable Firewall in Debian:
Stop firewall in Debian
Debian Firewall

Setting up vagrant 1.0.6

Debian Wheezy

$getconf GNU_LIBC_VERSION
glibc 2.13

When you install vagrant 1.0.6 deb package file, vagrant has its own ruby 1.9.1 in /opt/vagrant/embedded directory. This ruby requires glibc 2.14 or later. You should edit the last line from

${EMBEDDED_DIR}/bin/ruby ${VAGRANT_EXECUTABLE} "$@"

to

ruby ${VAGRANT_EXECUTABLE} "$@"

to use the system ruby version.

Ubuntu 12.04.2

$getconf GNU_LIBC_VERSION
glibc 2.15

Installing from .deb file works.

URLs:

Author: Tuan T. Pham

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment