vmware 磁盘清理---还原虚拟机硬盘大小
linux host:
1、使用dd命令将客户机未使用的磁盘空间用0填满
cat /dev/zero > zero.fill;sync;sleep 1;sync;rm -f zero.fill
2、转换磁盘镜像文件
qemu-img convert -O qcow2 abc.img abc_new.img
Windows host:
.\vmware-vdiskmanager.exe -k "E:\Redhat001\Red Hat Enterprise Linux6 64 位-cl1.vmdk"
###############################################################################
1、打开linux虚拟机,清空linux虚拟机缓存
To free pagecache: # echo 1 > /proc/sys/vm/drop_caches To free dentries and inodes: # echo 2 > /proc/sys/vm/drop_caches To free pagecache, dentries and inodes: echo 3 > /proc/sys/vm/drop_caches
2、清理yum缓存
yum clean headers 清理/var/cache/yum 的headers yum clean packages 清理/var/cache/yum下的软件包 yum clean metadata .... yum clean all
3、 使用zero数据填充磁盘的剩余空间,最后会提示空间不足。忽略
cat /dev/zero > zero
sync
rm -rf zero
4、 关闭虚拟机
在本地物理机上,到vmvare安装目录下执行 C:\Program Files (x86)\VMware\VMware Workstation>vmware-vdiskmanager.exe -d C:\workstation\centos7.5\centos7.5.vmdk Defragment: 100% done. Defragmentation completed successfully. C:\Program Files (x86)\VMware\VMware Workstation>vmware-vdiskmanager.exe -k C:\workstation\centos7.5\centos7.5.vmdk Shrink: 100% done. Shrink completed successfully.
QQ:328864113 微信:wuhg2008