Add the generated box file to Vagrant box list. Vagrant box list is a list of registered boxes per machine and per user. The box names present in this list can be used in multiple Vagrantfiles. Vagrant box add WinServer2012R2.; Verify the box list. Vagrant box list. You should see the entry for WinServer2012R2. I've been using Packer for a bit over a year now to create the Windows 2012 R2 Vagrant box that I regularly use for testing various server configuration scripts. My packer template has been evolving over time but is composed of some Boxstarter package setup and a few adhoc Powershell scripts. Import the box into vagrant with name windows10: vagrant box add windows10./ After this step vagrant instances can be created using the bare Windows 10 box. Install Visual Studio 2015 and configure provision script. Now, I would like to install Visual Studio, so I create a vagrant instance using windows10 box, install.

Using Vagrant for creating Consul cluster on Linux probably was fun. But what about Windows hosts? Believe it or not, but more than half of developers are actually using Windows, so for most of the folks seeing how Vagrant creates Linux VMs is pretty useless. However, you can create and provision Windows VMs with Vagrant with little to no problem. So I decided to go ahead and create a base box for Vagrant for Windows 10 Professional. I read several articles about creating Windows base boxes for Vagrant. There is plenty of information out there but it is scattered, some of it is old and no longer relevant and most of it is for Windows 8.1 or Windows Server 2012.

Create Windows Vagrant Box Ubuntu


Update on July 23, 2019: Since the time I originally made this post, Debian has moved from version 9.6 Stretch to 10.0 Buster. I’ve updated the post accordingly. Thankfully, nothing changed but the name of the Vagrant box to use! If you still want to use Stretch, replace everywhere that it says stretch64 with buster64. Some of your error messages may be different, though…

Lately, for my Linux development, I’ve been using Vagrant, using VirtualBox as a provider. In Vagrant, I set up a Debian box and do my development on that. It’s nice and easy to set up, and if I want to restart with a clean installation of Debian, it’s very easy to do.

I’ll write three posts about how I set it up. In this first post, I detail the steps that I use to create a basic Debian box, with no GUI. In my second post, I describe the steps I use to set up VirtualBox’s Guest Additions, so that I can share files between my host Windows system and my Debian Vagrant box. In the third post, I give the steps that I use to set up a GUI.

If you know what you’re doing, and you want to skip all the explanations and just see the steps involved, feel free to look at my summary!

Debian’s Vagrant Box

The Debian project provides standard Vagrant boxes in the Vagrant Cloud box catalog. You can read about them on the Debian wiki, and look at the provided boxes on The latest version of Debian is version 10, codenamed Buster. At the time of writing this post, the latest point release was 10.0, and I’m using the 64-bit version of Debian. So, the Vagrant box I’m using is debian/buster64.

The Debian Vagrant box provides a standard basic Debian system, containing all packages with priority required, important, and standard. Note that it does NOT include a GUI; you’re just going to get a command-line version. We’ll look at how to set up a GUI in the third post.


To set this up, you need to have both VirtualBox and Vagrant installed. You can download VirtualBox from the website The download page is, and the installation instructions are in Chapter 2 of the User Manual. You can download Vagrant from the website, where the download page is at, and the installation instructions are at I installed VirtualBox first, then Vagrant. I don’t know if the order matters, but it made sense to me, and I know that works!

Create windows vagrant boxBox

Creating the Vagrantfile

Once you’ve got Vagrant and VirtualBox installed, you’re going to want to create the configuration file for your box. This file is called Vagrantfile. I’ve created a folder under my home directory called vagrant-VMs, and underneath that, another folder called buster. I’ve created multiple folders under vagrant-VMs, one for each Vagrant configuration, but in this post, I’m only discussing my Buster installation.

Here’s looking at my folder in File Explorer:

Open a command prompt, then change to the vagrant-VMsbuster folder:

Next, use Vagrant to create the Vagrantfile for us:

This will create the Vagrantfile that configures the usage of the Vagrant box. The box won’t actually be downloaded until you try to bring the box up for the first time.

Here’s a screenshot.

You might want to take a look at the Vagrantfile; it’s just a text file (actually, a Ruby program file), so you can look at it in your favourite text editor, such as Notepad, Notepad++, or Vim. There’s actually very little in the file; most of it is commented-out configuration, giving examples of things you may want to configure. But, for now, we’ll just leave things as they are.

Here’s a screenshot of the complete file (click to view it larger):

Creating the Virtual Machine

The next step is to create and start up the virtual machine. We’ll use the “vagrant up” command to do that. The first time you run this, it will connect to the Hashicorp atlas (a repository of Vagrant boxes, maintained by the developers of Vagrant) and download a copy of the box (called the “base box”). Then, it will create a virtual machine as a copy of the downloaded base box; subsequent executions will just use the virtual machine you’ve already created.

Note: Vagrant creates a folder to hold all its configuration data under your home directory, with the name .vagrant.d. If you’re curious where the downloaded base box goes, it goes underneath that folder, in a subfolder named boxes. On Windows, I use File History to back up my files; because these boxes are so big, and because I can easily re-download them, I don’t want to back them up, so I configure File History to not backup the .vagrant.dboxes folder. There’s another folder that I also don’t back up, but I’ll mention that next…

Second note: the virtual machine gets created in a folder in your home directory called “VirtualBox VMs”. Once again, I don’t want to back these up, so I add this folder to my list of excluded folders in File History. You may want to back them up, but as I said before, you can easily recreate these VMs, so it’s a waste of backup space to back them up.

OK, so let’s create our Virtual Machine:

You’ll see a whole bunch of messages. Vagrant goes through the following steps when it creates the VM:

  • Imports the debian/buster64 base box and uses it to create a new VM
  • Configures the networking of the new VM
  • Boots the VM, and waits for the booting to complete
  • Uses SSH to connect to the VM, and replaces the SSH key in the VM (more on that later)
  • Checks to see if the VirtualBox guest additions are installed.

You’ll now see one of two messages about the VirtualBox guest additions. If they are not installed in the Vagrant box (they shouldn’t be, but version 10.0.0 of the box seems to include them), you’ll get a scary error message telling you that you should install them, and that a lot of things won’t work until you install them. Ignore that for now; I’ll look at installing the guest additions in my next post. If they are installed (version 10.0.0, I’m looking at you!), you may get a slightly less scary message that the guest additions on the VM don’t match the installed version of VirtualBox. Don’t worry about that, as we’ll install the proper version in the next post.

At the time of writing, I also get a VERY scary error message about attempting to rsync a shared folder. Once again, don’t worry about that; we’ll resolve that in the next post as well.

With regards to SSH: the buster64 box that was downloaded from the Hashicorp atlas has a well-known SSH key, but you really want that to be secret. But, if it was secret, we wouldn’t be able to connect to the VM. So, when we first bring up the VM, Vagrant connects to the VM using the well-known key, then generates a secret key, and replaces the well-known key with our new secret key. Finally, it disconnects and reconnects using the new key, just to make sure everything is working OK.

Here’s a screenshot of all the output (click to enlarge):

You’ll notice that it doesn’t appear that the VM is running. The “vagrant up” command completes and returns us to the command prompt, and there isn’t a VirtualBox GUI. But, don’t worry, VirtualBox is running; you just can’t see it! If you really want, you can start up Windows’ Task Manager, and see the VBoxHeadless process listed under Background Processes. Or, you can start up VirtualBox, and you’ll see that you’ve got a running VM!

Bringing Debian Up-to-date

There may be security patches issued by Debian that aren’t incorporated into your imported box. The next thing we’re going to do is to bring all the software up-to-date.

Log in to the VM using the “vagrant ssh” command:

This will connect to the VM using SSH, and will log you in to an account named “vagrant”. This account was present in the Vagrant box you downloaded; it’s a standard convention used by Vagrant boxes. If you ever need to log in without using the “vagrant ssh” command, the password is also “vagrant”.

Here’s a screenshot:

Once you’re logged in, you’ll be at the Debian command prompt. We’ll want to execute the following commands:

The first command will connect to the Debian package repository, and download a list of all of the latest versions of Debian packages. The second command will download and install any packages that have been updated in the repository since the Vagrant base box was created.

Here’s a screenshot of executing the update:

and another of executing the upgrade (click to enlarge). Note that your packages being updated almost certainly will be different from mine.

Depending on which packages have been updated, there are two other possible commands you may need to execute. If you get a message about some packages being held back, execute this command:

And, if you get a message that some packages are no longer needed, you can remove them with:

VagrantCreate vagrant box

Actually, there’s really no harm in executing both of these commands anyways, since we’re setting up a new VM; they just might not do anything.

And now, we’re done! We’ve got an up-to-date Debian system running.

Log out of the SSH session to return to the Windows command prompt:

Shutting down the Virtual Machine

The last thing to do is to shut down the virtual machine. That’s very easy to do from the Windows command prompt. Execute:

And you’ll get a message that Vagrant is gracefully shutting down the virtual machine.

Next time you want to start the VM back up, just go to your vagrant-VMsbuster folder (or whatever you called it), and re-execute “vagrant up”. It won’t need to recreate the VM; it’ll just use it as it was the last time you used it.

Do you want to clean up?

For completeness, I should mention how you can clean up what you’ve done.

If you want to delete the VM that you created, execute:

That will delete the virtual machine. You can easily recreate the VM, though, just be executing “vagrant up” again. This is a nice easy way to start your VM over fresh if you mess it up somehow. It leaves your Vagrantfile intact, so any configuration changes you made in there will be used the next time you recreate the virtual machine. But, any changes you made inside the VM (such as updating Debian!) will need to be redone.

If you also want to remove the base box, execute:

If you want to use it again, you’ll need to re-download it; executing “vagrant up” will automatically do that for you if you need it.

Next steps

It’s very useful to have the VirtualBox guest additions installed on your system; I detail how to do that in my next post. This will allow you to share files between your VM and your Windows machine that the VM is running on. Also, if you’re running a GUI (which I’ll describe how to set up in my third post), it allows you to resize the window, which is very handy!

This tutorial will create a base box using Ubuntu 16.04

1. First, initialize vagrant, ssh into the box and install whatever you want on it.

While still in ssh…

You can also use this tutorial and script to initialize and install a lemp stack:
How To Provision A LEMP Stack in Vagrant

2. Make the box as small as possible

3. Then, “zero out” the drive

Not sure what this does

4. Clear the Bash History and exit the VM

Now continue from the vagrant command line

Create Windows Vagrant Box Centos

5. Repackage the server we just created into a new vagrant base box

where ‘’ is any name you choose while adding .box at the end

6. Add this new Vagrant Box into Vagrant

where ‘mynewbox’ is any name you choose (preferrably similar to the name of the box you just added) and ‘’ is the file name of the box you just created

This now will “download” the box into your Vagrant installation allowing you to initiate this from any folder.

To view the list of vagrant boxes:

Create Windows Vagrant Box Debian

To remove a vagrant box:

Coments are closed
Scroll to top