50

I imported the precise32 box, then installed some packages and other data on the VM. My plan is to then repackage it into a box, to save on complicated provisioning when sharing.

However.

vagrant package --base dev-vm --output /box/vm.box

Always returns

[dev-vm] VM not created . Moving on

My directory structure is:

-dev-vm
    --.vagrant
    --Logs
    --box.ovf
    --box-disk1.vmdk
    --dev-vm_13345342.vbpx
    --metadata.json
    --Vagrantfile

Ive

 set VAGRANT_LOG=debug

Which shows no extra info on whats going on.

Windows 7 using Cygwin

UPDATE:

 export VAGRANT_LOG=debug

for Cygwin to set debug log.

I then get

 DEBUG subprocess: Waiting for process to exit. Remaining to timeout: 32000
 DEBUG subprocess: Exit status: 0
 INFO warden: Calling action: #<Vagrant::Action::Builtin::Call:0x2abb800>
 INFO runner: Running action: #<Vagrant::Action::Builder:0x2695920>
 INFO warden: Calling action: #<VagrantPlugins::ProviderVirtualBox::Action::Created:0x267c078>
 INFO runner: Running action: #<Vagrant::Action::Warden:0x2ac6c48>
 INFO warden: Calling action: #<VagrantPlugins::ProviderVirtualBox::Action::MessageNotCreated:0x2ac6c00>
 INFO interface: info: VM not created. Moving on...
Kiksy
  • 1,272
  • 5
  • 20
  • 43
  • When I package up a VirtualBox provisioned box, I have to use the specific box name with the time code attached, like `lucid_1372711888`. – bfitzpatrick Jul 25 '13 at 17:34
  • @bfitzpatrick . That was it. So: vagrant package --base dev-vm_13743534 --output /box/vm.box worked. Did you want to add this as an answer so I can accept? – Kiksy Jul 26 '13 at 09:31

2 Answers2

83

When you package a box, the box name has to be the specific machine name that you can get from VirtualBox (e.g. lucid_1372711888). Just execute following command in cmd:

vboxmanage list vms

Notice that "vboxmanage" should prior be added to PATH variable. See here how to do that.

Also notice that virtual maschine name must not contain spaces. Otherwise it won't be recognized by "vagrant package" command. For instance:

vagrant package --base win7_vbox_base --output win7_base.box #CORRECT
------------------------------------------------------------------------
vagrant package --base win7 vbox base --output win7_base.box #INCORRECT
Community
  • 1
  • 1
bfitzpatrick
  • 1,513
  • 11
  • 13
  • 15
    You can find box names via: `$ VBoxManage list vms`. Also note that this is broken in Vagrant 1.4.2: https://groups.google.com/forum/#!msg/vagrant-up/HNXKTBv0-Jw/-yIbhNHCz10J – earldouglas Jan 14 '14 at 01:08
  • 1
    Remember that unusually for a Windows program (due I think to its origin in Linux) it is case sensitive, so you may get errors if case is not an exact match ie: `lucid_1372711888` != `Lucid_1372711888` – GMasucci Apr 01 '14 at 15:14
  • 2
    Note that the box name is case sensitive – 79E09796 Aug 15 '14 at 15:34
  • @79E09796 comment is important. "ubuntu" != "Ubuntu" if that's your box name. I just had that issue. :) Also spaces can be used if you double quote your boxname `vagrant package --base "Ubuntu 14.04.3"` – jmbertucci Jan 19 '16 at 19:19
  • Note that if your vm name DOES contain spaces, you can use the UUID that the "vboxmanage list vms" command prints instead of the text vm name. That avoids the need to rename the machine instance! – nzc Mar 10 '16 at 17:09
  • You'd think Vagrant might mention this in their "how to package" documentation :-p – foobarbecue Aug 21 '16 at 00:19
  • To find box name on macOS, with the usual path: `/Applications/VirtualBox.app/Contents/MacOS/VBoxManage list vms` – Mihai MATEI Apr 19 '17 at 12:47
13

If you are in the folder that contains your Vagrantfile, you can also simply run:

vagrant package --output your-box-name.box

The following image shows the content of the .box file created with this command:

Unpacket .box

Marco Altieri
  • 3,726
  • 2
  • 33
  • 47
  • If you do that, then the .box created only includes the .vmdk file -- it's missing all the configuration stuff (.ovf and Vagrantfile if you use --vagrantfile option to package). – foobarbecue Aug 21 '16 at 00:23
  • @foobarbecue - I have used that command in the past and it packed everything. I added a screenshot of the un-packed .box to my answer. – Marco Altieri Sep 24 '17 at 20:14
  • I feel this should be the correct answer since the alternate - using 'vboxmanage list vms' requires the user to know the name produced in the list matches. This method will implicitly produce output based on the path the Vagrant file is in. – openCivilisation Feb 29 '20 at 04:45