Ubuntu 16.04 freezes on vagrant up
So, I had the same problem freezing at booting VM
using Ubuntu 16.04 LTS.
And to solve this in some steps with a lot of hard resets - I've updated to Vagrant 2.0.1 and VirtualBox 5.2.
Check what versions you have:
vagrant -v
(opened the GUI: Help --> About)virtualbox -v
Vagrant
- Remove old
index
andindex.lock
files in folder/home/USER/.vagrant.d/data/machine-index/
- Download Vagrant 2.0.1 https://www.vagrantup.com/downloads.html
- install package
sudo dpkg -i vagrant_2.0.1_x86_64.deb
Virtualbox
Remove the current virtualbox
- run
sudo apt-get purge virtualbox*
to remove all files - Check if anything is left
dpkg -l | grep virtualbox
- (I had to) remove
sudo apt-get purge unity-scope-virtualbox
Add repository for Virtualbox (use apt to install)
sudo nano /etc/apt/sources.list
- Add the line
deb https://download.virtualbox.org/virtualbox/debian xenial contrib
- Add key
wget -q https://www.virtualbox.org/download/oracle_vbox_2016.asc -O- | sudo apt-key add -
sudo apt-get update
Install latest virtualbox
- run
sudo apt-get install virtualbox-5.2
- run
sudo /sbin/vboxconfig
to rebuild the settings
Issues I had
You probably need to destroy your box and build again.
Vagrant user issue
The VirtualBox VM was created with a user that doesn't match the
current user running Vagrant. VirtualBox requires that the same user
be used to manage the VM that was created. Please re-run Vagrant with
that user. This is not a Vagrant issue.
Removed the .vagrant folder rm -rf .vagrant
to solve that.
Duplicated VM names issue
The name of your virtual machine couldn't be set because VirtualBox
is reporting another VM with that name already exists. Most of the
time, this is because of an error with VirtualBox not cleaning up
properly. To fix this, verify that no VMs with that name do exist
(by opening the VirtualBox GUI). If they don't, then look at the
folder in the error message from VirtualBox below and remove it
if there isn't any information you need in there.
I had issues with duplicated Virtualbox names as VBoxManage: error: Could not rename the directory
error prevented vagrant up
from finishing. Just removed the folders in my Virtualbox VMs folder and through the GUI.
Machine index issue
This is what started my adventure and got me here from Googling.
The machine index which stores all required information about
running Vagrant environments has become corrupt. This is usually
caused by external tampering of the Vagrant data folder.
Vagrant cannot manage any Vagrant environments if the index is
corrupt. Please attempt to manually correct it. If you are unable
to manually correct it, then remove the data file at the path below.
This will leave all existing Vagrant environments "orphaned" and
they'll have to be destroyed manually.
After a while updating Vagrant to 2.0.1 and VirtualBox to 5.2, it solved the problem for me.
I was using Vagrant 1.9.4 and VirtualBox 5.0.
Basically, you need to upgrade the Virtualbox and Vagrant version.
Vagrant is easy to update (I updated to 2.0.1)
Here is how I updated the Virtualbox(more or less) to 5.1:
sudo apt remove virtualbox-X.X
sudo apt-get purge virtualbox-X.X virtualbox-qt virtualbox-dkms
Now, install the Virtualbox(it's important to install with apt)
sudo apt-get install virtualbox-5.1
sudo /sbin/vboxconfig
sudo apt-get install software-properties-common
sudo apt-add-repository ppa:ansible/ansible
sudo apt-get update
sudo apt-get install ansible
vagrant plugin install vagrant-vbguest
vagrant plugin install vagrant-hostsupdater
Restart and build your VM again
PS: Never build vagrant with sudo