• 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:UsersAdministratorVirtualBox VMsubuntuubuntu.vdi" --resize 20480

    就这些了,扩容后系统内还需要另外设置,这里就不赘述了。
    官方文档直通车

  • 相关阅读:
    使用MTA HTML5统计API来分析数据
    .NET Core下操作Git,自动提交代码到 GitHub
    EPPlus.Core 处理 Excel 报错之天坑 WPS
    利用SQL生成模型实体类
    基于.NET Core开发的个人博客发布至CentOS小计
    Windows下MySQL安装流程,8.0以上版本ROOT密码报错及修改
    Redis快速入门及使用
    一些不错的网站
    一些精简的JavaScript代码集合
    MongoDB Shell 命令
  • 原文地址:https://www.cnblogs.com/NoTrace/p/11911654.html
Copyright © 2020-2023  润新知