Monday, April 12, 2010

VMware tips

ESX - paid server
ESXi - free version

.vmdk - Virtual Machine Disk file format
.VMX files – a VMX file is the primary configuration file for a virtual machine.

Enabling SSH in VMware Hypervisor.
Press ALT F1 at the physical console of the system and type 'unsupported' and then the root password of the machine. From there uncomment ssh in /etc/inetd.conf and restart services with a /sbin/services.sh restart.

Moving VM's in VMware ESXi
Connect to the hypervisor that your VMDK files are on via ssh. From there you can navigate to the vmx and vmdk files you wish to migrate under the /vmfs directory. Your VM's should be under /vmfs/volumes/datastore#. Once you are in the directory you wish to migrate you can use SCP to copy the physical disk files to the other machine. With a command similar to scp * root@hostname:/vmfs/volumes/ datastore#/vm-dir. You will need to have the destination directory created ahead of time. Once the files have copied you will need the specific command VMware-cmd for the registration of the VM with the hypervisor and to power on the VM. A command similar to VMware-cmd -H hostname_of_hypervisor -s register /vmfs/volumes/datastorename/vm-dir/vm.vmx datacenter-name resource-pool. The easiest way to register VM's is through the VMware Console. VM's can be registered with the hypervisor by navigating
to the datastore on the summary tab under the main hypervisor in the GUI. Double click on the datastore to browse the files. Right click on the VMX file you wish to register and select add to inventory.

Now that our VM has been moved and registered we are ready to boot it. You can do this from the remote command line with VMware-cmd -H hostname_of_hypervisor /vmfs/volumes/datastorename/vm-dir/vm.vmx start or through the GUI.

vim-cmd
  1. vim-cmd vmsvc/getallvms
  2. vim-cmd vmsvc/power.getstate
  3. vim-cmd vmsvc ---- returns full list

For getting delay in power on BIOS (useful in super fast machine). Add line in .vmx file
  • bios.bootDelay = "5000"
  • bios.forceSetupOnce = "TRUE"
The ESX Configuring tools are located @ /usr/sbin/esxcfg*


VMWare ESX or ESXi CAN run inside a virtual machine, provided certain prerequisites are satisfied.
This kind of setup is of course completely useless (and totally unsupported) in a production environment, but can be very useful for two purposes:

  • Testing or studying ESX or ESXi if you don't have a physical server available.
  • Testing or studying the whole Virtual Infrastructure if you don't have at least two servers and a SAN.


Prerequisites:

  • You need some physical resources. In order to run ESX or ESXi in VM, the VM needs at least 1.5 GB of memory, two VCPUs and enough disk space for the server itself and for the VMs you will run inside it.
  • You absolutely need a physical CPU with native virtualization support (Intel VT or AMD-V).
  • You need to run VMWare Workstation 6.5 or VMWare Server 2 on the physical host. Previous versions can't succesfully run ESX or ESXi in a VM.
  • A 64-bit OS on the physical host is useful but not required.

Setup:

  • Enable native virtualization support for your CPU in the motherboard BIOS (it's often not enabled by default).
  • Install your preferred virtualization software. I've tested everything succesfully using VMWare Workstation 6.5.2 on a Windows XP x64 host, but it should work with VMWare Server 2.0 and/or Linux hosts, too.
  • Create a custom VM using those setting:
    • Hardware compatibility level: latest
    • Guest operating system: other 64-bit
    • Virtual CPUs: at least 2
    • Memory: at least 1.5 GB
    • Networking: Host-only or NAT
    • SCSI adapter: LSI Logic
    • Virtual disk type: SCSI
    • Virtual disks: as you wish; I suggest using at least two virtual disks, a 10-GB one for installing the system and another one where to create a datastore. The space should be pre-allocated.
    • Remove floppy, sound card, USB controller, etc. Leave only networking and storage.
    • CPU Execution mode: Intel VT-x or AMD-V (very important).
  • Manually edit the VMX file of the virtual machine you created, setting the following parameters:

    guestOS = "vmkernel"
    monitor_control.vt32 = "TRUE"
    monitor_control.restrict_backdoor = "TRUE"

  • Start the VM and install ESX or ESXi from the installation ISO image.

  • Configure the networking to allow the ESX or ESXi virtual server to talk with the host.

Usage:

  • Use your web browser to connect to you virtual server's IP address and download the VI Client.
  • Install the VI Client on the host.
  • Connect to the virtual ESX/ESXi server.
  • Create a VM as you wish.
  • Power up the VM.
  • If everything is done correctly, the VM will start. If it complains about not being able to power on a VM inside a VM, then there is an error with the `monitor_control.restrict_backdoor' parameter (or you're using an old version of VMWare Workstation/Server).

    VMWare Server 2.0, you won't be able to select the CPU execution mode in the GUI; you can fix this by adding the following line to the .vmx file: monitor.virtual_exec = "hardware"



No comments:

Post a Comment