Professional Documents
Culture Documents
You can find the most up-to-date technical documentation on the VMware Web site at: http://www.vmware.com/support/ The VMware Web site also provides the latest product updates. If you have comments about this documentation, submit your feedback to: docfeedback@vmware.com
2008 VMware, Inc. All rights reserved. Protected by one or more U.S. Patent Nos. 6,397,242, 6,496,847, 6,704,925, 6,711,672, 6,725,289, 6,735,601, 6,785,886, 6,789,156, 6,795,966, 6,880,022, 6,944,699, 6,961,806, 6,961,941, 7,069,413, 7,082,598, 7,089,377, 7,111,086, 7,111,145, 7,117,481, 7,149,843, 7,155,558, 7,222,221, 7,260,815, 7,260,820, 7,269,683, 7,275,136, 7,277,998, 7,277,999, 7,278,030, 7,281,102, 7,290,253, 7,356,679, 7,409,487, 7,412,492, 7,412,702, 7,424,710, and 7,428, 636; patents pending. VMware, the VMware boxes logo and design, Virtual SMP, and VMotion are registered trademarks or trademarks of VMware, Inc. in the United States and/or other jurisdictions. All other marks and names mentioned herein may be trademarks of their respective companies.
VMware, Inc.
Contents
AboutThisBook
5 7
UsingVMwareVirtualDiskManager
AboutVirtualDiskManager 7 UsesofVirtualDiskManager 8 VMwareDiskMount 8 RunningVirtualDiskManager 8 ExamplesUsingVirtualDiskManager 10 CreatingaVirtualDisk 10 ConvertingaVirtualDisk 10 IncreasingtheSizeofanExistingVirtualDisk 10 RenamingorRelocatingaVirtualDisk 11 DefragmentingaVirtualDisk 11 ShrinkingaVirtualDisk 12
VMware, Inc.
VMware, Inc.
ThisVMwaremanual,theVirtualDiskManagerUsersGuide,providesanintroductiontousingthe vmware-vdiskmanagercommandlineutility.
Revision History
Thisbookisrevisedwitheachreleaseoftheproductorwhennecessary.Arevisedversioncancontainminor ormajorchanges.Table P1summarizesthesignificantchangesineachversionofthisguide. Table P-1. Revision History
Revision Date 20070420 20070607 20080128 20080407 20080407 Description of Changes FirstversionoftheVirtualDiskManagerUsersGuide. UpdatewithsupportforLinuxhostsandremotevirtualdisks. Added-toption5forthecompressedstreamvirtualdisktype. Added-Soptiontoswitchremotesystemfromtargettosource. ReissuedwithVMwareWorkstation6.5andVMwareServer2.0.
Intended Audience
ThisbookisintendedforanyonewhousesVMwareVirtualDiskManager.Userstypicallyincludepeoplewho dosoftwaredevelopmentandtestingorworkwithmultipleoperatingsystemsorcomputingenvironments: systemadministrators,applicationdevelopers,QAengineers,andanyonewhowantstocreate,manage,and modifyvirtualdiskfilesfromscriptsoratthecommandline.
Documentation Resources
ToaccessthecurrentversionsofVMwareAPIandSDKdocumentation,goto: http://www.vmware.com/support/pubs/sdk_pubs.html ToaccessthecurrentversionsofotherVMwaremanuals,goto: http://www.vmware.com/support/pubs
Documentation Feedback
VMwarewelcomesyoursuggestionsforimprovingourdocumentation.Sendyourfeedbackto: docfeedback@vmware.com
VMware, Inc.
Online Support
YoucansubmitquestionsorpostcommentstotheDeveloperCommunitySDKsandAPIsforum,whichis monitoredbyVMwaretechnicalsupportandproductteams.Toaccesstheforum,goto: http://communities.vmware.com/community/developer
Support Offerings
TofindouthowVMwaresupportofferingscanhelpmeetyourbusinessneeds,goto: http://www.vmware.com/support/services
VMware, Inc.
VMware, Inc.
Thecommandsyntaxisoneof:
vmware-vdiskmanager <options> <diskname> vmware-vdiskmanager <options> <drive|mountpoint>
Use<diskname>tospecifythenameofavirtualdiskfile(VMDK)thatyouwanttocreate,manage,ormodify. Thevirtualdiskfilemusthavea.vmdkextension.Youmayspecifyapathinfrontofthefilename.Forexample: C:\DocumentsandSettings\<user>\My Documents\MyVirtualMachines\VMname\newvmdisk.vmdk (onaWindowshost)or/path/to/disk/newvmdisk.vmdk(onaLinuxhost).Ifyoumappedanetworkshare onthehost,youcancreatethevirtualdiskonthatsharebyprovidingpathinformationwiththediskname. Use<drive|mountpoint>tospecifythedriveletterormountpointassociatedwithavirtualdiskthatwas mountedusingVMwareDiskMount.Youmustmountavirtualdisktoprepareitforshrinking. SeeTable 1,VMwareVirtualDiskManagerOptions,onpage 9foradescriptionofcommandlineoptions. SeeExamplesUsingVirtualDiskManageronpage 10forsamplecommandstoperformvarioustasks.
VMware, Inc.
-n <sourcedisk> <targetdisk>
-p
-r <sourcedisk> <targetdisk>
-q
VMware, Inc.
Thiscreatesa40GBSCSIvirtualdisknamedmydisk.vmdk.Typezeromeansthatthespaceiscontainedina singlevirtualdiskfile,andthatdiskspaceisgrowable,notpreallocated.
ThisconvertsthediskfromitsoriginalpreallocatedtypetoagrowablevirtualdiskconsistingofoneVMDK file.VirtualDiskManagerreclaimssomespaceinthevirtualdisk,sotheVMDKneedstobeonlyaboutaslarge asthedataitcontainedatconversiontime. To convert a local virtual disk to a remote ESX virtual disk Forthisconversion,specifytype4forVMFSvirtualdisk,withremotediskoptions:
vmware-vdiskmanager -r sourceDisk.vmdk -t 4 -h esx3.example.com -u admin -f password.txt "[storage1] <VMname>/targetDisk.vmdk"
10
VMware, Inc.
Torenamethevirtualdiskandlocateitinadifferentdirectory,type:
vmware-vdiskmanager -n mydisk.vmdk "..\<Another Path>\myNewDisk.vmdk"
OnLinuxhosts,type:
vmware-vdiskmanager -n mydisk.vmdk ../<anotherPath>/myNewDisk.vmdk
Tokeepthesamenamebutlocatethediskinadifferentdirectory,type:
vmware-vdiskmanager -n mydisk.vmdk "..\<Another Path>\mydisk.vmdk"
OnLinuxhosts,type:
vmware-vdiskmanager -n mydisk.vmdk ../<anotherPath>/
Addthevirtualdiskbacktoanyvirtualmachinesthatuseit. ChooseVM>Settings>Hardware,clickAdd,andfollowtheinstructionsinthewizard.
Defragmentconsolidatessparsedisk,movingdatatolowernumberedsectors.Thisisindependentofany defragmentationtoolsintheguestoperatingsystem,whichworkonvolumesstoredinsidetheVMDK. Defragmentingdoesnotreclaimunusedspaceonavirtualdisk;todothis,youmustshrinkthedisk. Youcannotdefragment: Preallocatedvirtualdisks(flattype2or3) Physicalharddrives Virtualdisksthatareassociatedwithsnapshots. Followthisorderofstepswhendefragmentingandshrinkingvirtualdisk: 1 Runadiskfragmentationtoolinsidethevirtualmachine.Forexample,withaWindows98guestoperating system,runtheWindows98defragmentationtool. VMwarerecommendsthatyoudefragmentaguestsvirtualdiskbeforetakingthefirstsnapshotofa guest,orafterdeletingsnapshots.Otherwiseyoulosetheabilitytodefragmenttheguestsvirtualdisk, becauseafterasnapshot,changesaremadetotheredolog,nottheoriginalvirtualdisk.Moreover, defragmentationcanheavilymodifythevirtualdiskimage,resultinginaverylargeredolog. 2 3 4 Powerdownthevirtualmachineandusevmware-vdiskmanager-dtodefragmentitsvirtualdisk.This isthesameasclickingHardDisk>Utilities>Defragmentintheuserinterface. Runadiskfragmentationtoolonthehostcomputer,ifneeded.ModernfilesystemssuchasNTFSand Linuxext2andespeciallyext3arerelativelyresistanttodefragmentation. ShrinkthevirtualdiskasdescribedinShrinkingaVirtualDiskonpage 12.
VMware, Inc.
11
OnLinuxhosts,type:
vmware-mount /path/to/vmware/guest/Windows98.vmdk /mnt/win98
UseVirtualDiskManagertopreparethevolumeforshrinking. OnWindowstypethiscommand,whereM:isthedriveletterwiththemountedvolume:
vmware-vdiskmanager -p M:
OnLinuxhosts,specifythemountpointinsteadofthedrive:
vmware-vdiskmanager -p /mnt/win98
Theprepareoperationzeroesoutunusedsectorssothatshrinkrecognizesthesesectorsasunusedspace. 3 UnmountthevolumeusingtheVMwareDiskMountutility:
vmware-mount /d M:
OnLinuxhosts,type:
vmware-mount -d /mnt/win98
4 5
Repeatthemounting,preparing,andunmountingstepsforeachvolumeofthevirtualdisk. NowuseVirtualDiskManagertoshrinkthevirtualdisk:
vmware-vdiskmanager -k Windows98.vmdk
12
VMware, Inc.