Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use the virtual disk tool vmkfstools

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces how to use the virtual disk tool vmkfstools, which is very detailed and has a certain reference value. Friends who are interested must finish reading it!

Type of virtual disk

Thick setting delay zeroing / / default option

Allocate the required space for the virtual disk during creation. No data retained on the physical device will be erased when created, but it will be set to zero later on the first write from the virtual machine as needed.

two。 Thick setting zero

Create a thick disk that supports the clustering feature. Allocate the required space for the virtual disk at creation time. During creation, the retained data on the physical device is set to zero. It may take longer to create than other types of disks.

3. Streamlined provision

The data storage space initially required to use the disk. If the thin disk needs more space later, it can grow to the maximum capacity allocated to it.

2. Vmkfstools operation example

Please shut down the virtual machine before operation, open the ssh service in the security configuration file in the ESXI configuration, and log in to ESXI and enter your user name and password.

1 Virtual disk type conversion, thick to thin

Vmkfstools command format

# vmkfstools-iMurd {thin | thick}

Parameter explanation:

-I parameter: original vmdk disk name

-d {thin | thick}: format of the destination disk. Thin or thick; is the name of the target vmdk disk to be generated.

1.1 enter the datastore directory where the virtual machine is located, and each directory is a virtual machine

# cd / vmfs/volumes/datastore1

/ vmfs/volumes/4f3cedd3-1b48e924-3d7d-0022195a4404 # ls

Cobbler-5.85 converter-two-57.72 datanode2-57.78

1.2 the converted virtual machine is converter-two-57.72. Enter the virtual machine directory.

/ vmfs/volumes/4f3cedd3-1b48e924-3d7d-0022195a4404 # cd converter-two-57.72/

/ vmfs/volumes/4f3cedd3-1b48e924-3d7d-0022195a4404/converter-two-57.72 # du-sh *

20.0G converter-two-flat.vmdk 64.0k converter-two.nvram

64.0k converter-two.vmdk 0 converter-two.vmsd

64.0k converter-two.vmx 64.0k converter-two.vmxf

File, there are two kinds of vmdk, one is "virtual machine name .vmdk", vmdk file is very small, storing some configuration information of virtual disk (such as virtual disk data files, etc.); the other is "virtual machine name-flat.vmdk", the actual data are stored in flat.vmdk files, conversion requires the use of vmdk files instead of flat.vmdk files.

1.4 start the conversion process

A: use vmkfstools to clone a thick-mode vmdk file into a compact vmdk disk file, and two new vmdk and flat.vmdk files will be generated after conversion

/ vmfs/..../converter-two-57.72 # vmkfstools-I converter-two.vmdk-d thin converter-two_new.vmdk

/ vmfs/..../converter-two-57.72 # du-sh *

20.0G converter-two-flat.vmdk

64.0k converter-two.vmdk

64.0k converter-two.vmx

64.0k converter-two.vmxf

7.9G converter-two_new-flat.vmdk

64.0k converter-two_new.vmdk

B: back up the original thick mode disk files vmdk and flat.vmdk files

/ vmfs/..../converter-two-57.72 # mv converter-two.vmdk converter-two_old.vmdk

/ vmfs/..../converter-two-57.72 # mv converter-two-flat.vmdk converter-two-flat_old.vmdk

C: rename the newly generated vmdk and flat.vmdk disk files to the original disk name, respectively

/ vmfs/..../converter-two-57.72 # mv converter-two_new.vmdk converter-two.vmdk

/ vmfs/..../converter-two-57.72 # mv converter-two_new-flat.vmdk converter-two-flat.vmdk

D: edit the vmdk file and make sure that # Extent description "converter-two-flat.vmdk" is the original disk name

/ vmfs/..../converter-two-57.72 # cat converter-two.vmdk

# Disk DescriptorFile

Version=1

Encoding= "UTF-8"

CID=9cad19cd

ParentCID=ffffffff

IsNativeSnapshot= "no"

CreateType= "vmfs"

# Extent description

RW 41932416 VMFS "converter-two_new-flat.vmdk"

# The Disk Data Base

# DDB

Ddb.deletable = "true"

Ddb.toolsVersion = "0"

Ddb.geometry.biosHeads = "255"

Ddb.geometry.biosSectors = "63"

Ddb.geometry.biosCylinders = "2610"

Ddb.virtualHWVersion = "7"

Ddb.longContentID = "364b422b2ceb3f6f0a4e88d09cad19cd"

Ddb.uuid = "60 00 C2 94 89 93 59 2c-d9 22 d3 e4 e6 b3 a4 22"

Ddb.geometry.cylinders = "2610"

Ddb.geometry.heads = "255"

Ddb.geometry.sectors = "63"

Ddb.thinProvisioned = "1"

Ddb.adapterType = "lsilogic"

E: start the virtual machine to check whether it is working properly, and compare the size of the thin setting and the thick setting.

/ converter-two-57.72 # du-sh * 500.0M converter-two-326dc793.vswp

7.9G converter-two-flat.vmdk

20.0G converter-two-flat_old.vmdk

64.0k converter-two.nvram

64.0k converter-two.vmdk

1.5 other ways

Switch from thin setting to thick setting zero:

Vmkfstools-inflatedisk / vmfs/volumes/DatastoreName/VMName/VMName.vmdk

Thick setting delay zero conversion to thick setting zero:

Vmkfstools-eagerzero / vmfs/volumes/DatastoreName/VMName/VMName.vmdk

2 change the size of the virtual disk (vmdk)

It is important to note that if this virtual machine already has snapshots, delete all snapshots first and do the following, otherwise the VMDK will make an error and the internal data will be lost.

2.1 vmkfstools command format

Vmkfstools-X [new size] [destination vmdk file]

2.2 current virtual disk size of virtual machine

[root@bz-cl2 ~] # fdisk-l / dev/sda

Disk / dev/sda: 21.4 GB, 21469396992 bytes

255 heads, 63 sectors/track, 2610 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

2.3 shut down the virtual machine and log in to ESXI to resize the virtual disk

/ converter-two-57.72 # vmkfstools-X 40g converter-two.vmdk

2.4 turn on the virtual machine and verify the virtual disk size

[root@bz-cl2 ~] # fdisk-l / dev/sda

Disk / dev/sda: 42.9 GB, 42949672960 bytes

255 heads, 63 sectors/track, 5221 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Three vmkfstools command parameters

/ bin # vmkfstools

Vmkfstools-C-createfs vmfs3

-b-- blocksize # [mMkK]

-S-- setfsname fsName

-Z-- spanfs span-partition

-G-- growfs grown-partition

Add to the question:

Simplified configuration of 1TB space for the virtual machine VM1, after a long run, now in the VM1 windows system to see the data is only about 200GB, but the vmdk file already has 1TB. In my opinion, the reason for this is that streamlining allocation only increases but not shrinks.

Resolve:

It is not possible to reclaim inflated Thin Provision VMDK space through Storage vMotion between storage on the same file system and disk chunks of the same size. Because of the mechanism of the NTFS file system, the written file will not set the disk block to zero even if the file is deleted, and the next time the data is written will only give priority to the block marked zero to write. At present, a relatively simple and convenient method is to download a SDelete.exe program on VM, and then run it with cmd with the parameter-z, which marks the blocks that have been written into data as zero and is used for virtual machines, but this parameter is not valid on physical machines. Format such as: sdelete.exe-z CVR, the running process is slow, wait patiently, during which you will see that your disk will be full in the operating system, and then return to the normal capacity when the operation is completed.

After the command is run, use SSH to connect to the ESXi host to enter the .vmdk directory that needs to be reclaimed space, run the vmkfstools tool with a parameter of-K (because the ESXi host is the underlying OS of Linux, so pay attention to case), such as vmkfstools-K VirtualMachine.vmdk, and so on after the run is completed, you can successfully recover the inflated Thin Provision space.

This method is limited to Windows systems, Linux and other non-NTFS file systems. I haven't found a way to recycle it yet.

Attach a test chart (the space occupied by my vCenter Server.vmdk before recycling is 96.0GB):

The above is all the contents of the article "how to use the Virtual disk tool vmkfstools". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report