How to use Virtualbox smartly with Vagrant

Posted in tools, blogs on November 4, 2020 by Henk Verlinde ‐ 2 min read

How to use Virtualbox smartly with Vagrant

What is Virtualbox

A virtualization application that allows you to boot another guest OS on top of an existing host OS.

In simple terms, an application that allows you to start another PC on your PC.

As an advantage, you can use LinuxOS on Windows OS, and it has the following features.

  1. Snapshot function (backup)
  2. Seamless mode (concurrent work in host OS and guest OS)
  3. Shared folders (file sharing between host OS and guest OS)
  4. Clipboard sharing

What is Vagrant

It is a CLI tool that makes creating a guest OS (virtual environment) in Virtualbox easy, manageable, and easy to redistribute.

Install Virtualbox

Download and install VirtualBox from official site, virsion is 6.0.6

“C:\Program Files\Oracle\VirtualBox\VirtualBox.exe” which is installed in the following folder by default

Install Vagrant

Download and install Vagrant from official site virsion is 2.2.4

Check if it is installed with the following command (Git Bash)

user MINGW64 ~/
$ vagrant --version
Vagrant 2.2.4

Installing Vagrant Box

A Vagrant Box is a file that serves as a template for a virtual machine. When sharing with other companies, share the virtual environment based on this Box. As a test, install and use Vagrant Box in a CentOS environment built by others.

$ vagrant box add centos/7
==> box: Loading metadata for box 'centos/7'
    box: URL: https://vagrantcloud.com/centos/7
This box can work with multiple providers!
can work with are listed below.
the provider you will be working with.

1) hyperv
2) libvirt
3) virtualbox
4) vmware_desktop

Enter your choice: 3

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~

Start the virtual environment

Now let’s actually start Vagrant Box.

Create a working folder

user MINGW64 ~/
$ mkdir local
$ cd local

Create Vagrant configuration file

$ vagrant init centos/7

$ vagrant init centos/7
A `Vagrantfile` has been placed in this directory.
ready to `vagrant up` your first virtual environment!

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Check if the file was created

$ls
Vagrantfile

Start Virtualbox The virtual environment will be started as follows.

$ vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
===> default: Importing base box 'centos/7'...
===> default: Matching MAC address for NAT networking...


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~

connect to guest OS

Finally, let’s connect to the virtual environment! ! .

$ vagrant ssh
[vagrant@localhost ~]

that’s all. good job for today.