使用VirtualBox时,发现一个分区大小不够用,使用resize扩容,提示失败。
D:\VirtualBox>VBoxManage modifyhd "D:\vx\docker1\docker1.vdi" --resize 15480
0%...
Progress state: VBOX_E_NOT_SUPPORTED
VBoxManage.exe: error: Failed to resize medium
VBoxManage.exe: error: Resizing to new size 16231956480 is not yet supported for medium 'D:\vx\docker1\docker1.vdi'
VBoxManage.exe: error: Details: code VBOX_E_NOT_SUPPORTED (0x80bb0009), component MediumWrap, interface IMedium
VBoxManage.exe: error: Context: "enum RTEXITCODE __cdecl handleModifyMedium(struct HandlerArg *)" at line 768 of file VBoxManageDisk.cpp
解决方案
在命令行先创建一个空的vdi虚拟机介质,创建时设置大小为扩容后的大小,然后使用克隆命令进行虚拟机介质克隆。
创建新虚拟介质命令
D:\VirtualBox>VBoxManage.exe createhd -filename "D:\vx\docker1\server2008r2_810g" -size 151920 -format VDI -variant Standard
0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%
Medium created. UUID: aac9dd3f-ba41-46a8-bb49-c6559fef0360
克隆命令
D:\VirtualBox>VBoxManage.exe clonehd "D:\vx\docker1\docker1.vdi" "D:\vx\docker1\server2008r2_810g.vdi" --existing
0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%
Clone medium created in format 'VDI'. UUID: aac9dd3f-ba41-46a8-bb49-c6559fef0360
此时原来的那个docker1.vdi 已经克隆到server2008r2_810g.vdi了,再执行以下VBoxManage modifyhd 命令即可。
D:\VirtualBox>VBoxManage modifyhd "D:\vx\docker1\server2008r2_810g.vdi" --resize 151920
0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%
PS:注意-size -format 等命令,它们前面貌似只能有一个空格,否则会提示
Syntax error: Invalid parameter ' -format' .....