Export a VM from Nutanix AHV to VMware ESXi

Post Source : acropolis.ninja

In this example I export a CentOS 7 template from AHV to ESXi.  There are a couple of ways to accomplish this task, depending on whether you need a thin provisioned file or a thick provisioned file.

 

Note 1:

Step 2: You can check the path of the disk using the below command.

vm.get <VM_Name> include_vmdisk_paths=1

Note 2:

Always try to export the VM from the host which is shut down and then you will get all the permissions.

Thin Provisioned

Step 1: Find UUID of the vDisk.

Connect to a CVM, enter aCLI and run the command vm.get [vm name]

Copy the vmdisk_uuid.  (Notice the size of the VM under the STORAGE column in PRISM, that should be the size of the exported file… assuming the VM only has 1 vdisk)

 

Step 2: Export the vDisk

vDisks of AHV VMs are located in a hidden folder on the container named .acropolis.  We use the qemu-img command to export the vDisk.  The vdisk is exported in a thin format and should match the size of the VM in PRISM.  If the disk is large then the command might take longer to complete than the timeout value of the SSH session.  In order to not have the conversion corrupted by the SSH session timing out either use keep alives or run the task in the background by using a ‘&’ at the end of the command.  In this example I will run the task in the background.

Make sure the VM is powered off, then run the following command:

qemu-img convert –O vmdk nfs://127.0.0.1/[container]/.acropolis/vmdisk/[UUID] nfs://127.0.0.1/[container]/[vmdisk].vmdk &

Example:
qemu-img convert -O vmdk nfs://127.0.0.1/Nutanix/.acropolis/vmdisk/fea6b382-43ec-4236-b521-edac7ac923cb nfs://127.0.0.1/Nutanix/CentOS_7.vmdk &

We can check that the task is still running using the command PS –A | grep qemu.  When the command returns nothing we know it has completed.

 

 

Step 3: Copy the vDisk

Once the export completes, you can now whitelist a Windows 2012 R2 server and simply browse to the container and copy the vDisk.  Alternatively you can also use a SCP tool  by connecting with admin@[host]:2222.

 

Step 4.  Create a new Virtual Machine and Upload the VMDK to ESXi.

Here I create a new VM with no virtual disk, because I am going to upload the VMDK to the VM’s folder.

Use a SCP tool to connect to ESXi and upload the VMDK to the VM’s folder.

 

Step 5: Use vmkfstools to create the vmdk disk descriptor.

ESXi expects vmdks to have a disk descriptor file that points to the raw vmdk file.  We can use vmkfstools to create that using the following command:

vmkfstools –i [sourceVMDK] [destinationVMDK] –d thin

Example:
vmkfstools –i CentOS_7.vmdk CentOS7.vmdk –d thin

Once the disk descriptor is created you can delete the original file.

 

Step 6: Attach the VMDK to the VM and power it on

Thick Provisioned

Exporting a thick provisioned disk is similar to the process above, except we don’t need to use qemu.  We can just SCP the disk from the .acropolis directory.

Step 1: Find UUID of the vDisk.

Connect to a CVM, enter aCLI and run the command vm.get [vm name]

Copy the vmdisk_uuid.  (Notice the size of the VM under the STORAGE column in PRISM, that should be the size of the exported file… assuming the VM only has 1 vdisk)

 

Step 2: SCP the vdisk from the .acropolis/vmdisk directory.

Use a SCP tool to connect to the Nutanix CVM.  If you use WINSCP you will have to use the Open Directory button (CTRL+O) to open the hidden .acropolis/vmdisk directory.

Copy the vDisk that matches the UUID from vm.get. Then copy the file to ESXi.

 

Step 3.  Create a new Virtual Machine and Upload the VMDK to ESXi.

Here I create a new VM with no virtual disk, because I am going to upload the VMDK to the VM’s folder.

Use a SCP tool to connect to ESXi and upload the VMDK to the VM’s folder.

 

Step 4: Use vmkfstools to create a VMDK descriptor file, then replace the flat file with the exported vDisk.

Following the process in VMware KB 1002511 we recreate a vDisk descriptor file.  The file has to be created with the exact same size as the exported vDisk.  Use ls –l to check the size of the exported vDisk.  Then use the following command to create the vDisk descriptor file:

vmkfstools –c [vDisk size] [destination file] –d thin

Example:
vmkfstools -c 42949672960 CentOS_7.vmdk -d thin

Once the file is created then replace the –flat.vmdk file with the exported vDisk.

Example:
mv fea6b382-43ec-4236-b521-edac7ac923cb CentOS_7-flat.vmdk

 

Step 5: Attach the VMDK to the VM and power it on

Advertisements

How to remove “No Management Network Redundancy” warning on vSphere using das.ignoreRedundantNetWarning

Source: virtuallylg

Whilst updating my ApplicationHA lab images for various Symantec Partner events that i will be running later this year I noticed that I was seeing a “This Host has no Management network redundancy” message on my ESX servers, whilst it doesn’t effect my labs from running properly it is a bit off putting seeing warning triangles next to the ESX servers. I typically use a single NIC for creating ESX servers for the lab and this is the reason why it gets displayed, in real production and test environments you would normally have redundant NICs configured and this message wouldn’t appear.

Here are the steps that will remove the warning using the “das.ignoreRedundantNetWarning” attribute.

There are a couple of ways to remove the message from appearing, the correct way is to add redundancy to the management networks by adding in another NIC to the configuration or alternativeliy you can use the “das.ignoreRedundantNetWarning” attribute in the advanced vMwareHA/vSphere HA settings.

1. From within the vSphere Client right click on the cluster and edit settings.

2. Select (Depending on your version) the VMwareHA or vSphere HA feature and click “Advanced Options”

3. In the options column enter the tag “das.ignoreRedundantNetWarning”

4. In the value column enter “true” for the value.

5. Click on “OK” and then “OK” again to make the changes in the advanced options

6. right click on the ESX server which is diplaying the warning symbol and select “Reconfigure for vSphere HA” or “Reconfigure for VMware HA”

Thats it, once the reconfigure task completes the warning should disappear and you are left with a warning icon clean ESX server.

Management Redundant Network warning cleared

of course on the screen shot I do have a warning sign on the Win2003-SQL virtual machine but thats a story for another day….

How to Shrink OS disk in Windows running on VMware.

Source : Expertsexchange

The following procedure is split into two parts

 Shrink the Operating System partition – This is covered in Step 1.
 Shrink the VMware Virtual Machine Disk (VMDK) – This is covered in Step 2

1. Login to the Virtual Machine and shrink the OS Partition

Before we can shrink the VMware virtual machine disk (VMDK), we need to shrink the OS partition. (to avoid file system corruption). In this example I am using Windows 2008 R2, which has a shrink function. If you are using another OS, please see the other 3rd party partition utilities which are available, they are listed in my Experts Exchange article

Using an RDP (Remote Desktop Protocol) connection or connect via the Console, using the vSphere Client, login to the virtual machine as an Administrator.
Logon to the Virtual MachinePress Control-Alt-Delete to login to the virtual machine.
Right Click My Computer and Select ManageRight Click My Computer and Select Manage
Select Disk ManagementSelect Disk Management, and select the partition you need to shrink.
Right Click VolumeRight Click the Volume/Partition to shrink, and select Shrink.
Shrink Disk QueryThe above dialogue will briefly appear whilst the file system is queried.
Shrink C:the above dialogue will appear. Enter a size to reduce the OS partition.

In this example the VMware virtual machine disk (VMDK) is 40GB, and we would like to reduce the size of the VMware virtual machine disk (VMDK) to 20GB. The Disk Management utility scans the available file system, and reports a maximum size the OS partition can be reduce by, this is based on current file system usage.

Enter the figure 19.5 (GB) x 1024 = 19968
Shrink SizeOS Partition size after Shrink Operation.
Disk Manager after Shrink OperationAs can be clearly seen in the above screenshot, there is now an unallocated 19.5GB space on the virtual disk, in Step 2 the VMware virtual machine disk (VMDK) will be “chopped”, removing this unallocated storage space, and finally reducing the virtual machine disk (VMDK) to 20GB. Providing that we DO NOT affect the existing partitions, this is a safe operation. So in effect the “cut” will be made in the unallocated storage space, after the OS partition.

2. Reducing the size of the VMware Virtual Machine Disk (VMDK)

Login and connect to the VMware vSphere Host ESXi server which hosts the virtual machine.

see my previous Experts Exchange articles

Power OFF the Virtual Machine, and change to the datastore path where the VMware virtual machine disk (VMDK) is located.

cd /vmfs/volumes//
VM Folder PathWe need to edit the *.vmdk, which is the descriptor file, which contains the variables for the size of the *.-flat.vmdk. Using cat, this is what the descriptor file contains
VMDK Descriptor fileThe number highlighted above, under the heading #Extent description, after the letters RW, defines the size of the VMware virtual disk (VMDK).

this number – 83886080, and it’s calculated as follows:

40 GB = 40 * 1024 * 1024 * 1024 / 512  =  83886080

We wanted to reduce the size of the VMware virtual machine disk (VMDK) from 40 GB to 20 GB. So the value we need to enter into the descriptor file is:-

20 GB = 20 * 1024 * 1024 * 1024 / 512  =  41943040

Using vi, edit the descriptor file, and change the number from 83886080 to 41943040, and save the file.
VMDK Edited with viMigrate or Copy the virtual machine to another datastore, if you do not have the migrate option, see my Experts Exchange article here

After the virtual machine disk (VMDK) has been moved, you will notice the disk size reflects the desired size of 20GB.
Size of virtual disk, as viewed from vSphere ClientSize of virtual disk as viewed from consoleAfter restarting the virtual machine, and checking with Disk Management, you will notice the 19.5GB unallocated storage space, has been removed, and disappeared.
Size of virtual disk as viewed from Disk Management in the OS
Congratulations, you have successfully Shrunk a VMware Virtual Machine Disk (VMDK)

Powercli script to capture Cpu & Memory usage stats

Connect-VIServer <server> -User <user> -Password <password>
$allvms = @()
$allhosts = @()
$hosts = Get-VMHost
$vms = Get-Vm

foreach($vmHost in $hosts){
$hoststat = “” | Select HostName, MemMax, MemAvg, MemMin, CPUMax, CPUAvg, CPUMin
$hoststat.HostName = $vmHost.name

$statcpu = Get-Stat -Entity ($vmHost)-start (get-date).AddDays(-30) -Finish (Get-Date)-MaxSamples 10000 -stat cpu.usage.average
$statmem = Get-Stat -Entity ($vmHost)-start (get-date).AddDays(-30) -Finish (Get-Date)-MaxSamples 10000 -stat mem.usage.average

$cpu = $statcpu | Measure-Object -Property value -Average -Maximum -Minimum
$mem = $statmem | Measure-Object -Property value -Average -Maximum -Minimum

$hoststat.CPUMax = $cpu.Maximum
$hoststat.CPUAvg = $cpu.Average
$hoststat.CPUMin = $cpu.Minimum
$hoststat.MemMax = $mem.Maximum
$hoststat.MemAvg = $mem.Average
$hoststat.MemMin = $mem.Minimum
$allhosts += $hoststat
}
$allhosts | Select HostName, MemMax, MemAvg, MemMin, CPUMax, CPUAvg, CPUMin | Export-Csv “c:\Hosts.csv” -noTypeInformation

foreach($vm in $vms){
$vmstat = “” | Select VmName, MemMax, MemAvg, MemMin, CPUMax, CPUAvg, CPUMin
$vmstat.VmName = $vm.name

$statcpu = Get-Stat -Entity ($vm)-start (get-date).AddDays(-30) -Finish (Get-Date)-MaxSamples 10000 -stat cpu.usage.average
$statmem = Get-Stat -Entity ($vm)-start (get-date).AddDays(-30) -Finish (Get-Date)-MaxSamples 10000 -stat mem.usage.average

$cpu = $statcpu | Measure-Object -Property value -Average -Maximum -Minimum
$mem = $statmem | Measure-Object -Property value -Average -Maximum -Minimum

$vmstat.CPUMax = $cpu.Maximum
$vmstat.CPUAvg = $cpu.Average
$vmstat.CPUMin = $cpu.Minimum
$vmstat.MemMax = $mem.Maximum
$vmstat.MemAvg = $mem.Average
$vmstat.MemMin = $mem.Minimum
$allvms += $vmstat
}
$allvms | Select VmName, MemMax, MemAvg, MemMin, CPUMax, CPUAvg, CPUMin | Export-Csv “c:\VMs.csv” -noTypeInformation

Enabling Password Free SSH Access on ESXi

When people ask  “how” to enable password free SSH, the question I always ask in return is “should” you enable password free SSH?  In most situations I would dare say the answer is probably not.  I often find that the decision to enable password free access is not based on any real requirement, but rather is done for the sake of convenience – admins want easy access to their vSphere hosts.  In my opinion, this is a case where security should trump convenience.  However, having said that I do realize that there are valid situations where SSH access is unavoidable, and depending the situation it might make sense to enable password free access.  My point here is that just because you can setup password free SSH doesn’t mean it’s a good idea.  Keep in mind, once you enable password free SSH:


 

  • Anybody with access to the root account on the remote host will have full root access to your ESXi host.
  • Root users allowed password free access to ESXi are not affected by password changes.
  • Root users allowed password free access to ESXi are not affected by lockdown mode.

 

With that I’ll jump down off my soapbox and go over the steps to enable password free SSH.   It’s really pretty easy.  Two basic steps:

1.  On the remote host use “ssh-keygen” to create a private/public key pair.  You can use an RSA or DSA token.  Make sure you leave the passphrase empty/blank.

1

2.  Next, append the user’s public key (created by the ssh-keygen tool) to the /etc/ssh/keys-root/authorized_keys file on the ESXi host.  Here’s an easy way to do this  (I got this nifty syntax from here):

# cat /root/.ssh/id.dsa.pub | ssh root@<esx host> ‘cat >> /etc/ssh/keys-root/authorized_keys’

2

With the remote host’s public key stored in the “authorized_keys” file, anytime this user SSH’s to the vSphere host instead of prompting for a password the host will check the remote users public key against what’s in the authorized_keys file, and if a match is found access is allowed.

Note:  I’ve seen a few articles that mentioned the need to edit the /etc/ssh/sshd_config file.  On ESXi 5.0  you do not need to edit the sshd_config file. The file is already configured to allow password free SSH.  All you need to do is load the user’s public keys into the /etc/ssh/keys/authorized_keys file.

Default Passwords for VMware and EMC

Default Passwords

Here is a collection of default password to save you time googling for them:

EMC Secure Remote Support (ESRS) Axeda Policy Manager Server:
•Username: admin
•Password: EMCPMAdm7n

EMC VNXe Unisphere (EMC VNXe Series Quick Start Guide, step 4):
•Username: admin
•Password: Password123#

EMC vVNX Unisphere:
•Username: admin
•Password: Password123#
NB You must change the administrator password during this first login.

EMC CloudArray Appliance:
•Username: admin
•Password: password
NB Upon first login you are prompted to change the password.

EMC CloudBoost Virtual Appliance:
https://:4444
•Username: localadmin
•Password: password
NB You must immediately change the admin password.
$ password

EMC Ionix Unified Infrastructure Manager/Provisioning (UIM/P):
•Username: sysadmin
•Password: sysadmin

EMC VNX Monitoring and Reporting:
•Username: admin
•Password: changeme

EMC RecoverPoint:
•Username: admin
Password: admin
•Username: boxmgmt
Password: boxmgmt
•Username: security-admin
Password: security-admin

EMC XtremIO:

XtremIO Management Server (XMS)
•Username: xmsadmin
password: 123456 (prior to v2.4)
password: Xtrem10 (v2.4+)

XtremIO Management Secure Upload
•Username: xmsupload
Password: xmsupload

XtremIO Management Command Line Interface (XMCLI)
•Username: tech
password: 123456 (prior to v2.4)
password: X10Tech! (v2.4+)

XtremIO Management Command Line Interface (XMCLI)
•Username: admin
password: 123456 (prior to v2.4)
password: Xtrem10 (v2.4+)

XtremIO Graphical User Interface (XtremIO GUI)
•Username: tech
password: 123456 (prior to v2.4)
password: X10Tech! (v2.4+)

XtremIO Graphical User Interface (XtremIO GUI)
•Username: admin
password: 123456 (prior to v2.4)
password: Xtrem10 (v2.4+)

XtremIO Easy Installation Wizard (on storage controllers / nodes)
•Username: xinstall
Password: xiofast1

XtremIO Easy Installation Wizard (on XMS)
•Username: xinstall
Password: xiofast1

Basic Input/Output System (BIOS) for storage controllers / nodes
•Password: emcbios

Basic Input/Output System (BIOS) for XMS
•Password: emcbios

EMC ViPR Controller :
http://ViPR_virtual_ip (the ViPR public virtual IP address, also known as the network.vip)

•Username: root
Password: ChangeMe

EMC ViPR Controller Reporting vApp:
http://:58080/APG/

•Username: admin
Password: changeme

EMC Solutions Integration Service:
https://:5480

•Username: root
Password: emc

EMC VSI for VMware vSphere Web Client:
https://:8443/vsi_usm/
•Username: admin
•Password: ChangeMe

Note:
After the Solutions Integration Service password is changed, it cannot be modified.
If the password is lost, you must redeploy the Solutions Integration Service and use the default login ID and password to log in.

Cisco Integrated Management Controller (IMC) / CIMC / BMC:
•Username: admin
•Password: password

Cisco UCS Director:
•Username: admin
•Password: admin
•Username: shelladmin
•Username: changeme

Hewlett Packard P2000 StorageWorks MSA Array Systems:
•Username: admin
•Password: !admin (exclamation mark ! before admin)
•Username: manage
•Password: !manage (exclamation mark ! before manage)

IBM Security Access Manager Virtual Appliance:

•Username: admin
•Password: admin

VCE Vision:
•Username: admin
•Password: 7j@m4Qd+1L
•Username: root
•Password: V1rtu@1c3!

VMware vSphere Management Assistant (vMA):
•Username: vi-admin
•Password: vmware

VMware Data Recovery (VDR):
•Username: root
•Password: vmw@re (make sure you enter @ as Shift-2 as in US keyboard layout)

VMware vCenter Hyperic Server:
https://Server_Name_or_IP:5480/
•Username: root
•Password: hqadmin

https://Server_Name_or_IP:7080/
•Username: hqadmin
•Password: hqadmin

VMware vCenter Chargeback:
https://Server_Name_or_IP:8080/cbmui
•Username: root
•Password: vmware

VMware vCenter Server Appliance (VCSA) 5.5:
https://Server_Name_or_IP:5480
•Username: root
•Password: vmware

VMware vCenter Operations Manager (vCOPS):

Console access:
•Username: root
•Password: vmware

Manager:
https://Server_Name_or_IP
•Username: admin
•Password: admin

Administrator Panel:
https://Server_Name_or_IP/admin
•Username: admin
•Password: admin

Custom UI User Interface:
https://Server_Name_or_IP/vcops-custom
•Username: admin
•Password: admin

VMware vCenter Support Assistant:
http://Server_Name_or_IP
•Username: root
•Password: vmware

VMware vCenter / vRealize Infrastructure Navigator:
https://Server_Name_or_IP:5480
•Username: root
•Password: specified during OVA deployment

VMware ThinApp Factory:
•Username: admin
•Password: blank (no password)

VMware vSphere vCloud Director Appliance:
•Username: root
•Password: vmware

VMware vCenter Orchestrator :
https://Server_Name_or_IP:8281/vco – VMware vCenter Orchestrator
https://Server_Name_or_IP:8283 – VMware vCenter Orchestrator Configuration
•Username: vmware
•Password: vmware

VMware vCloud Connector Server (VCC) / Node (VCN):
https://Server_Name_or_IP:5480
•Username: admin
•Password: vmware
•Username: root
•Password: vmware

VMware vSphere Data Protection Appliance:
•Username: root
•Password: changeme

VMware HealthAnalyzer:
•Username: root
•Password: vmware

VMware vShield Manager:
https://Server_Name_or_IP
•Username: admin
•Password: default type enable to enter Privileged Mode, password is ‘default’ as well

Teradici PCoIP Management Console:
•The default password is blank

Trend Micro Deep Security Virtual Appliance (DS VA):
•Login: dsva
•password: dsva

Citrix Merchandising Server Administrator Console:
•User name: root
•password: C1trix321

TP-Link ADSL modem / router, Wi-Fi :
•User name: admin
•password: admin

VMTurbo Operations Manager:
•User name: administrator
•password: administrator
If DHCP is not enabled, configure a static address by logging in with these credentials:
•User name: ipsetup
•password: ipsetup
Console access:
•User name: root
•password: vmturbo

How To: Use PowerCLI to find (and disconnect) all CD Drives on VMs

VMs that leave ISOs mounted cause problems. I’d like to find all the VMs that have CD-ROM drives loaded with ISOs, look over that list, and then remove them if necessary.

Solution :

The first solution I provided here wasn’t that great, so I’m updating this post. The original contents have been changed because they previously would disconnect the entire CD-ROM drive, vs. just unmounting the ISO. As you can imagine, pulling the equivalent of ripping a CD-ROM drive out while a machine is running can cause some interesting behavior. The solution below outlines a much better way to do this.

Two one-line PowerCLI scripts will help us with this.

Firstly, to search for all Connected CD-ROMs for all VMs:

Get-VM | Where-Object {$_.PowerState –eq “PoweredOn”} | Get-CDDrive | FT Parent, IsoPath

And as long as there aren’t any you need to keep up, you can just select them all and then set the state to “No Media” for each CD-Drive:

Get-VM | Where-Object {$_.PowerState –eq “PoweredOn”} | Get-CDDrive | Set-CDDrive -NoMedia -Confirm:$False

Note the -Confirm:$False to allow it to just proceed with what it needs to do.