Creating a TFM Vagrant Box from Scratch

tfm logoCreating a Vagrant box from a TFM/GNU Linux image tutorial. It’s an easy 10 step tutorial that will alow you to have a development box based on TFM/GNU Linux

1) Create a new Virtual Machine in VirtualBox

Type: Linux
Version: Linux (64-bit)
Memory Size: 2048MB
New Virtual Disk:
Type: VMDK (Dynamically allocated)
Max Size: 40GB

2) Modify Virtual Machine settings:

* Disable audio
* Disable USB
* Ensure Network Adapter 1 is set to NAT
* Mount the TFM Linux ISO

3) Add the vagrant group and user and set password to vagrant

groupadd vagrant
useradd -m -g vagrant
passwd vagrant

4) Modify /etc/sudoers

Defaults:vagrant !requiretty
#Defaults !visiblepw
Defaults env_keep = “SSH_AUTH_SOCK”

5) Add vagrant ssh key to allow logins

mkdir -p /home/vagrant/.ssh
chmod 0700 /home/vagrant/.ssh
wget –no-check-certificate \ \
-O /home/vagrant/.ssh/authorized_keys
chmod 0600 /home/vagrant/.ssh/authorized_keys
chown -R vagrant /home/vagrant/.ssh

6) modify /etc/ssd/sshd_config

Port 22
PubKeyAuthentication yes
AuthorizedKeysFile .ssh/authorized_keys
PermitEmptyPasswords no
PasswordAuthentication no

7) Install the Guest Tools for our VM package.
* From Virtualbox Install Guest Additions…
* from linux prompt:

mkdir /mnt/cdrom
mount /dev/cdrom /mnt/cdrom
umount /mnt/cdrom

8) Adjust the base settings of the configuration

echo “dhclient eth0” > /etc/init.d/local
echo “nameserver” >/etc/resolv.conf
ln -s /etc/init.d/local /etc/rc.d/rc3.d/S99local
ln -s /etc/init.d/vboxadd /etc/rc.d/rc3.d/S25vboxadd

9) Shutdown the TFM guest OS .

shutdown -h now

10) Pack and distribute the image

vagrant package –base vagrant-tfm

vagrant box add dev-new
vagrant init dev-new
vagrant up

So … Happy developing .

Some thoughts ( depending on what you want that machine for ):
– You will probably want to mount a local directory into VM
– You probably want to start nginx / mysql / php-fpm
– Maybe the you want to add the logs on the local machine …

Leave a Reply