VMware PowerCLI useful commands

Connect to vCenter server:

Connect-VIServer -Server servername/ipaddress -Protocol https -Username ‘domain\accountname’ -Password ‘password’

Identifying quests with RDM mappings

Get-VM | Get-HardDisk -DiskType “RawPhysical”,”RawVirtual” | Select Parent,Name,DiskType,ScsiCanonicalName,DeviceName | fl

During a recent SAN migration, it was time to clean up RDM hard drives.

I went the route of shutting down the virtual machines and performing the following tasks to migrate the RDM hard drives to to VMDK hard drives.

1.click edit settings and select migrate
2.select datastore migration option
3.select advance under the disk
4.change the disk format to thick or thin disk
5.select the destination datastore .

There are several articles on this as well as a KB article.  I felt safest with the shutdown and migrate/conversion of the RDM to VMDK route due to the nature of the particular vm’s and the restore from backup time.

From the article, there are some more instructions.

Converting physical compatability mode  RDM disk to VMDK

1.directly converting physical mode rdm to vmdk will not be possisble First this physical mode rdm disk need to be converted to virtual mode.
2.shutdown the vm
3. click edit settings and select the physical mode rdm disk
4. click remove disk and delete from datastore ( this will not delete the data from the disk for physical compatability mode rdm disk)
5.click edit settings
6. Add hard disk
7. rdm disk
8.select the rdm disk and select the mode as virtual compatability mode
9.power on the server
10.click edit settings and select migrate
11.select datastore migration option
12.select advance under the disk
13.change the disk format to thick or thin disk
14.select the destionation datastore .

This is an RDM to VMDK conversion.  According to the blog author, the same process to go from VMDK to RDM.

  1. Here’s the current VM configuration:

    Hard disk 2 is the data disk, and is the one we’ll be switching to a VMDK.

  2. Disk configuration in Windows:
  3. Make a note of the size of the disk that you’re going to transfer. As with all RAID 1, the disk you’re going to mirror onto must be the same size (or larger) than the existing disk. My disk is 10Gb, so I’m going to add a new 10GB VMDK disk to the VM:
  4. New disk in Windows Disk Management will show in Disk Management.
  5. First you need to bring the disk online. Right-click the disk (where it says Disk 2, Unknown, 10.00GB, Offline) and choose Online.
  6. Now you need to initialize the disk, right-click again and choose Initialize:
  7. Now that we have our new disk ready for use, we can add it as a mirror to the original (RDM) disk. Right-click the RDM disk and choose Add Mirror…:
  8. Select the new unallocated disk:

    Click Add Mirror.
    If your original disk is currently a Basic disk you’ll be warned that the disk will be converted to a dynamic disk:

    Click

  9. The original disk and the new unallocated disk will be converted to dynamic disks:

    And very shortly afterwards the mirroring process will commence:

    How long this takes depends on the speed of your disks.

  10. Once the resynching process has completed both disks will show as Healthy:
  11. Remove the mirror from the original disk. Right-click it and choose Remove Mirror…:

    The Remove Mirror dialogue box will open, it selects the disk that you right-clicked but just confirm that it’s the right one:

    Click Remove Mirror, then click Yes.

  12. Now you’ll be running from the new VMDK disk, the old RDM disk will be showing as unallocated:
  13. Before removing the disk from the VM I like to right-click it and put it offline:
  14. Now edit the settings of the VM and remove the RDM disk:

    Choose the “and delete files from disk” option as this will delete the .rdmp file.

  15. Finally, here is the view from Windows Disk Management showing the VM that’s now only seeing the (new) VMDK disk:
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s