我已经用完了虚拟机磁盘(vmdk)上的空间,需要调整虚拟映像的大小。使用命令调整大小
vboxmanage modifyhd Machine-disk1.vmdk --resize 30720
给出错误
Progress state: VBOX_E_NOT_SUPPORTED
VBoxManage: error: Resize hard disk operation for this format is not implemented yet!
如何调整vmdk映像的大小?
我已经用完了虚拟机磁盘(vmdk)上的空间,需要调整虚拟映像的大小。使用命令调整大小
vboxmanage modifyhd Machine-disk1.vmdk --resize 30720
给出错误
Progress state: VBOX_E_NOT_SUPPORTED
VBoxManage: error: Resize hard disk operation for this format is not implemented yet!
如何调整vmdk映像的大小?
当前回答
我可以通过克隆vmdk,然后修改和调整它的大小来调整它的大小。
vboxmanage clonehd "virtualdisk.vmdk" "new-virtualdisk.vdi" --format vdi
vboxmanage modifyhd "new-virtualdisk.vdi" --resize 30720
其他回答
这里所有的办法都试过了,但似乎都不管用。经过几个小时的挖掘,我发现了这篇博客文章,就像魔法一样,一切都起作用了。我需要做一些调整,所以这是修改后的版本。使用Docker 17.06.0-ce版本测试,构建02c1d87。
一旦开发人员真正开始容器化他们的应用程序,他们通常会生成大量的映像,并迅速填满默认分配给Docker虚拟机的20GB硬盘空间。为了确保Docker虚拟机有足够的磁盘空间,我们应该将/dev/sda1的大小调整为一个更合理的数字。
Download GParted Live CD/USB/HD/PXE Bootable Image. Stop the Docker virtual machine docker-machine stop default. Boot2Docker package installer ships with a VMDK volume, which VirtualBox’s native tools cannot resize. In order to resize the Docker disk volume, first clone the VDI volume from the default VMDK volume vboxmanage clonehd /full/path/to/disk.vmdk /full/path/to/disk_resized.vdi --format VDI --variant Standard. Resize the newly cloned VDI volume to the desired capacity. We recommend at least 64GB vboxmanage modifyhd /full/path/to/disk_resized.vdi --resize <size in MB>. Launch the VirtualBox application, select default VM and click on the “Settings” gear on top. Click on the “Storage” icon. Remove the default VMDK volume. Add a new IDE controller. Mount the GParted ISO via the “Add CD/DVD Device” option. Mount the cloned VDI volume via the “Add CD/DVD Device” option. If you are running Docker on a computer with a solid-state hard drive, please make sure the “Solid-state Drive” option is selected for the cloned VDI volume. Click on the “Start” icon to boot up the Docker virtual machine, which will launch the GParted ISO. Select “GParted Live (Default settings)”. Set the policy for handling keymaps to “Don’t touch keymap”. Set language preference to option “33”, which maps to “US English”. Select option “1” to run “Forcevideo” and configure X manually. Keep the default resolution of “1024×760” by selecting option “2”. Keep the default “vesa” as the VGA card. Keep the default colour depth of “24” by selecting option “0”. Once GParted launches, click on the “Resize/Move” icon. Set the new disk volume size to desired size by dragging the slider. In this example, the maximum size is 127,035MB. Click on the “Resize/Move” button to start the process. Confirm the resizing operation by clicking on the “Apply” button. Power off the machine after the resizing operation finishes. Remove the GParted ISO. Log into the Docker virtual machine to verify that the volume resizing was successful by starting machine docker-machine start default If you experience network issues, restart the docker-machine
如果您希望结束返回vmdk硬盘(可能您也有兴趣在vwmare中使用该磁盘),完整的步骤如下:
VBoxManage clonemedium "source.vmdk" "cloned.vdi" --format vdi
VBoxManage modifymedium "cloned.vdi" --resize 51200
VBoxManage clonemedium "cloned.vdi" "resized.vmdk" --format vmdk
以上将调整硬盘大小至50GB (50 * 1024MB)。 要完成事情,你也需要调整驱动器的大小!要实现这一点,您可能需要下载gparted iso,并从该iso引导来调整驱动器的大小(从virtualbox设置中选择iso)。
附注:如果你的新大小太小,即使你的新vdi文件也会得到同样的错误。
vmdk:
相当固定的大小分配(步骤1、2)。 即使在扩展之后,也无法在vmdk的操作系统中使用(步骤3、4、5)
步骤:
1)转换为“。VBoxManage clonehd v1。vmdk v1。Vdi——格式化Vdi
2)使用命令行扩展大小(参考:tvial的博客一步一步的信息)
OR
从VirtualBox中的虚拟媒体管理器展开。
[现在-在vm内部]
3)扩大驱动器的大小,使用新的分配(例如Ubuntu在虚拟机上运行:使用GParted)
4)扩展文件系统- lvextend - l +50G <file-system-identifier>
说明:
$ lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
...
sda 8:0 0 200G 0 disk
└─sda1 8:1 0 200G 0 part
├─myfs-vg-cloud 253:0 0 99G 0 lvm /
└─myfs-vg-swap-1 253:1 0 980M 0 lvm [SWAP]
$ lvextend -L +100G /dev/mapper/myfs-vg-cloud
$ lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
...
sda 8:0 0 200G 0 disk
└─sda1 8:1 0 200G 0 part
├─myfs-vg-cloud 253:0 0 199G 0 lvm /
└─myfs-vg-swap-1 253:1 0 980M 0 lvm [SWAP]
5)扩展/home - resize2fs <file-system-identifier>
说明:
$ df -h /home/
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/myfs-vg-cloud 97G 87G 6.0G 94% /
$ resize2fs /dev/mapper/myfs-vg-cloud
$ df -h /home/
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/myfs-vg-cloud 196G 87G 101G 47% /
您的系统现在必须准备好使用扩展分配!!
这是一种调整VirtualBox磁盘大小的方法,无论它是固定格式的磁盘还是动态格式的磁盘。具体来说,它可以防止磁盘是固定格式时出现的错误。
⚠️备份虚拟磁盘。你永远不知道会出什么问题。
在主机上:
Open a terminal window. On Windows: Open the command prompt cmd. Go to the directory with the virtual disk you want to resize. For example: cd "My VMs" Create a new VirtualBox disk with your desired filename, size (in megabytes) and format (either Standard (dynamic) or Fixed). For example, to create a 50 GB fixed-format disk called MyNewDisk.vdi: VBoxManage createmedium --filename "MyNewDisk.vdi" --size 50000 --variant Fixed If VBoxManage is not recognized as a command, specify the full path to it. It can be found in the VirtualBox installation directory. On Windows the above command would become: "C:\Program Files\Oracle\VirtualBox\VBoxManage.exe" createmedium --filename "MyNewDisk.vdi" --size 50000 --variant Fixed Copy the original disk to the new disk. VBoxManage clonemedium "MyOriginalDisk.vdi" "MyNewDisk.vdi" --existing The resize is done! You can check the properties of the new disk if you want: VBoxManage showmediuminfo "MyNewDisk.vdi" Change the virtual machine to use the new disk instead.
接下来,在您的客户操作系统上,您需要调整分区大小以使用新的可用空间。
为了缩小图像大小,我使用以下步骤:
在客户端机器cat /dev/zero > z;sync;sleep 3;sync;rm -f z 关闭客户端机器 在主机VBoxManage clonehd”源代码上。vmdk”“克隆。Vdi”——格式化Vdi 在VBoxManage modifyhd克隆的主机上。vdi,紧凑 在主机VBoxManage clonehd“克隆。vdi”“调整大小。Vmdk "——格式化Vmdk