•
|
The virtual machine is powered off.(先关机)
|
•
|
The virtual disk is not mapped (on Windows guests) or mounted (on Linux guests). You cannot compact a virtual disk while it is mapped or mounted.(没被挂载)
|
•
|
The disk space is not preallocated (被预先分配)for the virtual hard disk. Use the virtual machine settings editor to view the disk information for this virtual hard disk. If the disk space was preallocated, you cannot compact the disk.
|
•
|
If the virtual hard disk is an independent disk, it is in persistent mode.
|
1
|
Select VM > Settings.
|
2
|
On the Hardware tab, select Hard Disk for the virtual hard disk you want to compact.
|
3
|
Select Utilities > Compact
|
4
|
Click OK after the disk compacting process is complete.
|
If you have a virtual disk that grows as data is added, you can shrink it as described in this section.If you allocated all the space for your virtual disk at the time you created it, you cannot shrink it.(就是说,如果你选择了在建立虚拟机的时候一次性分配硬盘空间,那就不能收缩了)
Note: The maximum benefit occurs when you defragment a virtual disk before you shrink it. See Defragmenting Virtual Disks.(最好碎片整理一下)
Shrinking a virtual disk reclaims unused space in the virtual disk. If there is empty space in the disk, this process reduces the amount of space the virtual disk occupies on the host drive.(这就是我要的目的啊啊啊啊)
Shrinking a virtual disk is a convenient way to convert a virtual disk to the format supported by Workstation. Virtual disks created in the new format can be recognized only by VMware Workstation 3.0 and higher.
This section describes the following topics:
Shrinking requires free disk space on the host equal to the size of the virtual disk you are shrinking.(收缩空间时,必须硬盘空间有和虚拟机磁盘一样大的空间,当时我就泪奔了。。。尼玛。。我收缩就是因为硬盘没空间了啊。。不过我在绝望的时候又做了一次defragment,然后compatc了一下,这次没报希望的动作居然成功的把物理硬盘空间腾出来30G,这样一来,我的磁盘空余空间就大于虚拟磁盘空间了)
Shrinking applies only to virtual disks. You cannot shrink physical disks or CD-ROMs.
The shrink feature is not enabled if the virtual machine
The shrink feature is not enabled for a virtual machine if any of its virtual disks are
Note: You can change the mode of a virtual disk before the virtual machine is powered on. See Excluding Disks from Snapshots for a discussion of independent disks.
Shrinking a disk is a two-step process:
When a virtual machine is powered on, you shrink its virtual disks from the VMware Tools control panel. You cannot shrink virtual disks if a snapshot exists. To remove the snapshot if one exists, choose VM > Snapshot > Snapshot Manager > Delete. See Unsupported and Disabled Partitions.
In a Linux or FreeBSD guest operating system, to prepare virtual disks for shrinking, you should run VMware Tools as the root user. This way, you ensure the whole virtual disk is shrunk. Otherwise, if you shrink disks as a nonroot user you cannot wipe the parts of the virtual disk that require root-level permissions.
To shrink a virtual disk:
1. Launch the control panel.
2. Click the Shrink tab.
3. Select the virtual disks you want to shrink, then click Prepare to Shrink.
A dialog box tracks the progress of the wiping process.
Note: If you deselect some partitions, the whole disk is still shrunk. However, those partitions are not wiped for shrinking, and the shrink process does not reduce the size of the virtual disk as much as it could with all partitions selected.
4. Click Yes when VMware Tools finishes wiping the selected disk partitions.
A dialog box tracks the progress of the shrinking process. Shrinking disks may take considerable time.
5. Click OK to finish.
In some configurations, it is not possible to shrink virtual disks. If your virtual machine uses such a configuration, the Shrink tab displays information explaining why you cannot shrink your virtual disks.
For example, you cannot shrink a virtual disk if
虚拟机在使用过程中,虚拟磁盘的大小会不断变大。即使你删除了磁盘中的文件,虚拟磁盘的大小仍然不会缩小。VMWare在VMWare Tools中推出了Shrink这个功能。在安装VMWare Tools后,在没有Snapshot的情况下,在Guest操作系统为Windows的情况下,能有效缩小虚拟磁盘大小。但如果在Guest操作系统为Linux时,此方法效果就不好了,而且有些挂载点无法Shrink。
VMWare还推出了vmware-vdiskmanager工具,也能Shrink虚拟磁盘。在Guest操作系统为Linux时,单独用此工具没有什么效果。需要先在Guest系统中把未使用的 空间清零,在使用vmware-vdiskmanager,效果比较好。可以通过以下步骤有些缩小虚拟磁盘。
1、cat /dev/zero > zero.fill;sync;sleep 1;sync;rm -f zero.fill
在Shell中运行以上命令,能对未使用空间清零,需要较大的空闲空间(跳过这步也可以,只是压缩效果没有这样好)
2、关闭Guest操作系统,进入VMWare安装目录运行:
vmware-vdiskmanager.exe -k "f:/vmware/Fedora11/Fedora11.vmdk"
就可以有效缩小虚拟磁盘的大小,基本达到你用了多少占用多少的效果。
用此方法分别对Guest系统为Fedora11和OpenSolaris10的VMDK文件进行Shrink,效果明显。