Updated: 2014-03-20 09:47 EDT

1 VMware ToolsIndexup to index

The VMware Tools software can be installed in your CentOS virtual machine to give improved performance and better time synchronization.

Without the VMware Tools, a suspended and resumed virtual machine resumes with its system date and time set incorrectly to the date and time it was suspended. It can take five or ten minutes for the Linux NTP daemon to reset the system clock to the correct date and time.

With VMware Tools installed, a vmtoolsd daemon is started that re-synchronizes the system clock when the virtual machine is resumed.

Note: This suspend/resume time synchronization does not appear to work for a host O/S of Windows 8 running VMware Workstation version 9. If you can figure out why, let us know.

2 Install in CentOS as rootIndexup to index

Boot your CentOS machine.

Become the root user. (Log in as root or use su or sudo from a non-root account, if you have one.)

For all system administration work, I recommend using an SSH connection rather than trying to work directly on the VMware console.

3 Install the fuse-libs packageIndexup to index

First, to allow VMware Tools to run its vmtoolsd daemon process, we need some software libraries. (Thanks to Todd Kelley who researched this.) If it isn’t already installed, install the fuse-libs library package:

# rpm -q fuse-libs
package fuse-libs is not installed

# yum -q list fuse-libs
Available Packages
fuse-libs.i686               2.8.3-4.el6         @base

# yum install fuse-libs
[...many lines print here; say Y to install...]

# yum -q list fuse-libs
Installed Packages
fuse-libs.i686               2.8.3-4.el6         @base

# rpm -q fuse-libs

4 Connect the VMware Tools linux.isoIndexup to index

We will use VMware to connect the VMware Tools ISO file to our virtual CD/DVD device:

  1. In your host machine running VMware application select menu item VM | Install VMware Tools.

  2. VMware will sometimes (not always) put up a Question box saying Click Install to connect the VMware Tools Installer CD to the virtual machine. Sometimes there is no Question box and some information appears in a small box on the bottom of your VMware window. Take a screen capture of what it says (or write it down) so you can follow the directions.

  3. If there is a Question box, click Install. If, instead, there is a box at the bottom of your screen talking about the Tools, close it.

  4. VMware will automatically find and connect a VMware Tools linux.iso file to your virtual CD/DVD device. (This ISO file is part of VMware. It is not the same as the CentOS ISO file you downloaded to install CentOS.)

  5. Verify that VMware has connected the linux.iso file to your CD/DVD: Open the VM | Settings | Hardware tab for your CentOS VM and select the CD/DVD device. Confirm that the Device Status is Connected and Use ISO image: is selected and the selected ISO image file has a basename of linux.iso.

  6. Close the VM | Settings box.

4.1 Verify that the ISO file is connectedIndexup to index

The first instruction in your saved screen capture said: Mount the virtual CD drive in the guest.

Let’s find out the name of our CD device in the CentOS VM. The name probably starts with the letters cd, so let’s look for it in /dev:

# ls -l /dev/cd*
lrwxrwxrwx 1 root root 3 Mar 10 02:44 /dev/cdrom -> sr0
lrwxrwxrwx 1 root root 3 Mar 10 02:44 /dev/cdrw -> sr0

The symbolic link output from ls above shows that the CD/DVD drive is actually named /dev/sr0 with symbolic links pointing there from both /dev/cdrom and /dev/cdrw. Are there other names for this device?

# ls -l /dev/ | fgrep 'sr0'
lrwxrwxrwx 1 root root           3 Mar 10 02:44 cdrom -> sr0
lrwxrwxrwx 1 root root           3 Mar 10 02:44 cdrw -> sr0
lrwxrwxrwx 1 root root           3 Mar 10 02:44 dvd -> sr0
lrwxrwxrwx 1 root root           3 Mar 10 02:44 dvdrw -> sr0
lrwxrwxrwx 1 root root           3 Mar 10 02:44 scd0 -> sr0
brw-rw---- 1 root cdrom    11,   0 Mar 10 02:44 sr0

The above ls output shows that there is a /dev/sr0 device available. Let’s make sure there is an actual CD (VMware Tools ISO image) connected to that device. Run the file command and you should see this:

# file -s /dev/sr0
/dev/sr0: ISO 9660 CD-ROM filesystem data 'VMware Tools                   '

If you don’t see the VMware Tools connected to the /dev/sr0 device, go back and try again, making sure the linux.iso file is attached and connected to your CD/DVD device in VMware. If you see this error no read permission below, the ISO file is not yet connected and you must try again:

# file -s /dev/sr0
/dev/sr0: writable, no read permission     # THIS IS WRONG - TRY AGAIN

(What is the purpose of the -s option to the file command? [RTFM])

Another way to verify the presence and size of a valid CD in the device is using the fdisk command:

# fdisk -l /dev/sr0 | fgrep '/dev/'
Disk /dev/sr0: 62 MB, 62396416 bytes       # the size may vary slightly

5 Mount the ISO file on /mnt/cdromIndexup to index

When the file command verifies that the VMware Tools ISO is connected to the virtual CD/DVD device /dev/sr0, follow the directions below to create an empty directory mount point under /mnt and mount the read-only VMware Tools ISO image on that empty directory:

# file -s /dev/sr0
/dev/sr0: ISO 9660 CD-ROM filesystem data 'VMware Tools                   '

# mkdir -p /mnt/cdrom              # create /mnt/cdrom not /dev/cdrom
# ls -lh /mnt/cdrom                # what is in the new directory (nothing)
total 0

# mount /dev/sr0 /mnt/cdrom        # mount the CD device onto the directory
mount: block device /dev/sr0 is write-protected, mounting read-only

# mount | grep /dev/sr0            # confirm that the mount worked
/dev/sr0 on /mnt/cdrom type iso9660 (ro)

# ls -lh /mnt/cdrom                # see what's in the directory now (lots)
total 60M
-r--r--r-- 1 root root  58M Oct 17 21:26 VMwareTools-9.6.1-1378637.tar.gz
-r-xr-xr-x 1 root root 2.0K Oct 17 21:26 manifest.txt
-r--r--r-- 1 root root 1.9K Oct 17 21:25 run_upgrader.sh
-r-xr-xr-x 1 root root 674K Oct 17 21:25 vmware-tools-upgrader-32
-r-xr-xr-x 1 root root 687K Oct 17 21:25 vmware-tools-upgrader-64

Your sizes and version numbers above may differ, depending on the version of VMware you are running. Above, we see the 58MB compressed installer tar archive file (sometimes called a tarball) located under /mnt/cdrom, which is where the virtual CD is currently mounted. (The exact content and size of the VMware Tools directory will differ, depending on which version of VMware you run.)

6 Extract the VMware Tools installerIndexup to index

The next instruction in your saved screen capture says: Uncompress the installer and then execute vmware-install.pl to install VMware Tools.

Let’s make sure we have space in the /tmp directory to uncompress the installer (we need about 200MB available), then uncompress the tar archive into /tmp directory:

Use the df command to make sure you have at least 200M free in the partition containing /tmp (exact Used/Avail sizes may vary):

# df -h /tmp
Filesystem            Size  Used Avail Use% Mounted on
/dev/sda1             1.5G  686M  717M  49% /

# cd /tmp
# pwd

# tar zxf /mnt/cdrom/VMware*gz

# ls -ld vmware*
drwxr-xr-x 7 root root 4096 Oct 17 21:26 vmware-tools-distrib

# ls -l vmware*
total 472
drwxr-xr-x  2 root root   4096 Oct 17 21:26 bin
drwxr-xr-x  2 root root   4096 Oct 17 21:26 doc
drwxr-xr-x  5 root root   4096 Oct 17 21:26 etc
-rw-r--r--  1 root root 258515 Oct 17 21:26 FILES
-rw-r--r--  1 root root   2538 Oct 17 21:26 INSTALL
drwxr-xr-x  2 root root   4096 Oct 17 21:26 installer
drwxr-xr-x 15 root root   4096 Oct 17 21:26 lib
-rwxr-xr-x  1 root root 192871 Oct 17 21:26 vmware-install.pl

(The exact content and size of the VMware Tools directory will differ, depending on which version of VMware you run.)

We see the installer program vmware-install.pl is an executable file under the new directory vmware-tools-distrib. The screen capture we took earlier says we must execute this program.

7 Execute the installer file vmware-install.plIndexup to index

Execute the installer file vmware-install.pl from inside its directory by typing its pathname, with a little GLOB help from the shell because we are lazy:

# echo vmware*/vmware*               # verify GLOB patterns before use

# vmware*/vmware*                    # shell GLOB patterns will expand

At this point, you might see one of two things, A or B:

A: Creating a new VMware Tools installer database using the tar4 format.
B: bash: vmware-tools-distrib/vmware-install.pl: /usr/bin/perl: bad interpreter: No such file or directory

A. If you see the output Creating a new VMware Tools installer database, then you already have Perl installed and should skip forward to the next section.

B. If you see an error message about the missing interpreter /usr/bin/perl, then you need to install the Perl package following the next instructions:

7.1 Install the Perl package (if not installed)Indexup to index

If the VMware Tools vmware-install.pl gives a bad interpreter error message when you run it, you need to install Perl package if it isn’t already installed:

# rpm -q perl
package perl is not installed

This VMware Tools installer file vmware-install.pl is a Perl script file that specifies the name of the Perl script interpreter as a comment in the first line of the file. Let’s use head to look at just the first two lines of the script file (which happen to be comment lines that start with # characters):

# head -n 2 vmware*/vmware*      # you type this; the next two lines are the output
#!/usr/bin/perl -w
# If your copy of perl is not in /usr/bin, please adjust the line above.

The first line of output above shows that script wants to run the program /usr/bin/perl. We can confirm that we don’t have this file installed, and the Perl program is only an Available Package:

# ls -l /usr/bin/perl
ls: cannot access /usr/bin/perl: No such file or directory

# yum -q list perl
Available Packages
perl.i686              4:5.10.1-131.el6_4        @updates

# rpm -q -a | grep 'perl'            # doesn't find anything

Our minimal CentOS installation doesn’t have the Perl program installed, so the VMware Tools installer script won’t execute. Let’s install the Perl package:

# yum install perl
[...many lines print here; say Y to install...]

# yum -q list perl
Installed Packages
perl.i686              4:5.10.1-131.el6_4        @updates

# ls -l /usr/bin/perl
-rwxr-xr-x 2 root root 5012 Apr 30 08:11 /usr/bin/perl

# rpm -q -a | grep 'perl'            # now it finds perl packages

7.2 Execute the installer file (needs Perl installed)Indexup to index

Now that we have Perl installed, we can resume following our screen capture directions and try executing the VMware Tools install script again. This time it works and starts asking us installation questions:

# rpm -q fuse-libs                   # make sure fulse-libs is installed

# vmware*/vmware*                    # shell GLOB patterns will expand
Creating a new VMware Tools installer database using the tar4 format.
Installing VMware Tools.
In which directory do you want to install the binary files?

The installer will ask you many questions, offering suggested default answers that will be used if you just push Enter. Accept the default answers (push Enter) for all the questions. Do not type anything except Enter after each question. At some point it will say (the exact version number may differ):

The installation of VMware Tools 9.6.1 build-1378637 for Linux
completed successfully. You can decide to remove this software
from your system at any time by invoking the following command:

Before running VMware Tools for the first time, you
need to configure it by invoking the following command:
"/usr/bin/vmware-config-tools.pl". Do you want this program to invoke
the command for you now? [yes]

Again, push Enter to accept yes and start the configuration process. Some of the steps will take a few minutes to finish; be patient.

Again, in the configuration process, do not type anything in response to any of the questions; just push Enter in response to every prompt. The configuration will end with this message, and you will get your bash shell prompt back:

Found VMware Tools CDROM mounted at /mnt/cdrom. Ejecting device /dev/sr0 ...
No eject (or equivilant) command could be located.
Eject Failed:  If possible manually eject the Tools installer from the guest
cdrom mounted at /mnt/cdrom before canceling tools install on the host.

Our minimal CentOS install does not have an eject command. We will unmount and eject the CD ISO image manually.

8 Unmount and Disconnect the VMware Tools ISO from the CD/DVD deviceIndexup to index

The df and mount commands show what is mounted, so we will use them below to verify that we have successfully unmounted the CD. Use the umount command (and note the spelling) to do the actual unmounting:

# df
Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/sda1              1511856   1023656    411400  72% /
tmpfs                   515340         0    515340   0% /dev/shm
/dev/sr0                 60934     60934         0 100% /mnt/cdrom

# mount | grep /dev/sr0
/dev/sr0 on /mnt/cdrom type iso9660 (ro)

# umount /mnt/cdrom

# df
Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/sda1              1511856   1023660    411396  72% /
tmpfs                   515340         0    515340   0% /dev/shm

# mount | grep /dev/sr0                  # should not be found

The df and mount commands must confirm that /dev/sr0 is no longer mounted. The other numbers and sizes may be different from what is listed above; all that matters is that you confirm that /dev/sr0 is no longer mounted before you disconnect it from your CD/DVD device.

After you have unmounted the ISO file, go to your VMware VM | Settings | CD/DVD and make sure of these things:

  1. Un-check Connected so that the CD is not connected now.
  2. Un-check Connect at power on so that the CD is not connected on boot.
  3. Switch the CD/DVD Connection back to Use a physical drive.
  4. Select Save or OK.

VMware Tools has been installed. Let’s verify that it is working.

9 Verify the VMware Tools installationIndexup to index

  1. Confirm that the VMware Tools daemon is running: Use the pgrep command to find the running vmtoolsd program (process) and print its process number, then use the ps command with that printed process number to show more information about that process number (your process number may be different – use your own process number):

    # pgrep -l vmtoolsd
    12345 vmtoolsd                    # your process number 12345 will differ
    # ps uww 12345                    # use process number printed by pgrep
    root  12345  0.1  0.3  38616  3972 ?   Sl   11:47  0:01 /usr/sbin/vmtoolsd

    If you do not see vmtoolsd running, your installation of VMware Tools did not work. Restore your virtual machine from your last snapshot and try the installation again. It is the vmtoolsd program that makes better time updating possible. (Make sure you installed fuse-libs.)

  2. Confirm that the system time in your VM is accurate and is restored across a VM suspend and resume: First, locate the name of an NTP time server from inside the NTP configuration file (note the use of a regular expression ^ character in the search string for grep):

    # grep '^server' /etc/ntp.conf
    server 0.centos.pool.ntp.org iburst
    server 1.centos.pool.ntp.org iburst
    server 2.centos.pool.ntp.org iburst
    server 3.centos.pool.ntp.org iburst

    The ^ regular expression character tells grep that it must match the server word only at the beginning of a line. We will cover regular expressions in CST8177.

  3. Use one of the above time server names as an argument to the ntpdate command to query the current time and compare it with your system time:

    # ntpdate -q 0.centos.pool.ntp.org
    server, stratum 2, offset 0.000084, delay 0.04436
    server, stratum 2, offset -0.005645, delay 0.04707
    server, stratum 3, offset -0.000439, delay 0.04239
    server, stratum 2, offset -0.006661, delay 0.09264
    29 Oct 13:12:59 ntpdate[13651]: adjust time server offset 0.000084 sec
  4. Look at the offset value in the last line of ntpdate output containing the phrase adjust time server. The offset should be less than one second.

    NOTE: This doesn’t always work. It’s not working for VMware Workstation 10.0.1 under Ubuntu 12.04.4. A work-around is to go to VM | Settings | Options | VMware Tools and turn on “Synchronize guest time with host”. That pops the time back to the corret value every 60 seconds or so, but it can drift by several seconds before that happens.

  5. In your host O/S go to VMware and suspend your CentOS guest VM for a minute or more and then resume it again. Re-run the above ntpdate command line again and verify that the time offset after the suspend/resume is still less than one second:

    # ntpdate -q 0.centos.pool.ntp.org | grep offset
    29 Oct 13:13:59 ntpdate[13661]: adjust time server offset 0.006617 sec

Note: This suspend/resume time synchronization does not appear to work for a host O/S of Windows 8 running VMware Workstation version 9. If you can figure out why, let us know. Windows 8.1 is rumoured to work. Use the work-around in the NOTE above, if that helps.

| Ian! D. Allen  -  idallen@idallen.ca  -  Ottawa, Ontario, Canada
| Home Page: http://idallen.com/   Contact Improv: http://contactimprov.ca/
| College professor (Free/Libre GNU+Linux) at: http://teaching.idallen.com/
| Defend digital freedom:  http://eff.org/  and have fun:  http://fools.ca/

Plain Text - plain text version of this page in Pandoc Markdown format

Campaign for non-browser-specific HTML   Valid XHTML 1.0 Transitional   Valid CSS!   Creative Commons by nc sa 3.0   Hacker Ideals Emblem   Author Ian! D. Allen