mwl*_*oda 12 vagrant vagrantfile
我在目录中执行了以下命令(在Windows上,使用Git Bash) D:\vagrant\precise32\02-lamp\
$ vagrant box add precise32 http://files.vagrantup.com/precise32.box
$ vagrant init precise32
$ vagrant up
Run Code Online (Sandbox Code Playgroud)
注意.我没有改变原来的Vagrantfile.
我认为该目录D:\vagrant\precise32\02-lamp\将是VDI类文件的位置,但事实并非如此.工作目录充当共享文件夹.
我找到了Vagrant盒子的位置
C:\Users\USER\.vagrant.d\boxes\precise32\0\virtualbox
根据我在VirtualBox GUI中找到的VM的Vagrant保存更改的位置虚拟硬盘驱动器文件的位置.这是
C:\Users\USER\VirtualBox VMs\02-lamp_default_1458429875795_57100\
我想把这个文件放在系统驱动器中,C:\而不是放在数据驱动器中D:\.如何设置这样的流浪汉配置?
Bri*_*ton 14
对于VirtualBox,您可以通过GUI的"首选项"对话框更改所谓的"默认计算机文件夹"的位置.
本指南虽然已有几年的历史,但工作正常,上周我就如何将现有的vagrant/VirtualBox驱动器移动到一个新位置.
编辑
我引用了以上链接/指南中的步骤,为子孙后代:
移动
~/.vagrant.d到外部驱动器.我重命名它,vagrant_home所以我能够看到它没有ls -a.设置
VAGRANT_HOME要/path/to/drive/vagrant_home在~/.bash_profile.打开VirtualBox应用程序,打开"首选项",然后将"默认计算机文件夹"设置为
/path/to/drive/VirtualBox VMs.关闭VirtualBox.
将
VirtualBox VMs文件夹移动 到驱动器.重新打开VirtualBox.您将看到您的VM列为"无法访问".从列表中删除它们.对于
VirtualBox VMs外部驱动器上文件夹中的每个VM ,浏览到Finder中的文件夹,然后双击该.vbox文件以将其还原到VirtualBox Manager.(有比这更简单的方法吗?)最后,将您使用的任何现有Vagrant目录
vagrant init(这些是Vagrantfile每个中包含a的目录)移动到外部驱动器.由于这些目录只存储元数据,您可以将它们保留在主驱动器上,但将所有内容保存在一起很好,这样您就可以非常轻松地将整个驱动器插入另一台计算机并从那里启动虚拟机.
当您总是想在导入期间更改 Virtualbox 创建虚拟机的位置时,也可以通过 CLI 执行此操作(因为 Virtualbox 通常希望将它们放在一个位置,而不是像 VMware 那样跟踪它们在磁盘上的位置) 。
请注意,通过 GUI 或 CLI 更改此设置不会移动现有虚拟机,它只会设置一个新路径以供导入/创建的下一台计算机使用。如果您想要移动现有计算机,您可以关闭并关闭 Virtualbox 的所有实例,然后mv /old/path /new/path从 cmd/shell 窗口使用或将文件夹剪切并粘贴到 GUI 中的新位置,然后将其更改machinefolder为该路径并打开 Virtualbox,它应该检测到所有现有的虚拟机。
如果您有大量用户需要将虚拟机路径移出其主目录以避免自动备份大型文件,则使用 CLI 可以更轻松地编写脚本/自动化。虚拟机的“最佳”位置在一定程度上取决于您的系统,但/usr/local/可能是在 macOS 或 Linux 上创建新文件夹的好地方。
# Look at the current path
vboxmanage list systemproperties | grep machine
# Output (commented for easier copying and pasting of commands)
# Default machine folder: /Users/<YourUser>/VirtualBox VMs
# Set it to a different folder in your home aka ~
# If you user has access to the path and can create files/folders, then
# the folder doesn't need to exist beforehand, Virtualbox will create it
vboxmanage setproperty machinefolder ~/VirtualMachines
# No output produced
vboxmanage list systemproperties | grep machine
# Output (commented for easier copying and pasting of commands)
# Default machine folder: /Users/<YourUser>/VirtualMachines
Run Code Online (Sandbox Code Playgroud)
您还可以将其设置为主目录之外的文件夹,但这通常需要创建该文件夹并修复权限,然后 Virtualbox 才能使用它。
# [Optional] Only needed if moving out of the home directory to
# a place the user doesn't have permission to access by default
sudo mkdir -p /usr/local/VirtualMachines && \
sudo chown -R ${USER} /usr/local/VirtualMachines
# If you add : like this `${USER}:` to the above, instead of
# setting the group to admin or wheel it will use the user's default group
# which can be seen by running `id -g`
vboxmanage setproperty machinefolder /usr/local/VirtualMachines
# No output produced
vboxmanage list systemproperties | grep machine
# Output (commented for easier copying and pasting of commands)
# Default machine folder: /usr/local/VirtualMachines
Run Code Online (Sandbox Code Playgroud)
如果您改变主意,您可以轻松地将其设置回默认值,但您需要自己再次将虚拟机移回原处。
vboxmanage setproperty machinefolder default
vboxmanage list systemproperties | grep machine
# Output (commented for easier copying and pasting of commands)
# Default machine folder: /Users/<YourUser>/VirtualBox VMs
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
10711 次 |
| 最近记录: |