How to Change a Downloaded Box to Be a Fixed Size VM ?

26 views
Skip to first unread message

peter....@gmail.com

unread,
Jun 5, 2017, 10:12:54 PM6/5/17
to Vagrant
Hi,

pretty new to Vagrant. Love it ;-)

I downloaded a public Vagrant box and initiated it via the Vagrantfile. All working.

Now, I see that the VM that has been created was set to be a 15 GB file with dynamically allocated storage.

How can I change the VM to be a fixed size of 10 GB, using the Vagrantfile ?


Thanks !

- Peter

peter....@gmail.com

unread,
Jun 5, 2017, 10:23:56 PM6/5/17
to Vagrant
Also, how can I change the location path of the VM via the Vagrantfile (specifying a custom path) ?


Alvaro Miranda Aguilera

unread,
Jun 6, 2017, 2:36:40 AM6/6/17
to vagra...@googlegroups.com
Hello.
Assuming you are using Vagrant with Virtualbox, yes is doable.

However you need to do some work on the following order

Filesystem
Partition
Disk

If you can came up with the commands you want vagrant to run, then you can include it on the Vagrantfile.


--
This mailing list is governed under the HashiCorp Community Guidelines - https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list.
 
GitHub Issues: https://github.com/mitchellh/vagrant/issues
IRC: #vagrant on Freenode
---
You received this message because you are subscribed to the Google Groups "Vagrant" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vagrant-up+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vagrant-up/c4383771-d8be-438a-a5b5-57a8bcbe531c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Alvaro

Alvaro Miranda Aguilera

unread,
Jun 6, 2017, 2:37:31 AM6/6/17
to vagra...@googlegroups.com
For Virtualbox, Vagrant will create the VM on the default path defined for Virtualbox.

Usually is 

Home_dir/VirtualBox VMs

You can change that in Virtualbox gui, preferences.

Alvaro.

On Tue, Jun 6, 2017 at 4:23 AM, <peter....@gmail.com> wrote:
Also, how can I change the location path of the VM via the Vagrantfile (specifying a custom path) ?


--
This mailing list is governed under the HashiCorp Community Guidelines - https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list.
 
GitHub Issues: https://github.com/mitchellh/vagrant/issues
IRC: #vagrant on Freenode
---
You received this message because you are subscribed to the Google Groups "Vagrant" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vagrant-up+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
Alvaro

peter....@gmail.com

unread,
Jun 6, 2017, 2:45:28 AM6/6/17
to Vagrant
Hi Alvaro,

thanks !

Can you give an example on how Filesystem, Partition, Disk need to be used ?

peter....@gmail.com

unread,
Jun 6, 2017, 2:47:36 AM6/6/17
to Vagrant
I've already done that in the VB GUI. Problem is that sets a general location for ALL VMs. I want individual location control. That is possible via the VB GUI but point of Vagrant for me is not to touch the VB GUI...

So, are you saying a custom path for each VM created by Vagrant can not be set inside the Vagrantfile ?

Thanks !

Alvaro Miranda Aguilera

unread,
Jun 6, 2017, 2:53:05 AM6/6/17
to vagra...@googlegroups.com
As you have found its global, and control by Virtualbox not, by Vagrant.

If this for user or for a CI/CD kind of stuff?

If you will be building some sort of disponsable system, then perhaps you can look into packer.io, you can start a VM from an existing VM (virtualbox-ovf)

If you will be running all this in some setup like Jenkins or scripts, then you can build somethings.


You can set:
VBOX_USER_HOME environment variable
then you can run:
VBoxManage setproperty machinefolder <path>

With that you will end with something very custom.

The need to be run before Vagrant.

Alvaro.





--
This mailing list is governed under the HashiCorp Community Guidelines - https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list.
 
GitHub Issues: https://github.com/mitchellh/vagrant/issues
IRC: #vagrant on Freenode
---
You received this message because you are subscribed to the Google Groups "Vagrant" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vagrant-up+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
Alvaro

peter....@gmail.com

unread,
Jun 6, 2017, 5:36:47 AM6/6/17
to Vagrant
it's really rather simple:

in my Vagrantfile, I create at least one VM. I want to specify the local path on the host machine, where this VM is located.

I have set already:

> VAGRANT_HOME env var, which controls where Vagrant boxes are located on the host
> default VM location in the VB GUI preferences

but these are global controls, I need an individual path for any given VM, on a case by case basis.

Is that doable in the Vagrantfile ?

Thanks !!!

Alvaro Miranda Aguilera

unread,
Jun 6, 2017, 6:46:24 AM6/6/17
to vagra...@googlegroups.com
I am afraid not on Virtualbox.

On vmware the VM gets created on the project folder by default.

Alvaro.

--
This mailing list is governed under the HashiCorp Community Guidelines - https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list.
 
GitHub Issues: https://github.com/mitchellh/vagrant/issues
IRC: #vagrant on Freenode
---
You received this message because you are subscribed to the Google Groups "Vagrant" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vagrant-up+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
Alvaro

Peter Folk

unread,
Jun 6, 2017, 4:52:41 PM6/6/17
to vagra...@googlegroups.com
then why when I create the VB VM manually (instead using Vagrant), I can specify a custom path for each VM ?

Nathan Fisher

unread,
Jun 6, 2017, 5:14:13 PM6/6/17
to vagra...@googlegroups.com
I think he's inferring it's a limitation of the virtualbox provider.

Out of curiosity why do you want the vm location different from the global path?
On Tue, 6 Jun 2017 at 22:52, Peter Folk <peter....@gmail.com> wrote:
then why when I create the VB VM manually (instead using Vagrant), I can specify a custom path for each VM ?
On Tue, Jun 6, 2017 at 3:46 AM, Alvaro Miranda Aguilera <kik...@gmail.com> wrote:
I am afraid not on Virtualbox.

On vmware the VM gets created on the project folder by default.

Alvaro.
On Tue, Jun 6, 2017 at 11:36 AM, <peter....@gmail.com> wrote:
it's really rather simple:

in my Vagrantfile, I create at least one VM. I want to specify the local path on the host machine, where this VM is located.

I have set already:

> VAGRANT_HOME env var, which controls where Vagrant boxes are located on the host
> default VM location in the VB GUI preferences

but these are global controls, I need an individual path for any given VM, on a case by case basis.

Is that doable in the Vagrantfile ?

Thanks !!!

--
This mailing list is governed under the HashiCorp Community Guidelines - https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list.
 
GitHub Issues: https://github.com/mitchellh/vagrant/issues
IRC: #vagrant on Freenode
---
You received this message because you are subscribed to the Google Groups "Vagrant" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vagrant-up+...@googlegroups.com.



--
Alvaro

--
This mailing list is governed under the HashiCorp Community Guidelines - https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list.
 
GitHub Issues: https://github.com/mitchellh/vagrant/issues
IRC: #vagrant on Freenode
---
You received this message because you are subscribed to the Google Groups "Vagrant" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vagrant-up+...@googlegroups.com.

--
This mailing list is governed under the HashiCorp Community Guidelines - https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list.
 
GitHub Issues: https://github.com/mitchellh/vagrant/issues
IRC: #vagrant on Freenode
---
You received this message because you are subscribed to the Google Groups "Vagrant" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vagrant-up+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vagrant-up/CAP5xNFJn%2BC_0ezsfW94DoT4MW4c8HW8x5C8Hc_hxZcKmm2LKnQ%40mail.gmail.com.

For more options, visit https://groups.google.com/d/optout.
--
- sent from my mobile

Alvaro Miranda Aguilera

unread,
Jun 6, 2017, 5:25:10 PM6/6/17
to vagra...@googlegroups.com
Hello Peter

So this is how vagrant + virtual box works today.
I wasn't able to find any feature request open, so as time permit, could you open an issue on github, and share some information on why this is a good feature?




Thanks 
Alvaro

peter....@gmail.com

unread,
Jun 6, 2017, 6:34:23 PM6/6/17
to Vagrant
Hi Alvaro,

got ya, so it's a limitation of the VB implementation. Thanks for the clarification.

Could you provide a quick example using the Filesystem, Partition, Disk commands on how you would change a VB VM to be a fixed size VM ?

Thanks.

Alvaro Miranda Aguilera

unread,
Jun 7, 2017, 3:24:46 AM6/7/17
to vagra...@googlegroups.com
Peter

Whats the box you are using today and whats the current size and what the size you need?

I think will be quicker if I create a packer project, upload the vagrant box for you.

Expanding can be done online after the new disk has been created, but shrinking will be harder and will require some rescue disk, boot into maintenance, so will be more pita.

Alvaro


--
This mailing list is governed under the HashiCorp Community Guidelines - https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list.
 
GitHub Issues: https://github.com/mitchellh/vagrant/issues
IRC: #vagrant on Freenode
---
You received this message because you are subscribed to the Google Groups "Vagrant" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vagrant-up+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
Alvaro

peter....@gmail.com

unread,
Jun 7, 2017, 6:35:55 AM6/7/17
to Vagrant
I'm using the default "aspyatkin/ubuntu-16.04-server-amd64" box. Vagrant creates a dynamically allocated VM with 15GB, which is way too large for this project.

What I'm looking for is to define in the Vagrantfile how large the VM should be (I would use a 6GB VM), and I want this to be FIXED SIZE (not dynamically allocated).

When I use VB manually and create VMs w/o Vagrant, during the setup process, one can specify the VM size and choose FIXED size. The VM is then built that way.

I'm looking for the exact same hooks, just via Vagrantfile.

Is that possible ?

Alvaro Miranda Aguilera

unread,
Jun 7, 2017, 6:57:50 AM6/7/17
to vagra...@googlegroups.com
Vagrant use case is for this.

Take a base box and create a VM used for development or prototyping. Dynamic allow have a big disk that uses little space, so will fit more use cases

The important is the code (your app) and not the vm.

Vm are disponsable.

If what you need is have a running VM, with a fixed size for performance, then perhaps Vagrant is not the tool you want, and maybe other solution is the best.

You could create your own base box with packer, and give the size you require, from memory I am not sure you will be able to create a Vagrant box with fixed size.

If you could explain your end to end workflow, maybe are other ways to solve that problem.

Alvaro.

Peter Folk

unread,
Jun 7, 2017, 5:36:10 PM6/7/17
to vagra...@googlegroups.com
okay, so I guess you're saying Vagrant does not offer the hooks for this. this is disappointing. Even with dynamic allocation, I want to set the max size to be lower than 15GB.

--
This mailing list is governed under the HashiCorp Community Guidelines - https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list.
 
GitHub Issues: https://github.com/mitchellh/vagrant/issues
IRC: #vagrant on Freenode
---
You received this message because you are subscribed to the Google Groups "Vagrant" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vagrant-up+unsubscribe@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages