Press "Enter" to skip to content

VMware收缩磁盘减少硬盘空间占用

最近发现本地的Centos虚拟机占用的空间越来越大,以至于两个Centos就占用了150G,通过df查看并没有使用那么多,通过网上一些文档,我这里总结了一个解决方案,当前以Centos为例,在VMware里安装VMwareTools,通过工具进行收缩磁盘。

1、在VMware安装VMwareTools

2、挂载VMwareTools镜像,安装tools

mount /dev/cdrom /mnt
cp /mnt/VMwareTools-10.3.10-12406962.tar.gz /root/
tar xf VMwareTools-10.3.10-12406962.tar.gz
cd vmware-tools-distrib/
./vmware-install.pl

一路回车即可

3、开始收缩磁盘

运行以下命令开始收缩磁盘

vmware-toolbox-cmd disk shrink /

如果看到以下报错,请删除磁盘快照,重新运行此命令

Shrink disk is disabled for this virtual machine.

Shrinking is disabled for linked clones, parents of linked clones, 
pre-allocated disks, snapshots, or due to other factors. 
See the User's manual for more information.
Unable to find partition /

如果一切正常,会看到以下内容

待运行到100后,会自动断开连接,然后看到以下内容

4、重启虚拟机

reboot

最后来一张收缩前后的硬盘占用对比


注:本文转自https://blog.whsir.com/post-4764.html

Be First to Comment

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注