如何将vagrant exact32升级到较新版本?

时间:2013-07-02 15:22:29

标签: ubuntu vagrant

我尝试运行Vagrant计算机,但因为安装了Vagrant 1.0.1而遇到错误。然后我卸载并安装了Vagrant 1.2.2。但是,当我运行vagrant时,我得到一个错误。

$ vagrant up

Bringing machine 'default' up with 'virtualbox' provider...
The box 'precise32' is still stored on disk in the Vagrant 1.0.x
format. This box must be upgraded in order to work properly with
this version of Vagrant.

我尝试了vagrant init但也出错了。

$ vagrant init precise32 http://files.vagrantup.com/precise32.box

`Vagrantfile` already exists in this directory. Remove it before
running `vagrant init`.

如何将我的精确32盒升级为新版Vagrant?

3 个答案:

答案 0 :(得分:15)

运行

vagrant box repackage precise32 virtualbox

答案 1 :(得分:0)

使用vagrant 1.1+打包的盒子根据docs有一个名为metadata.json的额外文件。

尝试在metadta.json下手动创建内容为

~/.vagrant.d/boxes/precise32/virtualbox文件
{"provider": "virtualbox"}

再试一次,看看你是否还有问题。

如果它没有帮助,我能想到的唯一方法是删除该框并使用新的流浪汉版本再次添加它。您不必销毁这些盒子,即使它们不再与vagrant一​​起使用,您仍然可以使用VBoxManage和VirtualBox GUI来操作它们。

答案 2 :(得分:0)

这些版本之间的vagrant目录结构的格式已更改。您添加一个名为virtualbox的子目录,然后使用'{“provider”:“virtualbox”}'等内容将metadata.json文件添加到其中。

这是一个带有bash脚本的要点,您可以使用它自动执行此操作,并将更改打印到屏幕上。

wget -q -O - https://gist.github.com/xrd/6055536/raw/8398322313a7e8a60ee8f9ad4d6a87d50ee55b8d/gistfile1.txt | bash

如果您希望恢复已有的输出,则输出实际上可以反转更改。

博客文章中详细介绍了这一点,这可能有所帮助:

Upgrading vagrant boxes to 1.2