Archive for the ‘VMWare’ Category

CentOS – Launching VMWare Workstation VMs at boot

Sunday, January 23rd, 2011

I was searching for a solution to launch and suspend VMWare Workstation VMs on a CentOS 5-machine during boot/shutdown.
A script script for launching VirtualBox VMS during boot inspired me to create one for VMWare Workstation.
In this example I have teamed my VMs in a team /vms/my_team.vmtm, it could as well be a single VM (.vmx) that is being launched.
The VM Team will be launched with a different user account as VMWare not allows root to launch VMs.
During shutdown root however can suspend the VM Team, and this is also the action being used during system shutdown.

  1. Create a user vmuser
    useradd vmuser
    passwd vmuser
  2. Create the VMHeadless script. I have teamed all my VMS and will launch/suspend the team /vms/my_team.vmtm
    vi /etc/init.d/vmheadless

    #!/bin/bash
    ### BEGIN INIT INFO
    # Provides:          vmheadless.sh
    # Required-Start:    $remote_fs $syslog
    # Required-Stop:     $remote_fs $syslog
    # Default-Start:     2 3 4 5
    # Default-Stop:      0 1 6
    # chkconfig: 2345 99 20
    # Short-Description: Start VM
    # Description:       Start/stop the virtual machines
    ### END INIT INFO
     
    MACHINE_NAME="/vms/my_team.vmtm"
    VM_USER="vmuser"
    RETVAL=0
    LD_LIBRARY_PATH=/usr/lib/vmware:$LD_LIBRARY_PATH
    PATH=/sbin:/usr/sbin:/bin:/usr/bin:/usr/local/bin
     
    id=`id -u`
    if  [ "$id" != "0" ] ; then
       echo "This script must be run as root" 1>&2
       exit 1
    fi
     
    # Load the VERBOSE setting and other rcS variables
     [ -f /etc/default/rcS ]  && . /etc/default/rcS
     
    # Load the VERBOSE setting and other rcS variables
    #. /lib/init/vars.sh
     
    # Define LSB log_* functions.
    # Depend on lsb-base (>= 3.0-6) to ensure that this file is present.
    . /lib/lsb/init-functions
     
    # Get function from functions library
    . /etc/init.d/functions
     
    # Load network defaults. Use this if there is any extra network stuff to do first.
     
    case "$1" in
    start)
       su $VM_USER -c "/usr/bin/vmrun start $MACHINE_NAME nogui"
            RETVAL=0
      echo "Started VM Headless RETVAL=($RETVAL)"
            ;;
    stop)
      /usr/bin/vmrun suspend "$MACHINE_NAME"
            RETVAL=$?
     echo "Suspended VM Headless RETVAL=($RETVAL)"
            ;;
    status)
      ps=`ps -ef | grep vmware-vmx | grep -v grep | wc -l`
      if  [ "$ps" -gt 0 ]  ; then
        echo "$ps VMS started"
        RETVAL=1
      else
        echo "VMS not running"
        RETVAL=0
      fi
            ;;
    restart)
      /usr/bin/vmrun suspend "$MACHINE_NAME" nogui
            RETVAL=$?
     echo "Suspended VM Headless RETVAL=($RETVAL)"
      su backup -c "/usr/bin/vmrun -T ws start $MACHINE_NAME nogui"
            RETVAL=$?
      echo "Started VM Headless RETVAL=($RETVAL)"
            ;;
    *)
            echo "Usage: $0 { start | stop }"
            RETVAL=1
            ;;
    esac
    exit $RETVAL
    
  3. Enable VMHeadless during boot
    chkconfig –add vmheadless
    chkonfig –level 2345 vmheadless on
  4. Launch the VMHeadless daemon, and thus launching the VM Team
    service vmheadless start

PS – Disable Unidentified network for VM nics

Wednesday, October 6th, 2010

This script adds the *NdisDeviceType registry value with value 1 to the keys of the VMWare network cards.
Afterwards it disables and enables the networkcards to let the changes take effect.

$nics = gci "HKLM:\SYSTEM\\CurrentControlSet\\Control\\Class\\{4D36E972-E325-11CE-BFC1-08002BE10318}"
$nics | foreach-object -process {
    $devInstanceId = $_.getvalue("DeviceInstanceID")
    if($devInstanceId -match "VMWARE"){
        Write-Host $_.Name
        $regpath = ( $_.name ) -replace("HKEY_LOCAL_MACHINE","HKLM:")
        new-itemproperty -path $regpath -name "*NdisDeviceType" -value 1 -PropertyType "DWORD"
    }
}
 
 $wminics = get-wmiobject win32_networkadapter | where-object {$_.name -like "*vmware*" }
 $wminics | foreach-object -process { 
        
     write-host -nonew "Disabling $($_.name) ... "
     $result = $_.Disable() 
     if ($result.ReturnValue -eq -0) { write-host " success." } else { write-host " failed." } 
        
     write-host -nonew "Enabling $($_.name) ... "
     $result = $_.Enable() 
     if ($result.ReturnValue -eq -0) { write-host " success." } else { write-host " failed." } 
 }

ESXi 3.5 and Server 2003 dualboot

Sunday, January 31st, 2010

After some testing I managed to create a dualboot setup with ESXi 3.5 and Windows Server 2003.

  1. Install ESXi to harddisk 1
  2. Install Windows Server 2003 to harddisk 2. Delete the existing partition on harddisk 2 if ESXi has created one.
    On the first reboot during the installation you should get an error “NTLDR is missing”
  3. Boot with a live linux cd-rom, eg KNOPPIX
  4. (Re-)install syslinux bootloader to boot partition (Hypervisor0)
    sudo syslinux /dev/hda1
    file is read only. overwrite anyway (y/n)? y
    sudo mkdir /mnt/Hypervisor0
    sudo mount /dev/hda1 /mnt/Hypervisor0
    vi /mnt/Hypervisor0/syslinux.cfg
    
    

    original:

    default safeboot.c32
    
    

    modified:

    default menu.c32
    menu title Dual boot
    timeout 100
    label esx
    menu label ESXi 3.5
    COM32 safeboot.c32
    LABEL win
    MENU LABEL MS Windows Server 2003
    COM32 chain.c32
    APPEND boot ntldr=/NTLDR
    
    
  5. Copy syslinux modules menu.c32 and chain.c32 to boot partition (Hypervisor0)
    Use locate to find the folder on the live cd that contains the modules, eg locate menu.c32

    cp /usr/lib/syslinux/menu.c32 /mnt/Hypervisor0
    cp /usr/lib/syslinux/chain.c32 /mnt/Hypervisor0
    
    
  6. Reboot

Installing VMWare-tools in ClarkConnect

Thursday, October 12th, 2006

Installing VMWareTools in ClarkConnect is very simple.
I found this solution on the ClarkConnect Forum.

Step 1: Determining your kernel version
With the following command you can retrieve your kernel version. On my system it is currently version 2.6.9-42.cc

  [root@s1 /] # uname -r
2.6.9-42.cc

Step 2: Preparing your system
First you need to update your package list using the apt-get update command, and secondly you need to install all the required packages.

 apt-get update
apt-get install kernel-devel#2.6.9-27.cc
apt-get install binutils
apt-get install gcc
apt-get install make

Step 3: Verifying your installation
After installing the packages you can verify your installation with the following commands:

  [root@s1 /] # updatedb
 [root@s1 /] # locate linux/version.h
/usr/src/kernels/2.6.9-42.cc-i686/include/linux/version.h
/usr/include/linux/version.h
 [root@s1 /] # rpm -q kernel-devel
kernel-devel-2.6.9-42.cc

The first command updates the locate filedatabase. Second command queries that database for a file called version.h in a folder called linux. The third command searches the installed packages called kernel-devel.

Step 4: Installing and configuring VMWare Tools
First you need to mount your cd-rom drive.

  [root@s1 /] # mkdir /mnt/cdrom
 [root@s1 /] # mount /dev/hdc /mnt/cdrom

Then you can start the installation and configuration of VMWare Tools. Normally the installer gives the good defaults so you just need to press enter on each question to accept the default.

  [root@s1 /] # cd /mnt/cdrom
 [root@s1 cdrom] # rpm -Uvh VMwareTools-1.0.1-29996.i386.rpm
 [root@s1 cdrom] # vmware-config-tools.pl

Step 5: Reset your network

  /etc/init.d/networking stop
 rmmod pcnet32
 rmmod vmxnet
 depmod -a
 modprobe vmxnet
 /etc/init.d/networking start

That’s really all needed to install VMwareTools on ClarkConnect.

Installing VMWare-tools in Debian

Thursday, October 12th, 2006

I found this information on a german site and it’s fairly simple to do.
First you need to determine your kernel version.

 debian-lamp:~#uname -r
2.6.8-2.386

Secondly you need to install some standard tools:

 apt-get install make binutils cpp cpp-3.3 gcc-3.3 autoconf automake gcc

Then you need to install the matching kernel-headers. Remark that the numbering after “kernel-headers-” is the same as your kernel version .

 apt-get install kernel-headers-2.6.8-2-386

Make a necessary soft link.

  mkdir -p /usr/src/linux
 ln -s /usr/src/kernel-headers-2.6.8-2-386/include /usr/src/linux/include

Mount your cdrom

  mkdir /mnt/vmware
 mount /dev/cdrom /mnt/vmware

Extract and install VMwareTools

  cd /tmp/
 tar xvzf /mnt/vmware/VMwareTools*.tar.gz
 cd vmware-tools-distrib/
 ./vmware-install.pl

Reset your networking

  /etc/init.d/networking stop
 rmmod pcnet32
 rmmod vmxnet
 depmod -a
 modprobe vmxnet
 /etc/init.d/networking start