Vagrant Introduction (Windows 11)

“In the early days of the personal computer, there were many choices of operating system; today, there are many solutions available to choose from for a virtualization strategy.”

Matthew Portnoy, Virtualization Essentials, https://www.goodreads.com/book/show/13838455-virtualization-essentials

Vagrant logo

Image Credit: Wikipedia

According to Wikipedia Vagrant (software) is:

Vagrant is a source-available software product for building and maintaining portable virtual software development environments; e.g., for VirtualBoxKVMHyper-VDocker containersVMwareParallels, and AWS. It tries to simplify the software configuration management of virtualization in order to increase development productivity. Vagrant is written in the Ruby language, but its ecosystem supports development in a few other languages.

Prerequisites: Install a virtualization product such as; VirtualBox, VMware Fusion, or Hyper-V. This tutorial will use VirtualBox 7.1. Note: I originally had downloaded Vagrant 2.4.1 but I needed to go to version 2.4.2 for Vagrant to work with VirtualBox 7.1.

Vagrant Installation

Download Vagrant Community from their website: Vagrant by HashiCorp. I’m installing on Windows 11 AMD64 architecture. After installation you will need to reboot.

After installing I followed these instructions: https://developer.hashicorp.com/vagrant/tutorials/getting-started/getting-started-project-setup as follows:

Download and install VirtualBox 7.1. -- a link walking you through the process is available on my site: VirtualBox: Windows Host, Manjaro Guest — Key Puncher. Note that in the link the Guest Operating System is Manjaro, however, this post assumes Ubuntu 18.04 (Bionic Beaver) as the VirtualBox guest.

In a PowerShell (see: https://learn.microsoft.com/en-us/powershell/scripting/install/installing-powershell-on-windows?view=powershell-7.4) prompt:

mkdir -p vagrant_test/vagrant_getting_started
cd vagrant_test\vagrant_getting_started
vagrant init hashicorp/bionic6

This will take a bit of time. When it’s finished enter:

vagrant up --provider=virtualbox

This will probably take a bit longer. The --provider=virtualbox will let you know if the installation has problems.

Wait for it to install, then open the VirtualBox application.

VirtualBox Settings

Immediately after installing you are going to want to update your VirtualBox settings. Vagrant uses horrendous defaults!

Open up VirtualBox and you should see a running container:

VirtualBox Vagrant Show Circled

Click the Show button on the running container

You can “Show” the instance you want by clicking: Show.

You are now met with a rather intimidating login screen:

Vagrant Login Screen

Vagrant / VirtualBox login screen

Never fear! The username and password are both “vagrant” without quotes.

You will very likely be met with a “you clicked on the mouse” dialog:

VirtualBox Mouse Click Dialog

VirtualBox / Vagrant mouse click dialog

You can either Capture or Cancel. Remember: if you click Capture you can push <right CTRL> to get your mouse back.

After logging at the terminal shut down immediately so you can set VirtualBox settings.

sudo shutdown -h now

VirtualBox Settings

Click the Settings for the box in question. Proceed to

General > Advanced > Shared Clipboard and set it to bidirectional.

Set VirtualBox Clipboard to bidirectional

VirtualBox bidirectional clipboard

Then go to General > System > Motherboard. Almost certainly Vagrant has not allocated sufficient memory. I like to set it to 8000 MB or higher. Caution: when Vagrant is active you have to be careful with the number of virtual machines you start up because they will eventually eat into the resources of your host OS.

Increase VirtualBox Memory Settings

My VirtualBox memory settings

Next proceed to General > System > Processor and select the number of CPUs desired.

Increase Number of VirtualBox CPUs

My VirtualBox processor settings

Next proceed to General > Display and increase the video memory available until it is out of the red. I also had to select Graphics Controller: VMSVGA to get rid of a warning from VirtualBox that was showing.

Increase VirtualBox display video memory

My VirtualBox display settings

Click “OK” (if you click “Cancel” your VirtualBox settings will be lost and you will have to start all over again).

When it’s all set up, click “Start” in the desired virtual machine.

Installing Updates

You may want to install updates. Do this only AFTER updating VirtualBox’s settings! You have been warned. This is done the usual Ubuntu way using APT (software):

sudo apt update
sudo apt upgrade

After updates are installed you very likely want to reboot or shutdown the VM:

sudo reboot

Or

sudo shutdown -h now

SSH-ing in

Secure Shell is the de facto standard replacement for Telnet. It provides end-to-end encryption to secure communication traffic on the Internet.

Pro tip: Don’t do the vagrant destroy command if you want to keep the virtual machine!

https://developer.hashicorp.com/vagrant/tutorials/getting-started/getting-started-index

Note: ssh was the only way I could get the bidirectional clipboard to work in terminal-based Ubuntu.

Again, in the PowerShell prompt (if the virtual machine is not running):

vagrant up

An alternative way to get to the vagrant instance is ssh. At the same prompt enter:

vagrant ssh

The ssh session can be terminated at any time via

exit

or

logout

Getting Help

The vagrant help text is pretty comprehensive. Simply enter:

vagrant help

at a PowerShell prompt.

And that’s it! That’s your whirlwind tour of Vagrant!

Feedback

As always, do make a comment or write me an email if you have something to say about this post!

Credits:

Vagrant: Up and Running Cover Art
Next
Next

VirtualBox: Windows Host, Manjaro Guest