Vagrant - 为 VirtualBox 设置虚拟硬盘的位置 [英] Vagrant - set the location of the virtual hard drive for VirtualBox

查看:36
本文介绍了Vagrant - 为 VirtualBox 设置虚拟硬盘的位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在目录 D:\vagrant\precise32\02-lamp\

中执行了以下命令(在 Windows 上,使用 Git Bash)

$ vagrant box 添加精确32 http://files.vagrantup.com/precise32.box$ vagrant init precision32$无业游民

注意.我没有改变原来的 Vagrantfile.

我认为目录 D:\vagrant\precise32\02-lamp\ 将是类似 VDI 的文件的位置,但事实并非如此.工作目录用作共享文件夹.

我找到了 Vagrant 盒子的位置C:\Users\USER\.vagrant.d\boxes\precise32\0\virtualbox

根据

本指南,而几年前,工作正常,上周我关注了如何将现有的 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.你会看到的您的虚拟机被列为无法访问".从列表中删除它们.

  • 对于外部驱动器上 VirtualBox VMs 文件夹中的每个 VM,浏览到 Finder 中的文件夹,然后双击 .vbox 文件以恢复它到 VirtualBox 管理器.(还有比这更简单的方法吗?)

  • 最后,移动您创建的任何现有 Vagrant 目录vagrant init(这些是每个目录中包含一个 Vagrantfile 的目录)到外部驱动器.由于这些目录只存储元数据你可以将它们留在您的主驱动器上,但保留所有内容很好在一起,这样你就可以很容易地将整个驱动器插入另一个机器并从那里启动您的虚拟机.

I have executed following commands (on Windows, using Git Bash) in the directory D:\vagrant\precise32\02-lamp\

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

Note. I haven't changed original Vagrantfile.

I thought the directory D:\vagrant\precise32\02-lamp\ would be the place of the VDI-like file but it is not. The working directory serves as the shared folder.

I found the location of the Vagrant box C:\Users\USER\.vagrant.d\boxes\precise32\0\virtualbox

According to Where is Vagrant saving changes to the VM I found in the VirtualBox GUI the location of the Virtual hard drive file. Which is

C:\Users\USER\VirtualBox VMs\02-lamp_default_1458429875795_57100\

I would like to put this file not in the system drive C:\ but in the data drive which is D:\. How to set such vagrant configuration?

解决方案

For VirtualBox, you can change the location of what is known as the Default Machine Folder through the GUI's Preferences dialog box.

This guide, while a couple of years old, works fine and I followed it last week for how to move an existing vagrant/VirtualBox drive to a new location.

EDIT

I have quoted the steps from the above link/guide, for posterity:

  • Move ~/.vagrant.d to the external drive. I renamed it vagrant_home so I'd be able to see it without ls -a.

  • Set VAGRANT_HOME to /path/to/drive/vagrant_home in ~/.bash_profile.

  • Open the VirtualBox app, open Preferences, and set its Default Machine Folder to /path/to/drive/VirtualBox VMs.

  • Close VirtualBox.

  • Move your VirtualBox VMs folder to the drive. Reopen VirtualBox. You'll see your VMs are listed as "inaccessible". Remove them from the list.

  • For each VM in your VirtualBox VMs folder on the external drive, browse to its folder in Finder and double-click the .vbox file to restore it to the VirtualBox Manager. (Is there an easier method than this?)

  • Finally, move any existing Vagrant directories you've made with vagrant init (these are the directories with a Vagrantfile in each) to the external drive. Since these directories only store metadata you could leave them on your main drive, but it's nice to keep everything together so you could fairly easily plug the whole drive into another machine and start your VMs from there.

这篇关于Vagrant - 为 VirtualBox 设置虚拟硬盘的位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆