Vagrant: troubleshooting

From wikinotes

manual box install

Occasionally in the past, the vagrant website was too busy, or had incorrect redirects. If you can find the box, you can add it manually.

cd ~/.vagrant.d/boxes/                           # location boxes are stored
vagrant box add yourfile.box  --name "centos/7"  # import a box as name

resize vagrant Box

Grow Disk Image

cd ~/.vagrant.d/boxes/{box}/{date}/virtualbox

# backup previous image
cp vagrant.vmdk vagrant.vmdk.old

# clone .vmdk to .vdi (which can be resized)
VBoxManage clonehd "vagrant.vmdk" "vagrant.vdi" --format vdi

# resize copy
VBoxManage modifyhd "vagrant.vdi"

# replace vmdk
VBoxManage clonehd "vagrant.vdi" "vagrant.vmdk" --format vmdk

Resize Partition/Filesystem within Image

# You shouldn't do this while the filesystem is mounted

# grow partition
gpart resize -i -s 47G -a 4k ada0

# grow filesystem
growfs /dev/ada0p2

resize vagrant VM

Host

cd ~/VirtualBox VMs/<vagrant box>
VBoxManage clonehd   in.vmdk   out.vdi   --format VDI  # C:\Program Files\Oracle\VirtualBox\VBoxManage.exe
VBoxManage modifyhd box.vdi --resize 40960             # (1024M * 40GB)

VirtualBox

<box> > settings:
    storage > Controller: SATA:
         rclidk > Add Hard Drive:
             choose existing: out.vdi

# also remove original

Guest

sudo cfdisk             # use cfdisk to resize disk

vagrant ssh fails

SSH problems when using vagrant are an enormous pain because they prevent you from having a fully functional vagrant setup, and testing it means constantly rebuilding your VM. Here are some of the issues that I have encountered:

  • make sure that ~/.ssh has the permissions 700.

vboxsf missing

When attempting to create the virtualbox shared-folders, if it is unable to create the share, an error will be thrown about this.

Common Culprits:

  • virtualbox-guest-additions are not installed in the guest (generally an installable package)
  • the user 'vagrant' does not exist in the box.