In What is this "Linux", anyhow? we mention using Vagrant as a way to quickly configure a Linux virtual machine, and the Raspberry Pi Kernel-o-Matic uses Vagrant to set up a VM for cross-compiling a custom Raspberry Pi kernel.

Vagrant is a software package designed to let you easily create disposable VMs from a library of freely-downloadable images and connect to them, all with a few simple commands in a terminal. The idea is that you can continue to run your desktop OS like Mac OS X or Windows 7 or whatever, but then make a tiny new Linux computer in a window that you can connect to whenever you need to run Linux software

Unfortunately this isn't quite as seamless on Windows machines as on GNU/Linux or OS X systems, but with a few minutes of effort you should be able to do this any time you feel like it:

This is a brief guide to installing the three moving pieces needed to make this work well on a Windows machine:

  1. Vagrant itself
  2. VirtualBox to run virtual machines
  3. msysGit, a Windows distribution of Git and some other Unix tools, for cloning git repositories containing Vagrant configurations and connecting to your new VM with SSH

First, hit the Vagrant site and look for a "DOWNLOAD" button.

Click on the Windows installer link, and save the installer:

Then run the installer. Default choices should be fine.

Next, we'll install msysGit, which is a distribution of the git version control system. Git isn't strictly necessary for working with Vagrant, but it provides a version of the Bash shell, SSH, and other tools we'll find helpful.  Later on, if you have Git installed, you can use it to keep up to date with things like the Kernel-o-Matic.

If you already have msysGit or the Cygwin tools installed, you can likely skip this step.

Again, visit the msysGit site and look for a "Download" button.

Run the installer. Windows will likely ask you several times if you'd like to allow the installer to run and modify your system.

For most options, the defaults should be acceptable. You may want to select "Use Git from the Windows Command Prompt", but it shouldn't make any real difference for our purposes.

For convenience, you might want to choose "In the Quick Launch" and "On the Desktop" under "Additional icons".

Lastly, we need VirtualBox to actually run the virtual machine we're going to configure. Head to virtualbox.org and look for the Downloads link, then find the Windows installer.

As with Vagrant and msysGit, run the installer, and click through options. Defaults should be fine.

If all has gone well, you should be ready to start up a Vagrant box.

First, look for the Git Bash prompt provided by msysGit. It's probably on your desktop, but if you can't find it there, have a look in the Start Menu.

This is a version of Bash, which is a standard shell on GNU/Linux systems (for shell basics, start here). Fire it up and enter the following commands:

mkdir vagrant_demo
cd vagrant_demo
vagrant init hashicorp/precise32

You should now have a folder containing a basic Vagrantfile. (There's a lot of documentation on Vagrantfiles.)

Next, do vagrant up, which should download an image, set it up, and start a virtual machine running in VirtualBox. This will probably take a while.

There you have it: A working Linux VM. What now? Well, you can:

Once you're done with a machine, you can remove it with vagrant destroy.

If you're interested in trying other operating systems and configurations, read the manual on boxes, then have a look at the list of available boxes from HashiCorp - you're not limited to these, but it's a good place to start.

This guide was first published on Feb 25, 2015. It was last updated on Feb 25, 2015.