vagrant halt
vagrant package
如果要指定vm或者输出名称等内容请查看
vagrant package -h
⇒ vagrant package -h
Usage: vagrant package [options] [name]
Options:
--base NAME Name of a VM in virtualbox to package as a base box
--output NAME Name of the file to output
--include FILE... Additional files to package with the box
--vagrantfile FILE Vagrantfile to package with the box
-h, --help Print this help
package.box 这个文件是当前vagrant vm的全镜像,且经过压缩。
# vagrant init
打开文件Vagrantfile,编辑文件,将当前默认的box名字改为新的box名称,比如“my-backup-test-box”
config.vm.box = "my-backup-test-box"
# config.vm.box_url = "http://domain.com/path/to/above.box"
config.vm.box_url = "file:///d:/folder/package.box"
config.vm.network :private_network, ip: "192.168.33.101"
# vagrant up
# vagrant box add --name name-of-this-box package.box virtual box
注意以上命令行参数–name
⇒ vagrant box add --name name-of-this-box package.box
==> box: Box file was not detected as metadata. Adding it directly...
==> box: Adding box 'name-of-this-box' (v0) for provider:
box: Unpacking necessary files from: file:///Users/Richard/Documents/Dev/vagrant/package.box
==> box: Successfully added box 'name-of-this-box' (v0) for 'virtualbox'!
config.vm.box = "name-of-my-box"
此种方法不需要再配置config.vm.box_url
需要注意 synced folder
在打包box并且创建新的vm时,客户(guest)下的synced folder的内容可能会丢失,所以最好在此之前关闭synced
config.vm.synced_folder ".", "/vagrant", disabled: true
以上内容是抄袭来的,原文在这里 原文传送门
Failed to mount folders in Linux guest. This is usually because
the "vboxsf" file system is not available. Please verify that
the guest additions are properly installed in the guest and
can work properly. The command attempted was:
mount -t vboxsf -o uid=`id -u vagrant`,gid=`getent group vagrant | cut -d: -f3` vagrant /vagrant
mount -t vboxsf -o uid=`id -u vagrant`,gid=`id -g vagrant` vagrant /vagrant
The error output from the last command was:
mount: unknown filesystem type 'vboxsf'
解决办法是:
# vagrant plugin install vagrant-vaguest
登录后,切换root遇到:
su: 鉴定故障
解决办法:
# sudo su
# passwd root