分类: 系统运维
2013-09-11 11:32:21
. |
Shutdown VM and remove from inventory
|
|
---|---|---|
. |
Copy vmx, vmdk, and *-flat.vmdk to Backup
SSH to the correct host, then copy: |
|
. |
Determine your desired shrunken file size in blocks (vmdk_shrunken)Decide your desired shrunken vmdk file size in GB (x) and use the following formula to determine what I will call the "vmdk_shrunken" size: vmdk_shrunken = [x * (1024*1024*1024)] / 512 I created this equation based on information in the referenced article: "How to Shrink a VMDK file in ESX" see below. |
|
. |
Modify RW Block size value in original *.vmdk and save.vi /path/to/original_vmdk
locate the lines that look like: Change the value beside RW to the value of vmdk_shrunken from above. Save the change. |
|
. |
Export the shrunken vmdk file to BackupYou'll need to export a new vmdk file from the edit you just made without overwriting the original: Use vmfstools -i /path/to/original/original_vmdkfilename.vmdk /path/to/backup/new_vmdkfilename.vmdk (with new filesize) IMPORTANT: If resizing a VMDK with snapshots, either remove the snapshots OR edit each snapshot using info from Step 4 for each snapshot file, then perform Step 5 on the latest snapshot file in the CID chain. IF YOU HAVE LIVE SNAPSHOTS AND DON'T DO THIS, YOU WILL LOSE DATA! |
|
. |
Delete the original *.vmdk and *-flat.vmdk filesNow that you have a backup of the original vmdk's and vmx as well as a newly exported/resized *.vmdk and *-flat.vmdk, you can delete the original files.
rm -rf |
|
. |
Copy the new resized files to the correct datastoreUse vmfstools -i /path/to/backup/new_vmdkfile.vmdk /path/to/original/original_vmdkfilenamename.vmdk (with new filesize) |
|
. |
Re-add VM to inventory
|
|
. |
Remove old disk from VM, add new disk to VMin vSphere, edit settings for the VM and remove the entry for the original HDD. Add the new vmdk and provide the path to it. Save settings. |
|
. |
Remove VM from inventory, Re-re-add VM to inventoryNot sure why, but my VM wouldn't start after performing this step. |
|
. |
Turn on VM and enable the diskFor windows VM's, you'll need to get into Disk Management and switch the disk to "Online" status. |
|
. |
Reboot the VMThis step will be necessary for VM's (like mine) who run services from the affected disk. |