Professional Documents
Culture Documents
VirtualDiskManager PDF
VirtualDiskManager PDF
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.
3401 Hillview Ave.
Palo Alto, CA 94304
www.vmware.com
VMware, Inc.
Contents
AboutThisBook
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
Description of Changes
20070420
FirstversionoftheVirtualDiskManagerUsersGuide.
20070607
UpdatewithsupportforLinuxhostsandremotevirtualdisks.
20080128
Added-toption5forthecompressedstreamvirtualdisktype.
20080407
Added-Soptiontoswitchremotesystemfromtargettosource.
20080407
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.
VMwareVirtualDiskManager(vmware-vdiskmanager)isautilitythatallowsyoutocreate,manage,and
modifyvirtualdiskfilesfromwithinscriptsoratthecommandline.ItrunsonWindowsandLinuxsystems,
andhasthesamecommandlineoptionsonboth.
Thischaptercontainsthefollowingsections:
AboutVirtualDiskManageronpage 7
RunningVirtualDiskManageronpage 8
ExamplesUsingVirtualDiskManageronpage 10
PreallocatedorgrowableAllspaceforthevirtualdiskisallocatedinadvance(flat),orallocatedspace
beginssmallbutgrowsasneededforthevirtualdisk(sparse).
SingleormultiplefilesVirtualdiskisstoredinonebigfile(monolithic),orstoredasaseriesofsmaller
virtualdiskfiles(split).
WithVirtualDiskManageryoucanchangewhetherthevirtualdisktypeisflatorsparse,monolithicorsplit.
Youcanchangepreallocateddiskintogrowablediskasneeded,andchangewhetherthevirtualdiskisstored
inasinglefileorsplitintomultiple2GBfiles.
Forexample,youmightallocateallthediskspaceforavirtualdisk,butlateryoumightneedtoreclaimhard
diskspaceonthehost.Youcanconvertthepreallocatedvirtualdiskintoagrowabledisk,andremovethe
originalvirtualdiskfile.Thenewgrowablevirtualdiskislargeenoughtocontainallthedataintheoriginal
virtualdisk,andmoreoverisabletogrowwhenyouadddatatoit.
Asanotherexample,youcouldmoveavirtualmachinefromanoldVMwareserverthatcouldnothandlefiles
largerthan2GB,convertingthesplitvirtualdiskintoasinglegrowablefile.
Asathirdexample,youcanconverthosteddisktomanageddiskinaVMFSfilesystemonanESXhost.
NOTEVirtualdiskmustbeoffline,withthevirtualmachinepoweredoff,formostoperations.
VMware, Inc.
Automatethemanagementofvirtualdiskswithscripts.
Createvirtualdisksthatarenotyetassociatedwithaparticularvirtualmachine.Thisisusefulformaking
templatestospeedcreationofvirtualmachine.
ConvertanexistinglocalvirtualdisktoaremoteESXvirtualdisk.
Createacompresseddiskoptimizedforstreaming.
Switchthevirtualdisktypefrompreallocatedtogrowable,orfromgrowabletopreallocated.Whenyou
changethedisktypetogrowable,youreclaimsomediskspace.Youcanshrinkthevirtualdisktoreclaim
evenmorediskspace.
Expandthesizeofavirtualdisksoitislargerthanthesizespecifiedwhenyoucreatedit.
Defragmentvirtualdisks.
Prepareandshrinkvirtualdiskswithoutpoweringonthevirtualmachine.
Renameandmovevirtualdisks.
NOTEYoucannotuseVirtualDiskManagertocreateortoshrinkphysicalharddrives.
YoucanuseVirtualDiskManagerwithvirtualdiskscreatedunderVMwareServer,VMwareWorkstation5
orhigher,VMwareFusion,VMwarePlayer,VMwareGSXServer,VMwareACE(unencrypteddisksonly),and
VMwareESX/ESXiserver(onlypreallocateddisksoftype4).
Openacommandpromptorterminalonthehost.
PathisprobablysetcorrectlybytheVMwareinstallation,butyoumighthavetochangetothedirectory
whereyouinstalledVMwareVirtualDiskManager.
Typethevmware-vdiskmanagercommandtodisplayusageinformation.
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.
Description
-c
Createsalocalvirtualdisk.The-a,-s,and-toptions,andavirtualdiskname
specifiedby<diskname>,arerequiredwhencreatingavirtualdisk.
-d
Defragmentsthevirtualdiskspecifiedby<diskname>.Youcandefragmentonly
growablevirtualdisks,notpreallocatedorremotevirtualdisks.
-k
Shrinksthevirtualdiskspecifiedby<diskname>.Beforeyoucanshrinkavirtual
disk,youmustprepareallitsvolumesforshrinkingusingthe-poption.Youcan
shrinkonlygrowablevirtualdisks,notpreallocatedorremotevirtualdisks.
-n <sourcedisk> <targetdisk>
Renamesthevirtualdisknamedby<sourcedisk>tothevirtualdisknamedby
<targetdisk>.Byspecifyingdirectorypaths,youcanplacetherenamedvirtual
diskinadifferentdirectory,eitherwithitsoriginalnameorwithanewname.
-p
Preparesthevirtualdiskmountedat<drive>(Windows)orat<mountpoint>
(Linux)forshrinking.Ifthevirtualdiskispartitionedintodifferentvolumesorfile
systems,youmustseparatelymountandprepareeachoneforshrinking.
-r <sourcedisk> <targetdisk>
Converts(clones)thevirtualdisknamedby<sourcedisk>,creatinganewvirtual
disknamedby<targetdisk>.
Forlocal<targetdisk>the-toptionisrequiredtospecifytype.
Forremote<targetdisk>onanESXhost,usethe-h,-u,and-foptions.
Forthevirtualmachinetorecognizetheconvertedvirtualdisk,editthevirtual
machinesettingstoremovetheexistingvirtualdiskfromthevirtualmachine,then
addtheconverteddisktothevirtualmachine.
-x <n>[GB|MB|KB]
-q
Expands(grows)thevirtualdiskspecifiedby<diskname>tothegivencapacity
<n>,whichyoucanspecifyingigabytes(GB),megabytes(MB),orkilobytes(KB).
Thenewcapacitymustbegreaterthantheoriginalcapacity.Youcanexpandlocal
virtualdisksonly.Youcannotchangethesizeofaphysicalharddrive.
DisablesVirtualDiskManagerlogging.
Otherwise,messagesthatVirtualDiskManagergeneratesarerecordedinalogfile
vdiskmanager.logstoredinatemporarydirectory.
-a [ide|buslogic|lsilogic]
-s <n>[GB|MB|KB]
Specifiesthediskadaptertype.Thisoptionisrequiredwhenyoucreateavirtual
disk.Chooseoneofthefollowingadaptertypes:
ideanIDEadapter,forcompatibilitywitholdsoftware.
buslogicaBusLogicSCSIadapter,forhighperformance.
lsilogicLSILogicSCSIadapter,forhighperformanceonnewsystems.
Specifiesthesizeofthevirtualdisk.Thisoptionisrequiredwhenyoucreatea
virtualdisk.Youcanspecifydisksize<n>ingigabytes(GB),megabytes(MB),or
kilobytes(KB).Sizemustbe1MB(2000sectors)orgreater.
Donotusethe-soptionwhenyouexpandavirtualdisk;specifydisksizeusing
the-xoptioninstead.
-t [0|1|2|3|4|5]
Specifiesthevirtualdisktype.Thisoptionisrequiredwhenyoucreateorconvert
avirtualdisk.Chooseoneofthefollowingtypes:
0createagrowablevirtualdiskcontainedinasinglefile(monolithicsparse).
1createagrowablevirtualdisksplitinto2GBfiles(splitsparse).
2createapreallocatedvirtualdiskcontainedinasinglefile(monolithicflat).
3createapreallocatedvirtualdisksplitinto2GBfiles(splitflat).
4createapreallocatedvirtualdiskcompatiblewithESXserver(VMFSflat).
5createacompresseddiskoptimizedforstreaming.
-h <hostname>
SpecifiesthehostnameorIPaddressofaremoteESXhost.
-u <username>
SpecifiestheusernameforconnectingtoaremoteESXhost.
-f <passwordfile>
Specifiesthenameandlocationofaplaintextfilethatcontainsthepasswordfor
connectingtoaremoteESXhost.
-P <portNumber>
SpecifiesaTCPportnumberforcommunicatingwiththeremoteESXhost.Thisis
optionalanddefaultsto902.
-S
Switchestomakethesourcevirtualdiskremote,insteadofthetargetdiskremote.
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"
ThisconvertsthelocalvirtualdisktoremotevirtualdisklocatedonthespecifiedESXhost.Afterconversion
iscompleteandyouhavetestedtheconvertedvirtualdisktomakesureitworksasexpected,youmaydelete
theoriginalvirtualdiskfile.Ifyoudeletetheoriginalfile,alsoremoveitfromanyvirtualmachinethatusesit.
Toremoveit,chooseVM>Settings>Hardware,selectthevirtualdisk,andclickRemove.
FortheESXhosttorecognizetheconvertedvirtualdisk,youmustaddthedisktothevirtualmachine.Choose
Inventory>VirtualMachine>EditSettings,clickAdd,andfollowthewizardpromptstoaddtheconverted
virtualdiskfile.
CAUTIONWhencloningtoaremoteESXhost,VirtualDiskManageroverwritesanypreexistingVMDKfile.
Thiscouldresultinlossofdata.Whencloningtolocaldisk,thedestinationVMDKisnotoverwritten.
Thisincreasesthemaximumcapacityofthevirtualdiskto80GB.Unlikedefragmentingandshrinking,you
mayincreasethesizeofpreallocatedvirtualdisks(flattype2or3).
VirtualDiskManagerexpandsthevirtualdiskbutdoesnotmodifyitscontents,sothepartitioninformation
remainsthesame.Manyoperatingsystemscannotalterpartitionsizeaftercreation,soyoumighthaveto
obtainthirdpartysoftware,suchasPartitionMagicorGNUParted,todothis.Suchsoftwareallowsyouto
alterdiskpartitionssoavirtualmachinecanaccesstheadditionaldiskspace.
Anothermethodofincreasingpartitionsize,easierinsomecases,wouldbetouseVMwareConverter.
10
VMware, Inc.
Removethevirtualdiskfromanyvirtualmachinethatcontainsthedisk.
ChooseVM>Settings>Hardware,selectthevirtualdisk,andclickRemove.
Typeoneofthefollowingcommands:
Torenamethevirtualdiskandkeepitinthesamelocation,type:
vmware-vdiskmanager -n mydisk.vmdk myNewDisk.vmdk
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.
Powerdownthevirtualmachineandusevmware-vdiskmanager-dtodefragmentitsvirtualdisk.This
isthesameasclickingHardDisk>Utilities>Defragmentintheuserinterface.
Runadiskfragmentationtoolonthehostcomputer,ifneeded.ModernfilesystemssuchasNTFSand
Linuxext2andespeciallyext3arerelativelyresistanttodefragmentation.
ShrinkthevirtualdiskasdescribedinShrinkingaVirtualDiskonpage 12.
VMware, Inc.
11
Preallocatedvirtualdisks(flattype2or3)
Physicalharddrives
Virtualdisksthatareassociatedwithsnapshots.
Toprepareandshrinkthevirtualdiskinitscurrentstate,firstusethesnapshotmanagertodeleteexisting
snapshots.Todiscardchangesmadesinceyoutookasnapshot,reverttothesnapshot.
To shrink a virtual disk
1
UsetheVMwareDiskMountutilitytomountavolumeofthevirtualdisk.TheVMwareDiskMount
utilityandtheVMwareDiskMountUsersManualareavailableontheVMwareWebsite.
Changedirectorytothelocationofthevirtualmachine,forexampleWindows98,andrunvmware-mount:
cd C:\Documents and Settings\user\My Documents\My Virtual Machines\Windows98
vmware-mount M: Windows98.vmdk
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
Repeatthemounting,preparing,andunmountingstepsforeachvolumeofthevirtualdisk.
NowuseVirtualDiskManagertoshrinkthevirtualdisk:
vmware-vdiskmanager -k Windows98.vmdk
12
VMware, Inc.