如何在VirtualBox或VMware中扩大虚拟机的磁盘

Hard disk drive
flickrsven/Flickr flickrsven / Flickr

When you create a virtual hard disk in VirtualBox or VMware, you specify a maximum disk size. If you want more space on your virtual machine’s hard disk later, you’ll have to enlarge the virtual hard disk and partition.

在VirtualBox或VMware中创建虚拟硬盘时,请指定最大磁盘大小。 如果以后要在虚拟机的硬盘上留出更多空间,则必须扩大虚拟硬盘和分区。

Note that you may want to back up your virtual hard disk file before performing these operations—there’s always a chance something can go wrong, so it’s always good to have backups. However, the process worked fine for us.

请注意,您可能需要在执行这些操作之前备份虚拟硬盘文件-总是有可能出现问题,因此进行备份总是很好的。 但是,该过程对我们来说很好。

更新:在VirtualBox中使用虚拟媒体管理器 (Update: Use the Virtual Media Manager in VirtualBox)

VirtualBox 6 added a graphical option for enlarging and resizing virtual disks. To access it, click File > Virtual Media Manager in the main VirtualBox window.

VirtualBox 6添加了用于扩大和调整虚拟磁盘大小的图形选项。 要访问它,请在VirtualBox主窗口中单击文件>虚拟介质管理器。

Launching the virtual media manager in VirtualBox

Select a virtual hard disk in the list and use the “Size” slider at the bottom of the window to change its size. Click “Apply” when you’re done.

在列表中选择一个虚拟硬盘,然后使用窗口底部的“大小”滑块更改其大小。 完成后,单击“应用”。

You will still have to enlarge the partition on the disk to take advantage of the additional space. The partition remains the same size even while the disk size increases. See the instructions below for more information on enlarging the partition.

您仍然必须扩大磁盘上的分区以利用额外的空间。 即使磁盘大小增加,分区仍保持相同大小。 有关扩大分区的更多信息,请参见以下说明。

Resizing a virtual disk graphically in VirtualBox

在VirtualBox中放大虚拟磁盘 (Enlarge a Virtual Disk in VirtualBox)

To enlarge a virtual disk in VirtualBox, you’ll need to use the VBoxManage command from a Command Prompt window. First, shut down the virtual machine – ensure its state is set to Powered Off, not Saved.

要在VirtualBox中扩展虚拟磁盘,您需要在“命令提示符”窗口中使用VBoxManage命令。 首先,关闭虚拟机–确保其状态设置为Powered Off,而不是Saved。

(Before continuing, you should also delete any snapshots associated with the virtual machine if you use the snapshots feature in VirtualBox. This will ensure you’re modifying the correct virtual disk file and that everything will work properly afterward.)

(在继续操作之前,如果您使用VirtualBox中的快照功能,还应该删除与虚拟机关联的所有快照 。这将确保您修改的是正确的虚拟磁盘文件,并且随后所有操作都会正常进行。)

image

Second, open a Command Prompt window from your Start menu and change to VirtualBox’s program files folder so you can run the command:

其次,从“开始”菜单打开“命令提示符”窗口,然后切换到VirtualBox的程序文件文件夹,以便您可以运行以下命令:

cd “C:\Program Files\Oracle\VirtualBox”

cd“ C:\ Program Files \ Oracle \ VirtualBox”

image

The following command will operate on the VirtualBox virtual disk located at “C:\Users\Chris\VirtualBox VMs\Windows 7\Windows 7.vdi”. It will resize the virtual disk to 81920 MB (80 GB).

以下命令将在位于“ C:\ Users \ Chris \ VirtualBox VMs \ Windows 7 \ Windows 7.vdi”的VirtualBox虚拟磁盘上运行。 它将虚拟磁盘的大小调整为81920 MB(80 GB)。

VBoxManage modifyhd “C:\Users\Chris\VirtualBox VMs\Windows 7\Windows 7.vdi” --resize 81920

(Use two dashes before resize in the command above.)

(在上面的命令中调整大小之前,请使用两个破折号。)

Replace the file path in the command above with the location of the VirtualBox disk you want to resize and the number with the size you want to enlarge the image to (in MB).

将上面命令中的文件路径替换为您要调整大小的VirtualBox磁盘的位置,并将数字替换为您要将图像放大到的大小(以MB为单位)。

Update: In VirtualBox 6.0, released in 2019, you may need to use the following command instead:

更新:在2019年发布的VirtualBox 6.0中,您可能需要改用以下命令:

VBoxManage modifymedium disk “C:\Users\Chris\VirtualBox VMs\Windows 7\Windows 7.vdi” --resize 81920
image

Note that this process doesn’t enlarge the partition on the virtual hard disk, so you won’t have access to the new space yet – see the Enlarge the Virtual Machine’s Partition section below for more information.

请注意,此过程不会扩大虚拟硬盘上的分区,因此您将无法访问新空间–有关更多信息,请参见下面的“扩大虚拟机的分区”部分。

在VMware中放大虚拟磁盘 (Enlarge a Virtual Disk in VMware)

To enlarge a virtual machine’s hard disk in VMware, power off the virtual machine, right-click it, and select Virtual Machine Settings.

要在VMware中扩大虚拟机的硬盘,请关闭虚拟机的电源,右键单击它,然后选择“虚拟机设置”。

image

Select the virtual hard disk device in the list, click the Utilities button, and click Expand to expand the hard disk.

在列表中选择虚拟硬盘设备,单击“实用程序”按钮,然后单击“展开”以展开硬盘。

image

Enter a larger maximum disk size and click the Expand button. VMware will increase the size of your virtual disk, although its partitions will remain the same size – see below for information on enlarging the partition.

输入更大的最大磁盘大小,然后单击“扩展”按钮。 VMware将增加虚拟磁盘的大小,尽管其分区大小将保持不变–有关扩大分区的信息,请参见下文。

image

扩大虚拟机的分区 (Enlarge the Virtual Machine’s Partition)

You now have a larger virtual hard disk. However, the operating system’s partition on your virtual hard disk is the same size, so you won’t be able to access any of this space yet.

您现在拥有更大的虚拟硬盘。 但是,虚拟硬盘上操作系统的分区大小相同,因此您将无法访问任何此空间。

image

You’ll now need to extend the guest operating system’s partition as if you were enlarging a partition on a real hard disk in a physical computer. You can’t enlarge the partition while the guest operating system is running, just as you can’t enlarge your C:\ partition while Windows is running on your computer.

现在,您需要扩展来宾操作系统的分区,就像在物理计算机上的真实硬盘上扩大分区一样。 来宾操作系统运行时,您无法扩大分区,就像Windows运行于计算机上时,您无法扩大C:\分区一样。

You can use a GParted live CD to resize your virtual machine’s partition – simply boot the GParted ISO image in your virtual machine and you’ll be taken to the GParted partition editor in a live Linux environment. GParted will be able to enlarge the partition on the virtual hard disk.

您可以使用GParted live CD来调整虚拟机分区的大小–只需在虚拟机中引导GParted ISO映像,即可进入实时Linux环境中的GParted分区编辑器。 GParted将能够扩大虚拟硬盘上的分区。

First, download the GParted live CD’s ISO file from here.

首先, 从此处下载GParted live CD的ISO文件

Load the ISO file into your virtual machine by going into the virtual machine’s settings window, selecting your virtual CD drive, and browsing to the ISO file on your computer.

通过进入虚拟机的设置窗口,选择虚拟CD驱动器并浏览到计算机上的ISO文件,将ISO文件加载到虚拟机中。

image

Boot (or restart) your virtual machine after inserting the ISO image and the virtual machine will boot from the ISO image. GParted’s live CD will ask you several questions while booting – you can press Enter to skip them for the default options.

插入ISO映像后引导(或重新启动)虚拟机,虚拟机将从ISO映像引导。 GParted的实时CD在引导时会询问您几个问题–您可以按Enter跳过它们以获取默认选项。

Once GParted is booted, right-click the partition you want to enlarge and select Resize/Move.

引导GParted后,右键单击要放大的分区,然后选择“调整大小/移动”。

image

Specify a new size for the partition – for example, drag the slider all the way to the right to use all the available space for the partition. Click the Resize/Move button after you’ve specified the space you want to use.

指定分区的新大小–例如,将滑块一直向右拖动以使用该分区的所有可用空间。 指定要使用的空间后,单击“调整大小/移动”按钮。

image

Finally, click the Apply button to apply your changes and enlarge the partition.

最后,单击“应用”按钮以应用更改并扩大分区。

image

After the resize operation completes, restart your virtual machine and remove the GParted ISO file. Windows will check the file system in your virtual machine to ensure it’s working properly — don’t interrupt this check.

调整大小操作完成后,重新启动虚拟机并删除GParted ISO文件。 Windows将检查您的虚拟机中的文件系统以确保其正常运行-不要中断此检查。

image

The virtual machine’s partition will now take up the entire virtual hard disk, so you’ll have access to the additional space.

现在,虚拟机的分区将占用整个虚拟硬盘,因此您将可以访问额外的空间。



Note that there are easier ways to get more storage – you can add a second virtual hard disk to your virtual machine from its settings window. You can access the other hard disk’s contents on a separate partition – for example, if you’re using a Windows virtual machine, the other virtual hard disk will be accessible at a different drive letter inside your virtual machine.

请注意,有更多获取更多存储空间的简便方法–您可以从虚拟机的“设置”窗口中向其虚拟机添加第二个虚拟硬盘。 您可以在单独的分区上访问另一个硬盘的内容-例如,如果您使用Windows虚拟机,则可以在虚拟机内部的其他驱动器号处访问另一个虚拟硬盘。

翻译自: https://www.howtogeek.com/124622/how-to-enlarge-a-virtual-machines-disk-in-virtualbox-or-vmware/

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值