I chose the D:\ drive during installation but when I download a vagrant box it downloads to my user directory on C:\ drive. I am using a SSD with hardly any available space. How do I make it download boxes to another drive?
-
This question appears to be [off topic](http://stackoverflow.com/help/on-topic). – Jørgen R Jun 05 '15 at 12:54
-
No, vagrant is a software used to configure development environment for programming. It is within the scope defined by SO. Search vagrant tag if you like. – Guerrilla Jun 05 '15 at 12:55
2 Answers
You can use the VAGRANT_HOME environment variable to change the vagrant config / box download directory.
On Windows you should be able to use the setx
command to change it, for example:
setx VAGRANT_HOME "D:/vagrant"
However, I found a similar stack overflow question where users are suggesting that the environment variable doesn't always work and that changing the @home_path
found in vagrant\embedded\gems\gems\vagrant-1.x.x.dev\lib\vagrant\environment.rb
worked for them.

- 1
- 1

- 450
- 4
- 10
-
1That has worked, files are going to D:\ drive now but I am still losing space from C: on first `vagrant up` (about 1gb I think roughly, could be a bit less). Is it using this space to run image do you think? The actual box downloaded to D: is only 300mb. – Guerrilla Jun 05 '15 at 15:10
-
1I suspect you are right. What are you using for your hypervisor? If you are using VirtualBox you can change the setting `Default Machine Folder` to change the location where the virtual hard drive's etc are stored. – Adam Taylor Jun 05 '15 at 16:20
-
-
So did you also set the VirtualBox Default Machine Folder to the D:/vagrant path? – JohnZaj Aug 11 '18 at 18:35
-
I did this with a symlink via cmd and used `mklink /J e:\VagrantBoxes\boxes boxes`. – Markus Zeller Mar 17 '19 at 22:13
-
1@MarkusZeller That’s an [NTFS junction point](https://en.wikipedia.org/wiki/NTFS_junction_point), which is different from [NTFS symbolic link](https://en.wikipedia.org/wiki/NTFS_symbolic_link) created with `/D` switch instead of `/J`. Both works on my machine. – Franklin Yu Apr 22 '19 at 20:24
You can also create a link in %UserProfile%\.vagrant.d\
pointing to a folder in your D drive. For Windows NTFS file system, both symbolic link and junction point works. To create a symbolic link, run following command in CMD (it doesn’t work in PowerShell):
mklink /d %UserProfile%\.vagrant.d\boxes D:\my-boxes-folder
Note that switch is case-insensitive, so /d
is same as /D
. To create a junction point, replace the /d
with /j
. For Unix-like system such as macOS or Linux, symbolic link should work.

- 8,920
- 6
- 43
- 57