VirtualBox预存空间不足
为已创建虚拟机扩容
近日,闲来无事df
了一下,突然发现/dev/sda1
使用率高达 97%! 后悔当初分配的初始空间太少。虽然目前并不影响使用,无奈强迫症不允许硬盘可用量不足20%
,那就加点吧。
大致看了下官方文档(链接附文末)
,需要使用 modifymedium
这个命令进行扩容,具体用法:
//With the modifymedium command, you can change the characteristics of a disk image after it has been created.
VBoxManage modifymedium [disk|dvd|floppy] <uuid|filename>
[--type normal|writethrough|immutable|shareable|
readonly|multiattach]
[--autoreset on|off]
[--property <name=[value]>]
[--compact]
[--resize <megabytes>|--resizebyte <bytes>]
[--move <path>]
[--setlocation <path>]
也就是 VBoxManage modifymedium [虚拟机所存放的目录] -resize [空间大小]
注意以下几点:
-
为了与之前的老版本VBox兼容,也可以使用
modifyvdi
或modifyhd
命令(注意前面的VBoxManage
不要少了),其用法和modifymedium
相同。官方原话:For compatibility with earlier versions of Oracle VM VirtualBox, the modifyvdi and modifyhd commands are also supported and mapped internally to the modifymedium command.
-
-resize
之后的数字大小是以MB
为单位的,并且是最终大小
,比如虚拟机原本大小为10GB,现在需要将其扩充为20GB,那么后面的数字则为20480
。另外,此选项支持增大不支持减小哦 -
照搬官方原话:
This option currently works only for VDI and VHD formats, and only for the dynamically allocated variants. It can only be used to expand, but not shrink, the capacity. For example, if you originally created a 10 GB disk which is now full, you can use the --resize 15360 command to change the capacity to 15 GB (15,360 MB) without having to create a new image and copy all data from within a virtual machine. Note however that this only changes the drive capacity. You will typically next need to use a partition management tool inside the guest to adjust the main partition to fill the drive.
大致意思就是只对VDI
和VHD
格式有效,并且仅适用于动态内存...
,英语不好,翻译的不太清楚,见谅...
例如我要将我的
ubuntu
由原本的10GB扩充至20GB,则需要这样:
VBoxManage modifymedium "C:\Users\Administrator\VirtualBox VMs\ubuntu\ubuntu.vdi" --resize 20480
就这些了,扩容后系统内还需要另外设置,这里就不赘述了。
官方文档直通车