How to, TipsAndTricks

How to customize your Vagrant and VirtualBox machines’ folder on Windows ?

Last week, for one of my side projects, I had to use vagrant in order to be able to run some tests on a Chocolatey packages I am currently trying to update. But having a computer almost full, any call to vagrant up ended up failing because of my lack of memory space on my main hard drive. 😝

VirtualBox and Vagrant

A small digression for those who don’t know what VirtualBox or Vagrant are. 😉

VirtualBox is a software made by Oracle, that allows us to virtualize system and to run virtualize system on a machine. This means that you can potentially have run any version of Windows, Linux or Mac on your own machine with this software.

Vagrant is a software made by Hashicorp, which simplifies the use of virtualization tools and offer a way to easily run and automate interactions with virtualized environments.

On a windows system, you can install both of them using Chocolatey with powershell like that:

choco install virtualBox
choco install vagrant

Back to our problem

Having virtual machines is nice, but can requires a lot of space.

So we need a way to have VirtualBox and Vagrant them in a different folder than their default one, on your main hard drive. Doing this is easy, since VirtualBox and Vagrant actually gives you the possibilities to change those elements (some people must have had the same problem before 😆 )

To do so, open your powershell terminal in Admin mode and run the following command with your custom folder

VBoxManage setproperty machinefolder <your/custom/VirtualBox/folder/>
setx VAGRANT_HOME <your/custom/Vagrant/folder>

Personally, here how I used them

VBoxManage setproperty machinefolder "D:/VirtualBoxVMs"
setx VAGRANT_HOME "D:/.vagrant_d

And now, all I have to do is run vagrant up to have my virtual machine running and stored in my other hard drive. 🙂

Conclusion

VirtualBox and Vagrant are amazing tools with a lot of configuration possibilities, so you can adapt them to your needs and constraints.

I hope this article will give you the information you were looking for. Personally, I needed to write this post so that future me will be able to go back to it whenever he will need to do so 😆

Thank you all for reading this article ! And until my next article, have an splendid day 😉

Votre commentaire

Entrez vos coordonnées ci-dessous ou cliquez sur une icône pour vous connecter:

Logo WordPress.com

Vous commentez à l’aide de votre compte WordPress.com. Déconnexion /  Changer )

Photo Google

Vous commentez à l’aide de votre compte Google. Déconnexion /  Changer )

Image Twitter

Vous commentez à l’aide de votre compte Twitter. Déconnexion /  Changer )

Photo Facebook

Vous commentez à l’aide de votre compte Facebook. Déconnexion /  Changer )

Connexion à %s