vCOPS 5: HTTP Status 404 –


When I opend the vCOPs v5 page this morning a got the following error:

image

So I checked if the services where running at the time. You can do this with the vcops-admin status command:

image

The next thing to check is the free disk space with the df –h command:

image

The disk seems to be full. To fix this issue, You can follow the steps from KB2016645:

To add a new virtual disk to the virtual machine:

  1. Power off the vApp.
  2. In the vSphere Client, right-click the virtual machine and click Edit Settings.
  3. Add the additional virtual disk.
    Note: Ensure to consider the future growth while selecting the disk size.
  4. Power on the vApp. The virtual machine automatically configures the newly added disk at boot time.

When the VM starts the disk is added to the VM and the LVM logical group will be configured with the new disk:

image

And we’re back:

image

Device eth0 has different MAC address than expected, ignoring.


After testing the Instant Recovery of a Linux web server. See my previous post about this Recovery process. The Linux web server has no network connection. I quick look at ifconfig only showed the loopback adapter. So I tried ifup eth0 and run into to following error:

image

This can simply be fixed by changing the MAC address. Open the Virtual Machine Properties and write down the MAC Address:

image

open the /etc/sysconfig/network-scripts/ifcfg-eth0 in your favorite editor and change the HWADDR to the new MAC address and save the file.

image

The final step is to restart networking via /etc/init.d/network restart.

vSphere: Hot Add or Remove a VMDK with a Linux VM


In this post I will show you how to hot add a new VMDK to a Linux VM. I will also post how to remove a VMDK if necessary.

 

Hot Add a new VMDK

Add the new VMDK:

image

After you added the new VMDK login to the VM and run fdisk –l

[root@nagios ~]#  fdisk -l

Disk /dev/sda: 21.4 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          13      104391   83  Linux
/dev/sda2              14        2610    20860402+  8e  Linux LVM

The new disk isn’t available yet so we have to do a SCSI bus rescan. You can run the following command to do a rescan:

echo "- – -">/sys/class/scsi_host/host0/scan

When you run the fdisk –l command after the rescan, you will see the new disk.

[root@nagios ~]# fdisk -l

Disk /dev/sda: 21.4 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          13      104391   83  Linux
/dev/sda2              14        2610    20860402+  8e  Linux LVM

Disk /dev/sdb: 10.7 GB, 10737418240 bytes
255 heads, 63 sectors/track, 1305 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Disk /dev/sdb doesn’t contain a valid partition table

The new disk doesn’t contain a valid parition table. This can be fixed with running the fdisk /dev/sdb command:

fdisk –l /dev/sdb n p 1 1 {enter} x b 1 128 w q

The options x b 1 128 will align the new parition.  For more info about, see Bob Plankers his post here: http://lonesysadmin.net/2010/03/30/i-will-keep-saying-it-align-your-partitions/

Now we have a valid parition table but no file system. Run the mkfs.ext3 /dev/sdb1 command to accomplish this task:

[root@nagios ~]# mkfs.ext3 /dev/sdb1
mke2fs 1.39 (29-May-2006)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
1310720 inodes, 2620595 blocks
131029 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=2684354560
80 block groups
32768 blocks per group, 32768 fragments per group
16384 inodes per group
Superblock backups stored on blocks:
        32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632

Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 39 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.

Run the fdisk –l command to verify the new configuration:

[root@nagios ~]# fdisk -l

Disk /dev/sda: 21.4 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          13      104391   83  Linux
/dev/sda2              14        2610    20860402+  8e  Linux LVM

Disk /dev/sdb: 10.7 GB, 10737418240 bytes
255 heads, 63 sectors/track, 1305 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1        1305    10482381   83  Linux

if you want to auto mount the new disk, you have to create a new folder and add an entry to the /etc/fstab file.

mkdir /disk2
nano or vi /etc/fstab

add the following line:
/dev/sdb1               /disk2                  ext2    defaults        1 2

Now you are ready to mount the new disk.

mount /dev/sdb1 /disk2/

These are all the steps.

Hot Remove a VMDK

If you want to remove an extra VMDK from a Linux VM,you need to follow these steps.

First you need to unmount the /dev/sdb1:

umount /dev/sdb1

Remove the /disk2 folder:

rmdir /disk2/

Remove the entry from the /etc/fstab:

nano or vi /etc/fstab

remove the following line:
/dev/sdb1               /disk2                  ext2    defaults        1 2

Delete the device:

echo 1 > /sys/block/sdb1/device/delete

Remove the VMDK:

image

VMware Tools: Uninstall failed. Please correct the failure


image

Today a ran into an issue with the VMware Tools installer on Linux:

image

The solution was simple this time. Just remove the locations file from from /etc/vmware-tools. You can do this by running the following command:

rm –f /etc/vmware-tools/locations

Now you are able to run the VMware Tool installer again. If you are installing the VMware Tools on it default locations, you can add the –default parameter to the ./vmware-install.pl command to install the VMware Tools on it’s default location.

Source: KB1013159

Update Linux VMs with PowerCLI thanks to Invoke-VMScript


image 
I created a new PowerCLI function to update the Linux Guest OS via PowerCLI. Be sure you use the check-vmware-tools script posted before: https://ict-freak.nl/2009/12/21/bash-script-auto-configure-vmware-tools-at-boot-time/

The function below will check if the VM is running Linux, if the VMware Tools are up to date and running, and last but not least it will determine the linux distribution so it will run the correct update command:

Function Update-LinuxVM{
 param($virtualmachine)
 $vm = Get-VM $virtualmachine
 $os = (Get-VM $vm | Get-View).Summary.Config.GuestFullName
 $toolsStatus = (Get-VM $vm | Get-View).Guest.ToolsStatus
 if($vm.powerstate -eq "PoweredOn"){
    if($toolsStatus -eq "toolsOk"){
        # Determining Linux Distro
        if($os -match 'Red Hat Enterprise Linux'){
            Write-Host "RedHat or CentOS installation found" -fore Yellow 
            $update = "yum clean all && yum update -y"
        }
        elseif($os -match 'Debian GNU'){
            Write-Host "Debian installation found" 
            $update = "apt-get update && apt-get upgrade -y"
        }    
        else{Write-Host "No update possible" -fore Red}
        
        # ifconfig
        if($ifconfig -ne ""){
        Write-Host "Configuring IP settings $ifconfig" -fore Yellow
        $vm | Invoke-VMScript -HostCredential $hc -GuestCredential $gc $ifconfig
        }

        # route
        if($route -ne ""){
        Write-Host "Setting default gateway route $route" -fore Yellow
        $vm | Invoke-VMScript -HostCredential $hc -GuestCredential $gc $route
        }
        
        # Update command
        Write-Host "Running $update command" -fore Yellow
        $vm | Invoke-VMScript -HostCredential $hc -GuestCredential $gc $update
        }
        else{Write-Host $vm "VMware Tools are out off date or not running" -fore Red }
    }
 else{Write-Host $vm "is not running" -fore Red }
}

You can use this function with the following parameters:

$hc = Get-Credential
$gc = Get-Credential
$ifconfig = ""
$route = ""

$hc will save the Host Credentials. These are the credentials you need to authenticate with the ESX Host

$gc will save the Guest Credentials. These are the credentials you need to authenticate with the Linux Guest OS.

$ifconfig can be used to set a temporary ip address. Example: ifconfig eth0 192.168.123.166 netmask 255.255.255.0

$route can be used to set a temporary gateway address: route add default gw 192.168.123.254

The following command will start the script:

Update-LinuxVM <vmname>

The Function in action:

image

Bash Script: Auto Configure vmware-tools at Boot time


This post is originally posted on my colleague Michel aka ‘HighKing’ blog: http://highking.nl/website/auto-config_vmware-tools

When you install a new kernel on a RHEL/CentOS VM, you need to reconfigure the vmware-tools using the ‘vmware-config-tools.pl’ script. I have created a simple script that does this automatically, so you don’t have to be there when the kernel is updated (handy for automatically updating machines).

Place this in a script called ‘check-vmware-tools’ in /etc/init.d:

#!/bin/bash
#
# check-vmware-tools
#
# chkconfig:   - 00 99
# description: Check whether or not the vmware-tools are installed at boot time.
# processname: check-vmware-tools
#

loadvmxnet() {
  if [ "`uname -i`" != "x86_64" ]; then 
        echo -n "Reloading vmxnet driver... "
        /sbin/rmmod pcnet32
        /sbin/rmmod vmxnet
        /sbin/depmod -a
        /sbin/modprobe vmxnet
        echo "done"
  fi
}

case $1 in
  start)
    echo -n $"Checking VMware-tools: "
   if [ ! -e /lib/modules/`/bin/uname -r`/misc/vmci.ko ]; then
      echo "Not available, running vmware-config-tools..."
      /usr/bin/vmware-config-tools.pl --default && loadvmxnet
   else
     echo "OK"
   fi
  ;;
  *)
    echo "Usage: $0 start"
    exit 1
  ;;
esac


Make it writeable with:

chmod +x /etc/init.d/check-vmware-tools


Next is to make it known by chkconfig with:

chkconfig --add check-vmware-tools


Now we have done that, we can simply enable it with:

chkconfig check-vmware-tools on

On the next boot, this script checks whether or not the vmware-tools are configured for the running kernel (by checking if vmmemctl.ko is in place). If not, it runs ‘vmware-config-tools.pl and reboots after that.

You can download the file here: check-vmware-tools

Source: http://highking.nl/website/auto-config_vmware-tools

How To: Install Webmin on Ubuntu 8.04


image

This post is an upgrade to an earlier post from September 2006.

Before you can install Webmin, you have to install some other packages first:

sudo apt-get install perl libnet-ssleay-perl openssl libauthen-pam-perl libpam-runtime libio-pty-perl libmd5-perl

Go to the /tmp dir

cd /tmp

Download the deb file via wget:

wget http://prdownloads.sourceforge.net/webadmin/webmin_1.450_all.deb

The final step:

sudo dpkg -i webmin_1.450_all.deb

/tmp$ sudo dpkg -i webmin_1.450_all.deb
Selecting previously deselected package webmin.
(Reading database … 38179 files and directories currently installed.)
Unpacking webmin (from webmin_1.450_all.deb) …
Setting up webmin (1.450) …
Webmin install complete. You can now login to https://server:10000/
as root with your root password, or as any user who can use sudo
to run commands as root.

Open your favorite browser and go to: https://server:10000/

image