我在虚拟机上安装了CentOS(主机操作系统是Windows 7).我创建了磁盘映像文件,即VDI文件(动态分配的映像).最近,当我删除CentOS中的大文件时,我磁盘上的VDI文件不会减少.为什么?如何解决这个问题?
解决方法:
删除VM中的文件时,VirtualBox不会自动回收磁盘空间(在主机上).要缩小磁盘映像,您需要
首先,将所有可用空间(对于HDD上的所有分区和逻辑卷)清零,然后关闭VM.
cat / dev / zero> z; sync; sleep 3; sync; rm -f z
然后,使用以下命令压缩VDI.
VBoxManage modifyhd /path/to/image.vdi –compact
With the –compact option, can be used to compact disk images, i.e. remove blocks that only contains zeroes. This will shrink a dynamically allocated image again; it will reduce the physical size of the image without affecting the logical size of the virtual disk. Compaction works both for base images and for diff images created as part of a snapshot.
顺便说一句:对于VMWare(.vmdk),您需要使用vmware-vdiskmanager -k xxx.vmdk来执行相同操作.
标签:linux,virtualbox
来源: https://codeday.me/bug/20190517/1123110.html