Thursday 19 April 2012

How to convert a thick provisioned disk to thin provisioned disk

If you created a virtual machine with Thick disks and want to convert it to thin provisioned disk please follow the below steps

Step 1 : Power off the virtual machine
Step 2 : Using putty login to the ESX/ESXi server console
Step 3 : Go the virtual machine directory where the virtual machine files are stored
Step 4 : Backup the virtual machine configuration file
Step 5 : Using vmkfstools command convert the thick disk to thin disk

# vmkfstools -i <thickdisk.vmdk> -d thin <newname.vmdk>

Once executed thick disk will be cloned to thin disk. After this process completed u must see two disk created with the newname ie (newname.vmdk and newname-flat.vmdk)

Step 6 : Open the virtual machine configuration file using vi editor
Step 7 : Locate for the old vmdk file name in virtual machine configuration file and replace it with new vmdk file
Step 8 : Make sure u are able to power on the virtual machine without any issues.
Step 9 : Then delete the old vmdk files

Tuesday 17 April 2012

How to rename a Virtual Machine and its Files

Renaming virtual machine files in-place using the console

Warning: Before proceeding, ensure that:
  • The virtual machine has a current backup and that it has been powered down.
  • The virtual machine does not have snapshots or virtual disks shared with other virtual machines. 

 

To manually rename the virtual machine's files:

  1. Log in to VMware vSphere Client.
  2. Locate the virtual machine in your host inventory.
  3. Power down the virtual machine.
  4. Right-click on the virtual machine and click Remove from inventory.
  5. Open a console to the ESX or ESXi host
  6. Navigate to the directory containing the virtual machine. For example: cd /vmfs/volumes/DatastoreName/originalname/.
  7. Rename the virtual disk (VMDK) files using the vmkfstools -E command.                                                        # vmkfstools -E "originalname.vmdk" "newname.vmdk"
  8. Copy the virtual machine configuration file (.vmx) using the command:
    # cp "originalname.vmx" "newname.vmx"

  9. Open the file new virtual machine configuration (for example, newname.vmx) in a text editor. For more information, see Editing configuration files in VMware ESX (1017022).

    For example:


    # vi "newname.vmx"

  10.  Within the configuration file, modify all old instances of the virtual machine's file names to the new file names. There should be at least these to adjust:
    nvram = "newname.nvram"
    displayName = "
    newname"
    extendedConfigFile = "
    newname.vmxf"
    scsi0:0.fileName = "
    newname.vmdk"[...]
    migrate.hostlog = "./
    newname-UUID.hlog"
    Repeat this process for each virtual machine disk. For example:
    scsi0:1.fileName = "
    newname_1.vmdk"
    scsi0:2.fileName = "
    newname_2.vmdk"
    Correct the VMkernel swap file reference. For example:
    sched.swap.derivedName = "/vmfs/volumes/DatastoreUUID/newname/newname-UUID.vswp
    Note
    : Be sure to rename both the .vswp file and the directory name for the swap file, bolded above.
  11. Correct any other remaining lines referencing the original path or file names.
  12. Save the file and exit the editor.
  13. Rename all the remaining files, except for the.vmxconfiguration file, to the new names desired.

    For example:

    # mv "originalname.nvram" "newname.nvram"
  14. Change directory to the parent directory:
    # cd ..

  15. Rename the directory for the virtual machine:
    # mv "originalname" "newname"
  16. Using VMware vSphere Client, browse the datastore and navigate to the renamed virtual machine directory
  17. Right-click on the virtual machine's new configuration file (for example, newname.vmx) and choose Add to inventory.

    Alternatively, you can use this command to inventory the virtual machine:

    # vmware-cmd -s register "/vmfs/volumes/DatastoreName/newname/newname.vmx"

  18. Power on the virtual machine.
  19. A question for the virtual machine displays in the Summary tab during power-on. Review the question by:
    • Clicking the Summary tab
    • Right-clicking the virtual machine in your inventory and selecting Answer question.

      When prompted, select I moved it, then click OK.

      Warning: Selecting I Copied It results in a change of the virtual machine's UUID and MAC address, which may have detrimental effects on guest applications that are sensitive toward MAC address changes, and virtual machine backups that rely on UUIDs.

  20. Optionally, delete the original virtual machine configuration file.

    For example:
    # rm /vmfs/volumes/DatastoreName/newname/originalname.vmx

How to Enable syslog on ESX

All ESX/ESXi hosts run a syslog service (syslogd) which logs messages from the VMkernel and other system components to a file. 
 
Note: In ESX, you must modify the remote host option in the /etc/syslog.conf file. The rempte host options are:
  • Log file path – Specifies a datastore path to the file where syslogd logs all messages.
  • Remote host – Specifies a remote host to which syslog messages are forwarded. To receive the forwarded syslog messages, your remote host must have a syslog service installed.
  • Remote port – Specifies the port used by the remote host to receive syslog messages.
     
    Resolution:
     
    To log events from an ESX host to a remote syslog server:
    1. Log in to the ESX host as root using an SSH client.
    2. Open the /etc/syslog.conf file using a text editor.
    3. Add this entry at the end of the file:
      *.*     @<IP_address_of_syslog-server>
      For example:
      *.*     @192.1.68.1

    4. Restart the syslog daemon using the command:
      service syslog restart
    5. Run this command to check if the ESX firewall has been opened for the syslog traffic:
      esxcfg-firewall -q|grep syslog
      If the firewall is open, you see an output similar to:
      syslog              : port 514 udp.out
      If the firewall is closed, you do not see any output.
    6. To open the firewall on the ESX host for syslog traffic and to refresh the firewall, run this command:
      esxcfg-firewall -o 514,udp,out,syslog && esxcfg-firewall -l