Virtually anything is possible!
Archive for June, 2010
Recreating a missing VMDK and descriptor file
Jun 30th
- Log in to the console of the ESX host.
- Go to the directory that contains the virtual disk with the missing header/descriptor file
- Identify the kind of SCSI controller the virtual disk is using this command:
less *.vmx | grep –i virtualdev - Run this command to identify and record the exact size of the flat file:# ls -l *.vmdk
- Run the vmkfstools command to create a new virtual disk.# vmkfstools -c filesize -a scsi type filename.vmdk
see the example belowvmkfstools -c 4294967296 -a lsilogic temp.vmdkThis command uses the following flags:-c <size> (This is the size of the virtual disk.)
-a <virtual controller> (Whether the virtual disk was configured to work with BusLogic or LSILogic.)If you are short on disk space, you can create the temporary disk as type thin. The associated -flat file consumes almost no space (1Mb) instead of the amount specified with -c (as we are not keeping the new -flat file, this is not a problem). The consequence is that the header file will contain an extra line that must be removed manually. The command looks like this:
# vmkfstools -c 4294967296 -a lsilogic -d thin temp.vmdk
The files temp.vmdk and temp-flat.vmdk are created as a result.
- Check if vmdk was created with this command : ls –ltr *.vmdk
- Delete temp-flat.vmdk as it is not needed. Run the command:# rm temp-flat.vmdk
- Rename temp.vmdk to the name that is required to match the orphaned -flat file
# mv temp.vmdk win2003x86.vmdk
- Use nano to edit the descriptor
- Find the line # Extent description
RW ####### VMFS “temp–flat.vmdk
and change the name of the -flat to match the orphaned -flat file you have. - Find the line with ddb.thinProvisioned and remove it.
(if -d thin was used and the original was not a thin disk)
- Find the line # Extent description
- The Virtual machine is now ready to power on
See the KB article 1002511
How to Power off an unresponsive VM on an ESX host
Jun 30th
Powering off an unresponsive virtual machine on an ESX host
1) Determine the host on which the virtual machine is running.
This information is available in the virtual machine’s Summary tab when viewed in the vSphere Client page.
2) Login to that Host using ssh client
3) Type vmware-cmd -l (shows full path to runing vms on this host)
4) Then type vmware-cmd (path to the vm) getstate see the example below.
vmware-cmd vmfs/volumes/49be35b9-b234a901-5406-002219b69217/Windows-2003-32-bit/win2003x86.vmx getstate
To stop the VM use the vmware-cmd command see the example below.
5) On the ESX host type vmware-cmd /vmfs/volumes/49be35b9-b234a901-5406-002219b69217/Windows-2003-32-bit/win2003x86.vmx stop
6) The type vmware-cmd /vmfs/volumes/49be35b9-b234a901-5406-002219b69217/Windows-2003-32-bit/win2003x86.vmx getstate
7) If the VM getstate output is still on then use the stop hard command see the example below.
vmware-cmd /vmfs/volumes/49be35b9-b234a901-5406-002219b69217/Windows-2003-32-bit/win2003x86.vmx stop hard
This article pertains to ESX and does not apply to ESXi.
For more information see the KB Article: 1004340
For ESXi hosts, see Powering off a virtual machine on an ESXi host (1014165).
How to clone a virtual machine on VMware ESXi
Jun 30th
Once you have established SSH connection to the server, you need to create a directory for the virtual machine you want to create in the Data Store, which should be here: “/vmfs/volumes/datastore1 /”.>
Type the following command: mkdir /vmfs/volumes/datastore1 /<name on your new VM>
We will now use vmkfstools to clone our virtual machine. In the example below, we show how to clone a Windows 2003 Server 32-bit, in our file structure.
/Vmfs/volumes/49be35b9-b234a901-5406-002219b69217 # /sbin/vmkfstools-i “/ vmfs/volumes/49be35b9-b234a901-5406-002219b69217/Windows-2003-32-bit/WindowsServer-2003 Serverx32.vmdk” ” /vmfs/volumes/datastore1/namn on the system’s directory/name of systemet.vmdk ” Disk Cloning
Clone: 100% done.
The virtual machine should now be cloned. All that remains now are two simple steps.
1st > Sign in with VMware vSphere client and select <Make a new VM on this server>.
2nd > Select “Custom” and then when you get to choose disk when the VM is created, you browse the data store and select the newly named vmdk file.
Enable SSH for ESXi
Jun 6th
By default SSH is not enabled in ESXi. Follow the steps below to enable it
- At the ESXi console, press alt+F1
- Type: unsupported
- Enter the root password
- At the prompt type “vi /etc/inetd.conf”
- Look for the line that starts with “#ssh”
- Remove the “#”
- Save “/etc/inetd.conf” by typing “:wq!” or “ZZ“
- Restart the management service “/sbin/services.sh restart” or reboot the host