虚拟机收缩磁盘空间
1.两点注意事项
- 想要对镜像文件进行压缩,要确认vmware中没有该虚拟机的快照,否则无法进行压缩。
- 要进行镜像文件的压缩,必须确保存放虚拟机镜像文件的电脑磁盘拥有至少和虚拟机镜像文件大小相同的空闲空间,也就是说如果虚拟机的镜像文件是20G,那么存放该文件的磁盘必须有至少20G的空闲空间,因为压缩过程的第一部分会生成镜像文件的备份,空间不够的话,最后会提示压缩失败。
2.操作步骤
安装VMWareTool
1).关闭虚拟机的情况下,使用VMWareTool --VM--Install VMWareTool这时,VMWareTool工具安装包,挂到虚拟光驱。
2).打开虚拟机,解压tar包,安INSTALL说明文件,安装VMWareTool。
使用vmware-toolbox-cmd收缩磁盘
1).列出所有可用命令:
[[email protected] ~]# vmware-toolbox-cmd help
Usage: vmware-toolbox-cmd [options] [subcommand]
Type ‘vmware-toolbox-cmd help ‘ for help on a specific command.
Type ‘vmware-toolbox-cmd -v‘ to see the VMware Tools version.
Use ‘-q‘ option to suppress stdout output.
Most commands take a subcommand.
Available commands:
device
disk
script
stat
timesync
upgrade (not available on all operating systems)
2).磁盘相关的命令:
[[email protected] ~]# vmware-toolbox-cmd help disk
disk: perform. disk shrink operations
Usage: vmware-toolbox-cmd disk [args]
Subcommands:
list: list available locations
shrink : wipes and shrinks a file system at the given location
shrinkonly: shrinks all disks
wipe : wipes a file system at the given location
3).列出可收缩的分区:
[[email protected] ~]# vmware-toolbox-www.taohuayuan178.com cmd disk list
/
/boot
/home
/u01
4).收缩分区:
[[email protected] ~]# vmware-toolbox-cmd disk www.boshenyl.cn shrink /home
Please disregard any warnings about disk space for the duration of shrink process.
Progress: 100www.longboshyl.cn [===========>]
Disk shrinking complete.
完毕!