virtual disk manager
TRANSCRIPT
-
8/4/2019 Virtual Disk Manager
1/12
Virtual Disk Manager Users GuideVirtual Disk Development Kit
-
8/4/2019 Virtual Disk Manager
2/12
VMware, Inc.
3401 Hillview Ave.Palo Alto, CA 94304www.vmware.com
2 VMware, Inc.
Virtual Disk Manager Users Guide
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:
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 ofVMware, Inc. in the United States and/or other jurisdictions. All other marks and names mentioned herein may be trademarksof their respective companies.
Virtual Disk Manager Users Guide
Item: EN-000046-01
http://www.vmware.com/supportmailto:[email protected]://www.vmware.com/supporthttp://www.vmware.com/support/mailto:[email protected] -
8/4/2019 Virtual Disk Manager
3/12
VMware, Inc. 3
Contents
About
This
Book 5
UsingVMwareVirtualDiskManager 7AboutVirtualDiskManager 7
UsesofVirtualDiskManager 8
VMwareDiskMount 8
RunningVirtualDiskManager 8
ExamplesUsingVirtualDiskManager 10
CreatingaVirtualDisk 10
ConvertingaVirtualDisk 10
IncreasingtheSizeofanExistingVirtualDisk 10
RenamingorRelocatingaVirtualDisk 11
Defragmenting
a
Virtual
Disk 11ShrinkingaVirtualDisk 12
-
8/4/2019 Virtual Disk Manager
4/12
Virtual Disk Manager Users Guide
4 VMware, Inc.
-
8/4/2019 Virtual Disk Manager
5/12
VMware, Inc. 5
ThisVMwaremanual,theVirtualDiskManagerUsersGuide,providesanintroductiontousingthevmware-vdiskmanagercommandlineutility.
Revision History
Thisbookisrevisedwitheachreleaseoftheproductorwhennecessary.Arevisedversioncancontainminor
ormajorchanges.Table P1summarizesthesignificantchangesineachversionofthisguide.
Intended AudienceThisbookisintendedforanyonewhousesVMwareVirtualDiskManager.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:
About This Book
Table P-1. Revision History
Revision Date Description of Changes
20070420 FirstversionoftheVirtualDiskManagerUsersGuide.20070607 UpdatewithsupportforLinuxhostsandremotevirtualdisks.
20080128 Added-toption5forthecompressedstreamvirtualdisktype.
20080407 Added-Soptiontoswitchremotesystemfromtargettosource.
20080407 ReissuedwithVMwareWorkstation6.5andVMwareServer2.0.
http://www.vmware.com/support/pubs/sdk_pubs.htmlhttp://www.vmware.com/support/pubsmailto:[email protected]:[email protected]://www.vmware.com/support/pubshttp://www.vmware.com/support/pubs/sdk_pubs.html -
8/4/2019 Virtual Disk Manager
6/12
Virtual Disk Manager Users Guide
6 VMware, Inc.
Technical Support and Education Resources
Thefollowingsectionsdescribethetechnicalsupportandeducationalresourcesavailabletoyou.
Online Support
YoucansubmitquestionsorpostcommentstotheDeveloperCommunitySDKsandAPIsforum,whichis
monitoredbyVMwaretechnicalsupportandproductteams.Toaccesstheforum,goto:
http://communities.vmware.com/community/developer
Support Offerings
TofindouthowVMwaresupportofferingscanhelpmeetyourbusinessneeds,goto:
http://www.vmware.com/support/services
VMware Professional Services
VMwareEducationServicescoursesofferextensivehandsonlabs,casestudyexamples,andcoursematerials
designedtobeusedasonthejobreferencetools.Coursesareavailableonsite,intheclassroom,andlive
online.Foronsitepilotprograms andimplementationbestpractices,VMwareConsultingServicesprovides
offeringstohelpyouassess,plan,build,andmanageyourvirtualenvironment.Toaccessinformationabout
educationclasses,certificationprograms,andconsultingservices,goto:
http://www.vmware.com/services/
http://communities.vmware.com/community/developerhttp://www.vmware.com/support/serviceshttp://www.vmware.com/services/http://www.vmware.com/services/http://www.vmware.com/support/serviceshttp://communities.vmware.com/community/developer -
8/4/2019 Virtual Disk Manager
7/12
-
8/4/2019 Virtual Disk Manager
8/12
Virtual Disk Manager Users Guide
8 VMware, Inc.
Uses of Virtual Disk Manager
YoucanuseVirtualDiskManagerto:
Automatethemanagementofvirtualdiskswithscripts.
Createvirtualdisksthatarenotyetassociatedwithaparticularvirtualmachine.Thisisusefulformaking
templatestospeedcreationofvirtualmachine.
Convert
an
existing
local
virtual
disk
to
a
remote
ESX
virtual
disk. Createacompresseddiskoptimizedforstreaming.
Switchthevirtualdisktypefrompreallocatedtogrowable,orfromgrowabletopreallocated.Whenyou
changethedisktypetogrowable,youreclaimsomediskspace.Youcanshrinkthevirtualdisktoreclaim
evenmorediskspace.
Expandthesizeofavirtualdisksoitislargerthanthesizespecifiedwhenyoucreatedit.
Defragmentvirtualdisks.
Prepareandshrinkvirtualdiskswithoutpoweringonthevirtualmachine.
Renameandmovevirtualdisks.
YoucanuseVirtualDiskManagerwithvirtualdiskscreatedunderVMwareServer,VMwareWorkstation5
orhigher,VMwareFusion,VMwarePlayer,VMwareGSXServer,VMwareACE(unencrypteddisksonly),and
VMwareESX/ESXiserver(onlypreallocateddisksoftype4).
VMware Disk Mount
SomediskmanagementactivitiesrequireyoutomountaVMDKasavolumeorfilesystemavailabletothe
hostorguestoperatingsystem.SeetherelatedmanualVMwareDiskMountUsersGuideformoreinformation.Running Virtual Disk Manager
BackupyourvirtualdiskfilesbycopyingthemelsewherebeforemakingchangeswithVirtualDiskManager.
To run Virtual Disk Manager
1 Openacommandpromptorterminalonthehost.
PathisprobablysetcorrectlybytheVMwareinstallation,butyoumighthavetochangetothedirectory
whereyouinstalledVMwareVirtualDiskManager.
2 Typethevmware-vdiskmanagercommandtodisplayusageinformation.
Thecommandsyntaxisoneof:
vmware-vdiskmanager
vmware-vdiskmanager
Usetospecifythenameofavirtualdiskfile(VMDK)thatyouwanttocreate,manage,ormodify.
Thevirtualdiskfilemusthavea.vmdkextension.Youmayspecifyapathinfrontofthefilename.Forexample:
C:\DocumentsandSettings\\My Documents\MyVirtualMachines\VMname\newvmdisk.vmdk
(onaWindowshost)or/path/to/disk/newvmdisk.vmdk(onaLinuxhost).Ifyoumappedanetworkshare
onthehost,youcancreatethevirtualdiskonthatsharebyprovidingpathinformationwiththediskname.
Usetospecifythedriveletterormountpointassociatedwithavirtualdiskthatwas
mountedusingVMwareDiskMount.Youmustmountavirtualdisktoprepareitforshrinking.
SeeTable 1,VMwareVirtualDiskManagerOptions,onpage 9foradescriptionofcommandlineoptions.
SeeExamplesUsingVirtualDiskManageronpage 10forsamplecommandstoperformvarioustasks.
NOTE YoucannotuseVirtualDiskManagertocreateortoshrinkphysicalharddrives.
-
8/4/2019 Virtual Disk Manager
9/12
VMware, Inc. 9
Using VMware Virtual Disk Manager
Table 1. VMware Virtual Disk Manager Options
Option Parameters Description
-c Createsalocalvirtualdisk.The-a,-s,and-toptions,andavirtualdisknamespecifiedby,arerequiredwhencreatingavirtualdisk.
-d Defragmentsthevirtualdiskspecifiedby.Youcandefragmentonlygrowablevirtualdisks,notpreallocatedorremotevirtualdisks.
-k Shrinks
the
virtual
disk
specified
by
.
Before
you
can
shrink
a
virtual
disk,youmustprepareallitsvolumesforshrinkingusingthe-poption.Youcanshrinkonlygrowablevirtualdisks,notpreallocatedorremotevirtualdisks.
-n Renamesthevirtualdisknamedbytothevirtualdisknamedby.Byspecifyingdirectorypaths,youcanplacetherenamedvirtualdiskinadifferentdirectory,eitherwithitsoriginalnameorwithanewname.
-p Preparesthevirtualdiskmountedat(Windows)orat(Linux)forshrinking.Ifthevirtualdiskispartitionedintodifferentvolumesorfilesystems,youmustseparatelymountandprepareeachoneforshrinking.
-r Converts(clones)thevirtualdisknamedby,creatinganewvirtualdisknamedby.
Forlocalthe-toptionisrequiredtospecifytype.
ForremoteonanESXhost,usethe-h,-u,and-foptions.
Forthevirtualmachinetorecognizetheconvertedvirtualdisk,editthevirtualmachinesettingstoremovetheexistingvirtualdiskfromthevirtualmachine,thenaddtheconverteddisktothevirtualmachine.
-x [GB|MB|KB] Expands(grows)thevirtualdiskspecifiedbytothegivencapacity,whichyoucanspecifyingigabytes(GB),megabytes(MB),orkilobytes(KB).Thenewcapacitymustbegreaterthantheoriginalcapacity.Youcanexpandlocalvirtualdisksonly.Youcannotchangethesizeofaphysicalharddrive.
-q DisablesVirtualDiskManagerlogging.
Otherwise,messagesthatVirtualDiskManagergeneratesarerecordedinalogfilevdiskmanager.logstoredinatemporarydirectory.
-a [ide|buslogic|lsilogic] Specifiesthediskadaptertype.Thisoptionisrequiredwhenyoucreateavirtualdisk.Chooseoneofthefollowingadaptertypes:
ideanIDEadapter,forcompatibilitywitholdsoftware.
buslogicaBusLogicSCSIadapter,forhighperformance.
lsilogicLSILogicSCSIadapter,forhighperformanceonnewsystems.
-s [GB|MB|KB] Specifiesthesizeofthevirtualdisk.Thisoptionisrequiredwhenyoucreateavirtualdisk.Youcanspecifydisksizeingigabytes(GB),megabytes(MB),orkilobytes(KB).Sizemustbe1MB(2000sectors)orgreater.
Donotusethe-soptionwhenyouexpandavirtualdisk;specifydisksizeusingthe-xoptioninstead.
-t [0|1|2|3|4|5] Specifiesthevirtualdisktype.Thisoptionisrequiredwhenyoucreateorconvertavirtualdisk.Chooseoneofthefollowingtypes:
0createagrowablevirtualdiskcontainedinasinglefile(monolithicsparse).
1createagrowablevirtualdisksplitinto2GBfiles(splitsparse).
2createapreallocatedvirtualdiskcontainedinasinglefile(monolithicflat).
3createapreallocatedvirtualdisksplitinto2GBfiles(splitflat).
4createapreallocatedvirtualdiskcompatiblewithESXserver(VMFSflat).
5createacompresseddiskoptimizedforstreaming.
-h SpecifiesthehostnameorIPaddressofaremoteESXhost.
-u SpecifiestheusernameforconnectingtoaremoteESXhost.
-f SpecifiesthenameandlocationofaplaintextfilethatcontainsthepasswordforconnectingtoaremoteESXhost.
-P SpecifiesaTCPportnumberforcommunicatingwiththeremoteESXhost.Thisisoptionalanddefaultsto902.
-S Switchestomakethesourcevirtualdiskremote,insteadofthetargetdiskremote.
-
8/4/2019 Virtual Disk Manager
10/12
Virtual Disk Manager Users Guide
10 VMware, Inc.
Examples Using Virtual Disk Manager
ThefollowingexamplesillustratehowtouseVirtualDiskManager.
Creating a Virtual Disk
To create a new virtual disk
ChangedirectorytothelocationwhereyouwantthenewVMDKandtypethiscommand:
vmware-vdiskmanager -c -a lsilogic -s 40GB -t 0 mydisk.vmdk
Thiscreatesa40GBSCSIvirtualdisknamedmydisk.vmdk.Typezeromeansthatthespaceiscontainedina
singlevirtualdiskfile,andthatdiskspaceisgrowable,notpreallocated.
Converting a Virtual Disk
To convert a virtual disk from preallocated to growable
AssumingsourceDisk.vmdkexistsastype2or3,typethiscommandtoconvertit:
vmware-vdiskmanager -r sourceDisk.vmdk -t 0 targetDisk.vmdk
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] /targetDisk.vmdk"
ThisconvertsthelocalvirtualdisktoremotevirtualdisklocatedonthespecifiedESXhost.Afterconversion
iscompleteandyouhavetestedtheconvertedvirtualdisktomakesureitworksasexpected,youmaydelete
theoriginalvirtualdiskfile.Ifyoudeletetheoriginalfile,alsoremoveitfromanyvirtualmachinethatusesit.
Toremoveit,chooseVM>Settings>Hardware,selectthevirtualdisk,andclickRemove.FortheESXhosttorecognizetheconvertedvirtualdisk,youmustaddthedisktothevirtualmachine.Choose
Inventory>VirtualMachine>EditSettings,clickAdd,andfollowthewizardpromptstoaddtheconvertedvirtualdiskfile.
Increasing the Size of an Existing Virtual Disk
To expand (grow) a virtual disk
SpecifysizeandgivethefullpathtotheVMDK,orchangedirectorytoitslocation:
vmware-vdiskmanager -x 80GB mydisk.vmdk
Thisincreasesthemaximumcapacityofthevirtualdiskto80GB.Unlikedefragmentingandshrinking,you
mayincreasethesizeofpreallocatedvirtualdisks(flattype2or3).
VirtualDiskManagerexpandsthevirtualdiskbutdoesnotmodifyitscontents,sothepartitioninformation
remainsthesame.Manyoperatingsystemscannotalterpartitionsizeaftercreation,soyoumighthaveto
obtainthirdpartysoftware,suchasPartitionMagicorGNUParted,todothis.Suchsoftwareallowsyouto
alterdiskpartitionssoavirtualmachinecanaccesstheadditionaldiskspace.
Anothermethodofincreasingpartitionsize,easierinsomecases,wouldbetouseVMwareConverter.
NOTE Alwaysbackup(copy)yourvirtualdiskfilesbeforechangingsize,defragmenting,orrenamingthem.
CAUTION WhencloningtoaremoteESXhost,VirtualDiskManageroverwritesanypreexistingVMDKfile.Thiscouldresultinlossofdata.Whencloningtolocaldisk,thedestinationVMDKisnotoverwritten.
-
8/4/2019 Virtual Disk Manager
11/12
VMware, Inc. 11
Using VMware Virtual Disk Manager
Renaming or Relocating a Virtual Disk
To rename or relocate a virtual disk
1 Removethevirtualdiskfromanyvirtualmachinethatcontainsthedisk.
ChooseVM>Settings>Hardware,selectthevirtualdisk,andclickRemove.2 Typeoneofthefollowingcommands:
Torenamethevirtualdiskandkeepitinthesamelocation,type:
vmware-vdiskmanager -n mydisk.vmdk myNewDisk.vmdk
Torenamethevirtualdiskandlocateitinadifferentdirectory,type:
vmware-vdiskmanager -n mydisk.vmdk "..\\myNewDisk.vmdk"
OnLinuxhosts,type:
vmware-vdiskmanager -n mydisk.vmdk ..//myNewDisk.vmdk
Tokeepthesamenamebutlocatethediskinadifferentdirectory,type:
vmware-vdiskmanager -n mydisk.vmdk "..\\mydisk.vmdk"
OnLinuxhosts,type:
vmware-vdiskmanager -n mydisk.vmdk ..//
3 Addthevirtualdiskbacktoanyvirtualmachinesthatuseit.
ChooseVM>Settings>Hardware,clickAdd,andfollowtheinstructionsinthewizard.Defragmenting a Virtual Disk
To defragment a virtual disk
Todefragmentalocalvirtualdisk,typethiscommand.
vmware-vdiskmanager -d myDisk.vmdk
Defragment
consolidates
sparse
disk,
moving
data
to
lower
numbered
sectors.
This
is
independent
of
any
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 Powerdownthevirtualmachineandusevmware-vdiskmanager-dtodefragmentitsvirtualdisk.This
isthesameasclickingHardDisk>Utilities>Defragmentintheuserinterface.3 Runadiskfragmentationtoolonthehostcomputer,ifneeded.ModernfilesystemssuchasNTFSand
Linuxext2andespeciallyext3arerelativelyresistanttodefragmentation.
4 ShrinkthevirtualdiskasdescribedinShrinkingaVirtualDiskonpage 12.
-
8/4/2019 Virtual Disk Manager
12/12
Virtual Disk Manager Users Guide
12 VMware, Inc.
Shrinking a Virtual Disk
Ifyouhaveavirtualdiskthatgrowsasyouadddata,youcanshrinkthediskinordertoreclaimunusedspace.
Ifthereisemptyspaceinthevirtualdisk,shrinkingreducestheamountofspacethattheVMDKfileoccupies
onthehost.Shrinkingavirtualdiskdoesnotchangethemaximumcapacityofthevirtualdiskitself.
PoweroffthevirtualmachinebeforeusingVirtualDiskManagertoprepareandshrinkgrowablevirtualdisks.
Youcannotshrink:
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
2 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 Repeatthemounting,preparing,andunmountingstepsforeachvolumeofthevirtualdisk.
5 NowuseVirtualDiskManagertoshrinkthevirtualdisk:
vmware-vdiskmanager -k Windows98.vmdk