2009年8月26日 星期三

How to compact VHD file 如何縮小VHD檔(Hyper-V and Virtual Server 2005)

How to compact VHD file 如何縮小VHD檔

[Hyper-V]
1.Virtual Machine開機,登入Windows系統(Guest OS),執行磁碟重組
2.下載Sysinternals Suite
    http://technet.microsoft.com/en-us/sysinternals/bb842062
   或只下載SDelete
   http://technet.microsoft.com/en-us/sysinternals/bb897443
3.在Windows系統(Guest OS)執行sdelete c:/ -z
4.Virtual Machine關機
5.Hyper-V Manager使用[編輯虛擬硬碟精靈]壓縮VHD檔
  http://technet.microsoft.com/zh-tw/library/cc755149(WS.10).aspx


[Virtual Server]
1.Virtual Server Administration Website
mount C:\Program Files\Microsoft Virtual Server\Virtual Machine Additions\Precompactor.iso

2.run Precompact.exe in Guest OS

3.shutdown Guest OS

4.Virtual Server Administration Website
(1)Under Virtual Disks, click Inspect(檢查)(2)In the Known virtual hard disks list, click the virtual hard disk that you want to compact
Note You can also type the path of the virtual hard disk in the Fully qualified path to file box.
(3)Click Inspect
(4)Under VirtualHardDiskName.vhd Actions, click Compact virtual hard disk, and then click Compact(壓縮).


[Virtual Server 2005 R2 Release Notes]
you can find Virtual Disk Precompactor.iso in the folder: %systemdrive%\Program Files\Microsoft Virtual Server\Virtual Machine Additions\.

To use Virtual Disk Precompactor, you must first capture Virtual Disk Precompactor.iso using the standard procedure for capturing .iso files as described in "To add or remove a CD or DVD drive" in the Virtual Server 2005 Administrator's Guide.

If your virtual machine is running when you capture Virtual Disk Precompactor.iso, Virtual Disk Precompactor starts automatically. If you click Yes when prompted, Virtual Disk Precompactor precompacts all virtual hard disks for this virtual machine. If Virtual Disk Precompactor does not start automatically, you can start it by navigating to the CD drive of the guest operating system and double-clicking Precompact.exe.

Alternatively, you can also run Virtual Disk Precompactor from the command line by navigating to the CD drive of the guest operating system and typing Precompact. The available parameters are:

-Help - Displays help for the precompactor.

-Silent - Runs the precompactor in unattended mode.

-SetDisks - Specifies the disks to be precompacted. If this parameter isn't specified, then all virtual hard disks for this virtual machine are compacted. For example, the following command will precompact your C, D, and E drives in unattended mode:

Precompact -Silent -SetDisks:CDE
Note
You can only compact dynamically expanding VHDs. To compact a fixed-size VHD, you can convert it to a dynamically expanding VHD, compact it, and then convert it back to a fixed size VHD.

[Reference]
http://support.microsoft.com/default.aspx?scid=kb;en-us;888760

沒有留言: