Renaming a virtual machine disk (VMDK) via the vSphere Management Assistant (vMA) or vSphere CLI (vC

http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=1002491


Details

This articles provides steps for renaming an ESX/ESXi virtual disk using the vSphere Command Line Interface (vCLI) or the console interface on an ESX/ESXi host.

Note: The vCLI is available pre-installed within the vSphere Management Assistant. For more information, see the vSphere Management Assistant Documentation. and vSphere Command-Line Interface Documentation.

For more information on renaming a virtual machine and its files, see Renaming a virtual machine and its files (1029513).

Solution

A virtual disk above consists of two files:

  • Virtual disk descriptor. In the following example: examplevm.vmdk
  • Virtual disk extent. In the following example: examplevm-flat.vmdk

A virtual machine's files can be listed and manipulated using the vSphere Command-Line Interface or the console interface on an ESX/ESXi host. For example, the descriptor and extent files can be seen using the vCLI vifs command:

vifs --server 10.21.49.14 -D '[Storage1 (3)] examplevm]'Enter username: rootEnter password:Content Listing---------------examplevm-flat.vmdkexamplevm.nvramexamplevm.vmdkexamplevm.vmsdexamplevm.vmxexamplevm.vmxfvmware.log

Prerequisites

Prior to renaming a virtual disk, meet the prerequisites:

Note: Always ensure you have a backup of all virtual machines. For additional information, see Backing up ESX Server virtual machines (1355).

Renaming using the virtual disk using the vSphere Command-Line Interface

For documentation on using the vCLI or vMA, refer to the vSphere Command-Line Interface or vSphere Management Assistant documentation.

To rename the disk and its files using the vmkfstools command in the vMA or vCLI:

  1. Verify the virtual machine referring to the virtual machine disk is powered off and does not have outstanding snapshots.

  2. Remove the virtual disk from the virtual machine's configuration:

    1. Locate the virtual machine in the inventory using the vSphere Client.
    2. Right-click the virtual machine select Edit Settings.
    3. Select the virtual disk in question and take note of virtual device node (eg, SCSI 0:1) and the name of the datastore and directory in the Disk File field at the top-right.
    4. Click the Remove button to disconnect the virtual disk from the virtual machine.

  3. Open a console session to the location the vCLI is installed. If using the vCLI from within the VMware Management Appliance, log in to the vMA.

  4. Obtain a listing of the files within a directory using the vCLI command:

    vifs --server <vCenter IP/Hostname> -D '[Datastore Name] Directory Name'

  5. Rename a virtual disk using a command similar to:

    vmkfstools --server <vCenter IP/Hostname> -E '[Datastore Name] Directory Name/examplevm.vmdk' '[Datastore Name] Directory Name/examplevm-renamed.vmdk'

    Note: Specify the descriptor file; the associated extent file is renamed in the process.

  6. Validate the files were renamed by listing the files within the directory using a command similar to:

    vifs --server <vCenter IP/Hostname> -D '[Datastore Name] Directory Name'

  7. Re-add the virtual machine disk to the virtual machine's configuration.

    1. Using the vSphere Client, select the virtual machine and click Edit Settings.
    2. Click the Add... button above the virtual hardware list.
    3. Select Hard Disk and Use an existing virtual disk.
    4. Select the datastore and disk that was renamed.
    5. Confirm that the same SCSI controller type and Device Node noted in step 2c.
    6. Click the OK button to complete the configuration change.

Renaming using the virtual disk using the ESX/ESXi host console interface

To rename the disk and its files using the vmkfstools command in ESX/ESXi host's console interface:

  1. Verify the virtual machine referring to the virtual machine disk is powered off and does not have outstanding snapshots.

  2. Remove the virtual disk from the virtual machine's configuration:

    1. Locate the virtual machine in the inventory using the vSphere Client.
    2. Right-click the virtual machine select Edit Settings.
    3. Select the virtual disk in question and take note of virtual device node (eg, SCSI 0:1) and the name of the datastore and directory in the Disk File field at the top-right.
    4. Click the Remove button to disconnect the virtual disk from the virtual machine.

  3. Open a console to the ESX or ESXi host. For more information, see Unable to connect to an ESX host using Secure Shell (SSH) (1003807) or Using Tech Support Mode in ESXi 4.1 (1017910).

  4. Navigate to the virtual machine's directory using a command similar to:

    cd "/vmfs/volumes/Datastore Name/Directory Name/"

  5. Obtain a listing of the files within a directory using the command:

    ls -l

    For example:

    total 320
    -rw------- 1 root root        8684 Aug 30 10:53 examplevm.nvram
    -rw------- 1 root root 21474836480 Aug 30 10:26 examplevm-flat.vmdk
    -rw------- 1 root root         482 Aug 30 11:26 examplevm.vmdk
    -rw------- 1 root root           0 Aug 30 10:33 examplevm.vmsd
    -rwxr-xr-x 1 root root        2724 Aug 30 12:20 examplevm.vmx
    -rw------- 1 root root         264 Aug 30 12:20 examplevm.vmxf
    -rw-r--r-- 1 root root       39168 Aug 30 10:53 vmware.log


  6. Rename a virtual disk using a command similar to:

    vmkfstools -E OldName.vmdk NewName.vmdk

    For example:

    vmkfstools -E examplevm.vmdk examplevm-renamed.vmdk

    Note: Specify the descriptor file; the associated extent file is renamed in the process.

  7. Validate the files were renamed by listing the files within the directory using the command:

    ls -l

    For example:

    total 320
    -rw------- 1 root root        8684 Aug 30 10:53 examplevm.nvram
    -rw------- 1 root root 21474836480 Aug 30 10:26 examplevm-renamed-flat.vmdk
    -rw------- 1 root root         482 Aug 30 11:26 examplevm-renamed.vmdk
    -rw------- 1 root root           0 Aug 30 10:33 examplevm.vmsd
    -rwxr-xr-x 1 root root        2724 Aug 30 12:20 examplevm.vmx
    -rw------- 1 root root         264 Aug 30 12:20 examplevm.vmxf
    -rw-r--r-- 1 root root       39168 Aug 30 10:53 vmware.log


  8. Re-add the virtual machine disk to the virtual machine's configuration.

    1. Using the vSphere Client, select the virtual machine and click Edit Settings.
    2. Click the Add... button above the virtual hardware list.
    3. Select Hard Disk and Use an existing virtual disk.
    4. Select the datastore and disk that was renamed.
    5. Confirm that the same SCSI controller type and Device Node noted in step 2c.
    6. Click the OK button to complete the configuration change.
Keywords
cannot-rename-vm-files rename-vm-files virtual-disk virtual-disks
Update History
08/30/2010 - Updated all content with vMA/CLI methods.01/24/2011 - Changed title to reflect that these commands are for renaming a vmdk via the vSphere Management Assistant (vMA) or vSphere CLI (vCLI)
Request a Product Feature
To request a new product feature or to provide feedback on a VMware product, please visit the Request a Product Feature page.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值