Vmkfstools: Difference between revisions

From VI-Toolkit
Jump to navigation Jump to search
mNo edit summary
mNo edit summary
Line 1: Line 1:
Command for directly working with the virtual disk at host level.
Command for directly working with the (virtual) disk at host level.


With this command you can destroy whole virtual machines if you do not take the right precautions (hint: BACKUPS) and are not familiar with the command.
With this command you can destroy whole virtual machines if you do not take the right precautions (hint: BACKUPS) and are not familiar with the command.
Line 9: Line 9:
Whereby target can be either a physical disk, a virtual disk or a device.
Whereby target can be either a physical disk, a virtual disk or a device.


The command is mostly known for using it to manipulate virtual disks.
The command is mostly known for using it to manipulate virtual disks.
Beware that if you are working with a virtual disk that in most cases the virtual machine itself should be shut down.


=== Options ===
=== Options ===
Line 69: Line 70:
Export a VM disk in 2GB chunks, note that since ESXi 5.x the 2GB sparse driver is disabled.
Export a VM disk in 2GB chunks, note that since ESXi 5.x the 2GB sparse driver is disabled.
  vmkfstools -i /vmfs/volumes/storagename/YourVM/YourVM.vmdk -d 2gbsparse /vmfs/volumes/storage2/YourVM/YourVM.vmdk
  vmkfstools -i /vmfs/volumes/storagename/YourVM/YourVM.vmdk -d 2gbsparse /vmfs/volumes/storage2/YourVM/YourVM.vmdk


  -x, --fix -[check|repair]
  -x, --fix -[check|repair]
Line 91: Line 90:


Example:
Example:
  vmkfstools -D /vmfs/volumes/esx4-1-local-storage-1/
  # vmkfstools -D /vmfs/volumes/esx4-1-local-storage-1/
   
   
  Lock [type 10c00001 offset 4292608 v 33, hb offset 3440640
  Lock [type 10c00001 offset 4292608 v 33, hb offset 3440640
Line 100: Line 99:
activehosts can be used by specifying "--activehosts" and specifying a VMFS volume
activehosts can be used by specifying "--activehosts" and specifying a VMFS volume


  vmkfstools --activehosts /vmfs/volumes/esx4-1-local-storage-1/
Example:
  # vmkfstools --activehosts /vmfs/volumes/esx4-1-local-storage-1/
  Found 1 actively heartbeating hosts on volume '/vmfs/volumes/esx4-1-local-storage-1/'
  Found 1 actively heartbeating hosts on volume '/vmfs/volumes/esx4-1-local-storage-1/'
  (1): MAC address 00:50:56:92:3f:86
  (1): MAC address 00:50:56:92:3f:86
Reclaim disk space by returning unused blocks of data in the virtual disk to the host OS. This will only work if your virtual disk is of type thin.
Example:
# vmkfstools --punchzero myvm.vmdk
vmfsDisk: 1, rdmDisk: 0, blockSize: 1048576
Hole Punching: 3% done.





Revision as of 16:58, 23 August 2014

Command for directly working with the (virtual) disk at host level.

With this command you can destroy whole virtual machines if you do not take the right precautions (hint: BACKUPS) and are not familiar with the command.


Usage

vmkfstools [options] target

Whereby target can be either a physical disk, a virtual disk or a device.

The command is mostly known for using it to manipulate virtual disks. Beware that if you are working with a virtual disk that in most cases the virtual machine itself should be shut down.

Options

from the help page of the command.

OPTIONS FOR FILE SYSTEMS

vmkfstools -C --createfs [vmfs3|vmfs5]
              -b --blocksize #[mMkK]
              -S --setfsname fsName
          -Z --spanfs span-partition
          -G --growfs grown-partition
  deviceName
          -P --queryfs -h --humanreadable
          -T --upgradevmfs
  vmfsPath

OPTIONS FOR VIRTUAL DISKS

vmkfstools -c --createvirtualdisk #[gGmMkK]
              -d --diskformat [zeroedthick|
                               thin|
                               eagerzeroedthick]
              -a --adaptertype [buslogic|lsilogic|ide|
                                lsisas|pvscsi]
          -w --writezeros
          -j --inflatedisk
          -k --eagerzero
          -K --punchzero
          -U --deletevirtualdisk
          -E --renamevirtualdisk srcDisk
          -i --clonevirtualdisk srcDisk
              -d --diskformat [zeroedthick|
                               thin|
                               eagerzeroedthick|
                               rdm:<device>|rdmp:<device>|
                               2gbsparse]
          -X --extendvirtualdisk #[gGmMkK]
              [-d --diskformat eagerzeroedthick]
          -M --migratevirtualdisk
          -r --createrdm /vmfs/devices/disks/...
          -q --queryrdm
          -z --createrdmpassthru /vmfs/devices/disks/...
          -v --verbose #
          -g --geometry
          -x --fix [check|repair]
          -e --chainConsistent
  vmfsPath

OPTIONS FOR DEVICES

          -L --lock [reserve|release|lunreset|targetreset|busreset|readkeys|rea                              dresv] /vmfs/devices/disks/...
          -B --breaklock /vmfs/devices/disks/...

vmkfstools -H --help


Examples

Export a VM disk in 2GB chunks, note that since ESXi 5.x the 2GB sparse driver is disabled.

vmkfstools -i /vmfs/volumes/storagename/YourVM/YourVM.vmdk -d 2gbsparse /vmfs/volumes/storage2/YourVM/YourVM.vmdk
-x, --fix -[check|repair]

This option will check and/or repair the virtual disk in case of an unclean shutdown.

Example:

vmkfstools --fix check /vmfs/volumes/esx4-1-local-storage-1/dummy/dummy.vmdk
Disk is error free
-J, --miscop [setuuid | getuuid]

'setuuid´ option creates a unique identifier (UUID) for the virtual disk and stores the UUID in the descriptor file of the

virtual disk. If the descriptor file already contains a UUID, it will be overwritten with a new one. 

Please make sure that the virtual disk does not have a UUID before using this option.

´getuuid´ option displays the UUID of the virtual disk.


dumpfs can be used by specifying either "-D | --dumpfs" and specifying a VMFS volume, file or folder.

Example:

# vmkfstools -D /vmfs/volumes/esx4-1-local-storage-1/

Lock [type 10c00001 offset 4292608 v 33, hb offset 3440640
gen 11, mode 0, owner 00000000-00000000-0000-000000000000 mtime 2509]
Addr <4, 0, 0>, gen 1, links 4, type dir, flags 0, uid 0, gid 0, mode 1755
len 1260, nb 1 tbz 0, cow 0, zla 1, bs 1048576

activehosts can be used by specifying "--activehosts" and specifying a VMFS volume

Example:

# vmkfstools --activehosts /vmfs/volumes/esx4-1-local-storage-1/
Found 1 actively heartbeating hosts on volume '/vmfs/volumes/esx4-1-local-storage-1/'
(1): MAC address 00:50:56:92:3f:86

Reclaim disk space by returning unused blocks of data in the virtual disk to the host OS. This will only work if your virtual disk is of type thin.

Example:

# vmkfstools --punchzero myvm.vmdk
vmfsDisk: 1, rdmDisk: 0, blockSize: 1048576 
Hole Punching: 3% done.


Links

Some useful vmkfstools ‘hidden’ options

William also has a list here