22 C
Jaipur
Saturday, October 31, 2020

How To Install Vagrant On Linux

Must read

Best Buy Black Friday Sony WH-1000XM4 deals end tomorrow – hurry for lowest price yet on top headphones

Best Buy's first wave of Black Friday deals must come to an end tomorrow, which means this excellent price on the Sony WH-1000XM4 headphones...

toyota: Toyota to invest $500 million in KDDI to deepen ties for “connected car” – Latest News

Toyota Motor Corp and KDDI Corp said on Friday that Japan's biggest automaker would invest 52.2 billion yen ($500 million) in the mobile carrier...

This $299 laptop is one of the best Black Friday deals we’ve seen yet – but it ends tomorrow

Granted, we're only just getting started in this year's Black Friday laptop deals, but Best Buy's offerings this weekend are looking particularly sharp. One...

Can the Honor Watch ES smartwatch give a lazy person a six-pack? I found out

Many smartwatches come with a wide range of fitness modes, helping the wearer stay fit and active; however, for all the clever tech in...

In this tutorial, we will see how to install Vagrant on Linux operating systems. Installing Vagrant is quite easy! All you have to do is to head over the Vagrant downloads page, grab the suitable precompiled binary version for your Linux distribution and install it as the way you would normally install other applications. You can also install Vagrant from the default repositories. Here I have included all possible ways to install Vagrant on your Linux box.

Install Vagrant On Linux

Vagrant is available in the official repositories of most Linux and Unix distributions. So we can install vagrant using the default package managers.

For instance, run the following command to install Vagrant on Debian, Ubuntu, Linux Mint:

$ sudo apt install vagrant

On Fedora:

$ sudo dnf install vagrant

On SUSE/openSUSE:

$ sudo zypper install vagrant

The official versions in the repositories might be very outdated. If you want the most recent version, go to the official Vagrant downloads page and download the latest binary file for your Linux operating systems.

For instance, if you’re using Debian and other Debian-based systems such as Ubuntu, just download .deb version. As of writing this guide, the latest version was 2.2.9. It is available for both 32 bit and 64 bit architecture.

After downloading the .deb file, go to the download section and install it like below:

$ sudo apt install gdebi
$ sudo gdebi vagrant_2.2.9_x86_64.deb

Here, the reason I used “gdebi” is because it automatically installs the necessary dependencies.

If you have downloaded the .rpm file, you can install it using command:

$ sudo dnf localinstall vagrant_2.2.9_x86_64.rpm

Or,

$ sudo yum localinstall vagrant_2.2.9_x86_64.rpm

Install hypervisors

After installing Vagrant, you need to install any virtualization hypervisors, for example VirtualBox or KVM. Because, Vagrant is not a standalone virtualization software. It is just a wrapper and front-end for other virtualization applications. Vagrant is originally developed for VirtualBox. Since the version 1.1, the vagrant team extended its support for other popular virtualization software and server environments including Aws, Azure, GCE, Docker, KVM, Proxmox, Openstack, Openvz, VMware and lot more. You can view the complete list of supported providers/environments here.

For the purpose of this guide, I am going to use Oracle VirtualBox. Because, installing Virtualbox is easy and Vagrant uses VirtualBox as default provider.

To install VirtualBox on Debain, Ubuntu, Linux Mint, run the following command:

$ sudo apt install virtualbox

To install Virtualbox on Red Hat, CentOS, Fedora, run:

$ sudo dnf install virtualbox

To install Virtualbox on SUSE/openSUSE, run:

$ sudo zypper install virtualbox

If you prefer to use KVM, you can follow the below guides to install it.

Verify Vagrant installation

To verify if Vagrant is properly installed, simply run it without any options from the terminal:

$ vagrant

It will return the Vagrant help section.

Usage: vagrant [options] <command> [<args>]

    -h, --help                       Print this help.

Common commands:
     box             manages boxes: installation, removal, etc.
     cloud           manages everything related to Vagrant Cloud
     destroy         stops and deletes all traces of the vagrant machine
     global-status   outputs status Vagrant environments for this user
     halt            stops the vagrant machine
     help            shows the help for a subcommand
     init            initializes a new Vagrant environment by creating a Vagrantfile
     login           
     package         packages a running vagrant environment into a box
     plugin          manages plugins: install, uninstall, update, etc.
     port            displays information about guest port mappings
     powershell      connects to machine via powershell remoting
     provision       provisions the vagrant machine
     push            deploys code in this environment to a configured destination
     rdp             connects to machine via RDP
     reload          restarts vagrant machine, loads new Vagrantfile configuration
     resume          resume a suspended vagrant machine
     snapshot        manages snapshots: saving, restoring, etc.
     ssh             connects to machine via SSH
     ssh-config      outputs OpenSSH valid configuration to connect to the machine
     status          outputs status of the vagrant machine
     suspend         suspends the machine
     up              starts and provisions the vagrant environment
     upload          upload to machine via communicator
     validate        validates the Vagrantfile
     version         prints current and latest Vagrant version
     winrm           executes commands on a machine via WinRM
     winrm-config    outputs WinRM configuration to connect to the machine

For help on any individual command run `vagrant COMMAND -h`

Additional subcommands are available, but are either more advanced
or not commonly used. To see all subcommands, run the command
`vagrant list-commands`.
        --[no-]color                 Enable or disable color output
        --machine-readable           Enable machine readable output
    -v, --version                    Display Vagrant version
        --debug                      Enable debug output
        --timestamp                  Enable timestamps on log output
        --debug-timestamp            Enable debug output with timestamps
        --no-tty                     Enable non-interactive output

You can also -h or –help parameter to bring up the help section.

$ vagrant --help

[Or]

$ vagrant -h

To get help for individual commands, run:

$ vagrant <COMMAND-NAME> -h

To view Vagrant version, run:

$ vagrant version

It will return the currently installed version and latest available version.

Installed Version: 2.2.9
Latest Version: 2.2.9
 
You're running an up-to-date version of Vagrant!

Troubleshooting

If you run multiple hypervisors on the same host machine, you will probably be encountered with an error something like below when starting a VM:

There was an error while executing `VBoxManage`, a CLI used by Vagrant for controlling VirtualBox. The command and stderr is shown below.

Command: ["startvm", <ID of the VM>, "--type", "headless"]

Stderr: VBoxManage: error: VT-x is being used by another hypervisor (VERR_VMX_IN_VMX_ROOT_MODE).
VBoxManage: error: VirtualBox can't operate in VMX root mode. Please disable the KVM kernel extension, recompile your kernel and reboot
(VERR_VMX_IN_VMX_ROOT_MODE)
VBoxManage: error: Details: code NS_ERROR_FAILURE (0x80004005), component ConsoleWrap, interface IConsole

This error occurs because an another hypervisor, for example KVM, is currently in use. To fix this error, you may need to temporarily blocklist that hypervisor.

Find the KVM module using command:

$ lsmod | grep kvm

If you host system is Intel, you will get the following output:

kvm_intel             282624  0
kvm                   663552  1 kvm_intel

If it is AMD, you will get this instead:

kvm_intel             282624  0
kvm                   663552  1 kvm_amd

Now block the KVM module using command:

$ echo 'blacklist kvm-intel' >> /etc/modprobe.d/blacklist.conf

Type “kvm-amd” in the above command if your CPU is AMD.

Restart your system and then try again running Vagrant. This time VM will start without any issues.

That’s it. We have successfully installed Vagrant on Linux. In our forthcoming tutorials, we will see how to use Vagrant to setup a virtualized environment and how to create and manage the virtual machines using Vagrant.

Source link

- Advertisement -

More articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest article

Best Buy Black Friday Sony WH-1000XM4 deals end tomorrow – hurry for lowest price yet on top headphones

Best Buy's first wave of Black Friday deals must come to an end tomorrow, which means this excellent price on the Sony WH-1000XM4 headphones...

toyota: Toyota to invest $500 million in KDDI to deepen ties for “connected car” – Latest News

Toyota Motor Corp and KDDI Corp said on Friday that Japan's biggest automaker would invest 52.2 billion yen ($500 million) in the mobile carrier...

This $299 laptop is one of the best Black Friday deals we’ve seen yet – but it ends tomorrow

Granted, we're only just getting started in this year's Black Friday laptop deals, but Best Buy's offerings this weekend are looking particularly sharp. One...

Can the Honor Watch ES smartwatch give a lazy person a six-pack? I found out

Many smartwatches come with a wide range of fitness modes, helping the wearer stay fit and active; however, for all the clever tech in...

France vs Ireland live stream: how to watch Six Nations 2020 rugby anywhere today

We're expecting drama in abundance at the Stade de France tonight, with Ireland the only side who have their fate completely in their own hands...