VirtualBox预存空间不足

时间:2019-11-22
本文章向大家介绍VirtualBox预存空间不足,主要包括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 [空间大小]

注意以下几点:

  1. 为了与之前的老版本VBox兼容,也可以使用modifyvdimodifyhd命令(注意前面的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.

  2. -resize之后的数字大小是以MB为单位的,并且是最终大小,比如虚拟机原本大小为10GB,现在需要将其扩充为20GB,那么后面的数字则为20480。另外,此选项支持增大不支持减小哦
  3. 照搬官方原话:

    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.
    大致意思就是只对VDIVHD格式有效,并且仅适用于动态内存...,英语不好,翻译的不太清楚,见谅...

例如我要将我的ubuntu由原本的10GB扩充至20GB,则需要这样:
VBoxManage modifymedium "C:\Users\Administrator\VirtualBox VMs\ubuntu\ubuntu.vdi" --resize 20480

就这些了,
官方文档直通车

原文地址:https://www.cnblogs.com/NoTrace/p/11911654.html