VMware Cloud Community
hharold
Enthusiast
Enthusiast

Rename VMDK through PowerCLI

All,

after searching through some old discussions and articles on the web, it seems not an easy task.

But I want to have a go at it anyhow.

My case:

I have a powered off VM (actually multiple)

I want to rename the attached harddisk, from let's say VIRTUAL.vmdk to VIRTUAL_1.vmdk

I'm fine with detaching, renaming, re-attaching, but have no clue how.

Can anyone help me out with an example script, or point me in the correct direction?

Thanks and kind regards,

Harold

0 Kudos
2 Replies
LucD
Leadership
Leadership

Renaming a file on a VMFS datastore is easy.

Renaming a .vmdk file is something else.

As you know, a virtual disk file consists basically of 2 files, the .vmdk or header file and the -flat.vmdk or actual data file.

Renaming these files individually will not work, since the header file contains a reference to the -flat.vmdk file.

That's why, as explained  KB1002491, you need to use a tool, like vmkfstools to rename a virtual disk.

So I'm afraid as long that there is no access to the API used by the vmkfstools in PowerCLI this will not be possible.

Another one of those small things that force PowerCLI users to still need a vMA 😞


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
GregorSm
Contributor
Contributor

So... I was checking PowerCLI 5.0 these days and Set-HardDisk cmdlet still haven't got -Name parameter. How can we regularly change the name of a VMDK file with PowerCLI again? I need this because it's one of the steps in migrating persistent / user data disks from VMware View 4.0 to 4.5 / 4.6.

As I can see, there's new support for ESXCLI. Can it be used to rename a .vmdk and how? Does it work only on ESX 5.0 hosts?

Kind regards

Gregor

0 Kudos