如何在VirtualBox中的固定磁盘和动态磁盘之间进行转换

VirtualBox allows you to choose either a dynamically allocated or fixed size disk when creating a new virtual hard disk file. Dynamically allocated disks are faster to create and can grow to larger sizes. Fixed size disks may be faster to use, but can’t grow any larger once they fill up. You can convert between the two formats and resize disks, if you like.

在创建新的虚拟硬盘文件时,VirtualBox允许您选择动态分配的磁盘或固定大小的磁盘。 动态分配的磁盘创建速度更快,并且可以增长到更大的大小。 固定大小的磁盘使用起来可能更快,但是一旦填满就无法再增大。 您可以根据需要在两种格式之间转换并调整磁盘大小。

Before continuing, we recommend shutting down the virtual machine rather than suspending it and saving its state. VirtualBox should say the virtual machine is “Powered Off.”

在继续之前,我们建议关闭虚拟机,而不是挂起虚拟机并保存其状态。 VirtualBox应该说虚拟机已关闭电源。

第一步:找到VBoxManage命令并打开命令提示符 (Step One: Locate the VBoxManage Command and Open a Command Prompt)

VirtualBox allows you to convert a fixed disk to a dynamic disk or a dynamic disk to a fixed disk, but this option isn’t exposed in its graphical interface. Instead, you have to use the VBoxManage.exe command.

VirtualBox允许您将固定磁盘转换为动态磁盘,或将动态磁盘转换为固定磁盘,但是此选项未在其图形界面中显示。 相反,您必须使用VBoxManage.exe命令。

Locate this command to continue. On Windows, you’ll find it in the VirtualBox program directory, which is  C:\Program Files\Oracle\VirtualBox  by default. If you installed VirtualBox to another directory, look there instead.

找到此命令以继续。 在Windows上,您可以在VirtualBox程序目录中找到它,该目录为C:\Program Files\Oracle\VirtualBox 默认情况下。 如果将VirtualBox安装到另一个目录,请查看那里。

Open a Command Prompt window. To do this, open the Start menu, type cmd , and press Enter.

打开命令提示符窗口。 为此,请打开“开始”菜单,键入cmd ,然后按Enter。

Type cd into the Command Prompt, followed by the path of the folder where the VBoxManage command is. You’ll need to enclose it in quotes.

在命令提示符中键入cd ,然后输入VBoxManage命令所在的文件夹的路径。 您需要将其用引号引起来。

You can quickly do this by typing cd into the Command Prompt window, and then dragging and dropping the folder icon from the file manager’s address bar into the Command Prompt.

通过在命令提示符窗口中键入cd ,然后将文件夹图标从文件管理器的地址栏中拖放到命令提示符中,可以快速完成此操作。

If you’re using the default path, it should look like the following:

如果您使用的是默认路径,则该路径应如下所示:

cd "C:\Program Files\Oracle\VirtualBox"

NOTE: These instructions assume you’re using VirtualBox on Windows. If you’re using VirtualBox on macOS or Linux, you can just open a Terminal window and run the vboxmanage command normally, as you would any other command.

注意:这些说明假定您在Windows上使用VirtualBox。 如果在macOS或Linux上使用VirtualBox,则可以像打开其他任何命令一样,仅打开Terminal窗口并正常运行vboxmanage命令。

第二步:找到要转换的磁盘的路径 (Step Two: Locate the Path to the Disk You Want To Convert)

Run the following command in the command prompt window to view a list of all the virtual hard disks on your computer:

在命令提示符窗口中运行以下命令,以查看计算机上所有虚拟硬盘的列表:

VBoxManage.exe list hdds

Look through the list and identify the file path to the virtual disk you want to convert. Let’s say we want to modify the virtual disk associated with the virtual machine named “Windows”. As we can see in the output below, the path to that virtual disk on our system is C:\Users\chris\VirtualBox VMs\Windows\Windows.vdi .

浏览列表,并确定要转换的虚拟磁盘的文件路径。 假设我们要修改与名为“ Windows”的虚拟机关联的虚拟磁盘。 从下面的输出中可以看到,系统上该虚拟磁盘的路径为C:\Users\chris\VirtualBox VMs\Windows\Windows.vdi

第三步:转换虚拟磁盘 (Step Three: Convert the Virtual Disk)

You can now use the VBoxManage command to convert the virtual disk from fixed to dynamic, or from dynamic to fixed.

现在,您可以使用VBoxManage命令将虚拟磁盘从固定磁盘转换为动态磁盘,或从动态磁盘转换为固定磁盘。

To convert a virtual disk from fixed to dynamic, run the following command:

要将虚拟磁盘从固定磁盘转换为动态磁盘,请运行以下命令:

VBoxManage.exe clonemedium disk "C:\path\to\source.vdi" "C:\path\to\destination.vdi" –variant Standard

For example, if the source disk is located at C:\Users\chris\VirtualBox VMs\Windows\Windows.vdi and you want to create a new disk named Windows-dynamic.vdi in the same folder, you’d run:

例如,如果源磁盘位于C:\Users\chris\VirtualBox VMs\Windows\Windows.vdi并且您想要在同一文件夹中创建一个名为Windows-dynamic.vdi的新磁盘,则可以运行:

VBoxManage.exe clonemedium disk "C:\Users\chris\VirtualBox VMs\Windows\Windows.vdi" "C:\Users\chris\VirtualBox VMs\Windows\Windows-dynamic.vdi" –variant Standard

To convert a virtual disk from dynamic to fixed, run the following command:

要将虚拟磁盘从动态磁盘转换为固定磁盘,请运行以下命令:

VBoxManage.exe clonemedium disk "C:\path\to\source.vdi" "C:\path\to\destination.vdi" –variant Fixed

For example, if the source disk is located at C:\Users\chris\VirtualBox VMs\Windows\Windows.vdi and you want to create a new disk named Windows-fixed.vdi in the same folder, you’d run:

例如,如果源磁盘位于C:\Users\chris\VirtualBox VMs\Windows\Windows.vdi并且您想在同一文件夹中创建一个名为Windows-fixed.vdi的新磁盘,请运行:

VBoxManage.exe clonemedium disk "C:\Users\chris\VirtualBox VMs\Windows\Windows.vdi" "C:\Users\chris\VirtualBox VMs\Windows\Windows-fixed.vdi" –variant Fixed

第四步:删除旧的虚拟磁盘 (Step Four: Remove the Old Virtual Disk)

The above command just clones the existing disk. You end up with both the original disk file and a new disk file.

上面的命令只是克隆现有磁盘。 您最终将获得原始磁盘文件和新磁盘文件。

First, you’ll need to actually remove the existing virtual disk from VirtualBox. In VirtualBox, right-click the virtual machine that uses the virtual disk and select “Settings”.

首先,您实际上需要从VirtualBox中删除现有的虚拟磁盘。 在VirtualBox中,右键单击使用虚拟磁盘的虚拟机,然后选择“设置”。

Select “Storage” to view connected storage devices. Right-click the original VDI and select “Remove Attachment”. Click “OK” afterwards.

选择“存储”以查看连接的存储设备。 右键单击原始VDI,然后选择“删除附件”。 然后单击“确定”。

The below process will delete the original disk file from your drive. Warning: You may want to back up the original disk file if you haven’t already, just in case anything goes wrong with this process.

以下过程将从驱动器中删除原始磁盘文件。 警告:如果尚未备份原始磁盘文件,则可能需要备份原始磁盘文件,以防万一此过程出现问题。

In the Command Prompt, run the following command to view a list of all virtual disks on your computer:

在命令提示符中,运行以下命令以查看计算机上所有虚拟磁盘的列表:

VBoxManage.exe list hdds

Locate the UUID of the original disk you want to delete. You can copy it to your clipboard by selecting it with your mouse’s left mouse button and then right-clicking it.

找到您要删除的原始磁盘的UUID。 您可以使用鼠标的左键选择它,然后右键单击它,将其复制到剪贴板。

Run the following command to remove the original disk from VirtualBox’s registry and delete it. You can right-click in the Command Prompt window to paste the UUID.

运行以下命令,从VirtualBox的注册表中删除原始磁盘并删除它。 您可以在“命令提示符”窗口中右键单击以粘贴UUID。

VBoxManage.exe closemedium UUID --delete

第五步:重命名新磁盘 (Step Five: Rename the New Disk)

You should now rename the new disk file so that it has the same name as the original one. Just navigate to it in a File Explorer or Windows Explorer window.

现在,您应该重命名新的磁盘文件,使其具有与原始磁盘文件相同的名称。 只需在文件资源管理器或Windows资源管理器窗口中导航到它即可。

Right-click the VDI file, select “Rename”, and change it to the original name. For example, here we renamed the Windows-fixed.vdi file we created to Windows.vdi.

右键单击VDI文件,选择“重命名”,然后将其更改为原始名称。 例如,在这里我们将创建的Windows-fixed.vdi文件重命名为Windows.vdi。

Once you’ve renamed the disk, remove the old disk name from VirtualBox. Click File > Virtual Media Manager in VirtualBox and locate the renamed disk’s original name—it will have a yellow warning icon to the left of it. Right-click it and select “Remove”. Click “Remove” again to confirm and close “Close”.

重命名磁盘后,从VirtualBox中删除旧磁盘名称。 单击VirtualBox中的“文件”>“虚拟介质管理器”,然后找到重命名的磁盘的原始名称-它的左侧将带有一个黄色警告图标。 右键单击它,然后选择“删除”。 再次单击“删除”以确认并关闭“关闭”。

第六步:将磁盘插入VirtualBox (Step Six: Insert the Disk In VirtualBox)

Head back into VirtualBox, right-click the virtual machine associated with the virtual disk, and select “Settings”. Under Storage, right-click the SATA controller and select “Add Hard Disk”.

返回VirtualBox,右键单击与虚拟磁盘关联的虚拟机,然后选择“设置”。 在“存储”下,右键单击SATA控制器,然后选择“添加硬盘”。

Select “Choose Existing Disk” and browse to the file you just renamed.

选择“选择现有磁盘”并浏览到刚刚重命名的文件。

Click “OK” to close the virtual machine settings window. You should now be able to boot the virtual machine normally. Its disk will be either a fixed or dynamic disk—whichever you converted it to.

单击“确定”关闭虚拟机设置窗口。 现在,您应该能够正常启动虚拟机了。 它的磁盘将是固定磁盘或动态磁盘,无论您将其转换为哪个磁盘。

翻译自: https://www.howtogeek.com/312456/how-to-convert-between-fixed-and-dynamic-disks-in-virtualbox/

  • 2
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值