Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

vagrant package how to save changes to new box

My question is related to this here but I do not get it to work.

I use a pre-made vagrant box from vagrantbox.es ( http://goo.gl/KwQSa2 ) and I want to make some changes and repackage the new virtual machine into a new vagrant box file.

To get the initial box, I add config.vm.box_url = "http://goo.gl/KwQSa2" to my vagrant file.

After invoking vagrant up I do vagrant ssh and then some operation (e.g. touch testfile.txt).

After logging out I use vagrant package which creates package.box.

Then I do vagrant destroy, add the path to package.box to config.vm.box_url in my vagrant file and do vagrant up again.

When I log into the VM, my testfile.txt is not there, so it looks like I packaged the unchanged box.

I tried other things such as vagrant box repackage without success.

What am I missing here?

like image 540
user1981275 Avatar asked May 08 '14 13:05

user1981275


1 Answers

When you package, you have to specify the UUID of the new VM created (by vagrant up) based on the base box.

NOTE: If you are using VirtualBox, it'll create a new VM with name - base_box_name-default-UUID.

When running

vagrant package --base name --output /path/to/name.box

The --base NAME, name should be either the new VM's name or its UUID.

You can get it by using the following command:

$ VBoxManage list vms
"oracle65" {5f9e6136-7773-4cd5-99a1-3a66b5e48045}
"Ubuntu" {e8c5a28c-788d-4d57-8c4a-c1f032a02443}
"oracle510" {fed5f379-495e-4b4b-b4e2-24f98edd2e72}
"archlinux" {c79dcee9-a523-4300-b026-cbc93ad37062}
"Windows" {fa768a76-5710-4b07-a4df-cc388370f038}
"Wiki" {a50ce314-6af8-4633-b02e-82b765cbf401}
"openSUSE" {af3cdf13-7e00-4c24-ae52-423919359b18}
"Debian" {37680776-73b9-44fd-8348-f60fd3895624}
"Solaris" {bc7be4ab-293d-4c94-b591-b5445a954f6c}
"centos_default_1395637517620_29337" {03d1282a-c7ba-493b-91ad-ec26ed763b6c}
"Kubuntu" {787ce012-00ef-4f90-acda-1b65c6d9941b}
like image 55
Terry Wang Avatar answered Oct 29 '22 22:10

Terry Wang