Updated: 2014-11-20 11:59 EST
root
permissionsfuse-libs
packagelinux.iso
/mnt/cdrom
vmware-install.pl
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.
root
permissionsIndexIf necessary, start your CentOS machine in VMware.
root
user:
root
account (a new install), just log in directly as the root
user.root
account, log in using that account and then use su
or sudo
to run commands as root
.For all system administration work, I recommend using an SSH connection to your CentOS machine rather than trying to work directly on the VMware console.
fuse-libs
packageIndexFirst, 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
fuse-libs-2.8.3-4.el6.i686
linux.iso
IndexWe will use VMware to connect the VMware Tools ISO file to our virtual CD/DVD device:
In your host O/S that is running VMware select the VMware menu item VM | Install VMware Tools.
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.
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.
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.)
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
.
Close the VM | Settings box.
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 Nov 2 09:42 /dev/cdrom -> sr0
lrwxrwxrwx 1 root root 3 Nov 2 09:42 /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 Nov 2 09:42 cdrom -> sr0
lrwxrwxrwx 1 root root 3 Nov 2 09:42 cdrw -> sr0
lrwxrwxrwx 1 root root 3 Nov 2 09:42 dvd -> sr0
lrwxrwxrwx 1 root root 3 Nov 2 09:42 dvdrw -> sr0
lrwxrwxrwx 1 root root 3 Nov 2 09:42 scd0 -> sr0
brw-rw---- 1 root cdrom 11, 0 Nov 2 09:42 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
(Look up 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: 63 MB, 63019008 bytes # the size may vary slightly
/mnt/cdrom
IndexWhen 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 | fgrep '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 59M Mar 21 2014 VMwareTools-9.6.2-1688356.tar.gz
-r-xr-xr-x 1 root root 2.0K Mar 21 2014 manifest.txt
-r--r--r-- 1 root root 1.9K Mar 21 2014 run_upgrader.sh
-r-xr-xr-x 1 root root 674K Mar 21 2014 vmware-tools-upgrader-32
-r-xr-xr-x 1 root root 687K Mar 21 2014 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 59MB
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.)
The next instruction in your saved screen capture says: Uncompress the installer and then execute vmware-install.pl
to install VMware Tools. Confirm that we have the installer ISO image available on the CDROM:
# ls -l /mnt/cdrom/VMware*gz
-r--r--r-- 1 root root 61260572 Mar 21 2014 /mnt/cdrom/VMwareTools-9.6.2-1688356.tar.gz
We will extract the installer into the system /tmp
temporary directory. 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 (available) 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 658M 713M 48% / # have lots of space!
Make the /tmp
directory the current directory for the extraction and then extract the installer from the tar
archive. Make sure you are using the /tmp
directory and not some other HOME directory.
# cd /tmp ; pwd
/tmp
# tar zxf /mnt/cdrom/VMware*gz # this extracts thousands of files
# pwd ; ls -ld vmware-tools-distrib
/tmp
drwxr-xr-x 7 root root 4096 Mar 21 2014 vmware-tools-distrib
# ls -l vmware-tools-distrib
total 472
-rw-r--r-- 1 root root 260079 Mar 21 2014 FILES
-rw-r--r-- 1 root root 2538 Mar 21 2014 INSTALL
drwxr-xr-x 2 root root 4096 Mar 21 2014 bin
drwxr-xr-x 2 root root 4096 Mar 21 2014 doc
drwxr-xr-x 5 root root 4096 Mar 21 2014 etc
drwxr-xr-x 2 root root 4096 Mar 21 2014 installer
drwxr-xr-x 15 root root 4096 Mar 21 2014 lib
-rwxr-xr-x 1 root root 192871 Mar 21 2014 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.
vmware-install.pl
IndexExecute the installer program vmware-install.pl
from inside its installation directory by typing its pathname:
# pwd
/tmp
# vmware-tools-distrib/vmware-install.pl
At this point, you should see one of three things, A or B or C:
A: Creating a new VMware Tools installer database using the tar4 format.
B: A previous installation of VMware Tools has been detected.
C: bash: vmware-tools-distrib/vmware-install.pl: /usr/bin/perl: bad interpreter: No such file or directory
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 and read how to answer the installer questions.
If a previous version has been installed, you need to let the installer first uninstall the old version then install the new one. Say yes
(just hit Enter) to uninstall, then skip forward to the next section and read how to answer the installer questions.
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:
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-tools-distrib/vmware-install.pl # 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 | fgrep '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 | fgrep 'perl' # now it finds perl packages
perl-Module-Pluggable-3.90-136.el6.i686
perl-libs-5.10.1-136.el6.i686
perl-5.10.1-136.el6.i686
perl-Pod-Escapes-1.04-136.el6.i686
perl-version-0.77-136.el6.i686
perl-Pod-Simple-3.13-136.el6.i68
The exact version numbers of the packages may differ slightly.
To run the installer file, we need both Perl and the fuse-libs
packages (installed in previous sections). If you don’t know if they are installed, you can verify it:
# rpm -q perl
perl-5.10.1-136.el6.i686
# rpm -q fuse-libs
fuse-libs-2.8.3-4.el6.i686
The exact version numbers of the packages may differ slightly.
To run the installer file, we need both Perl and the fuse-libs
packages (installed in previous sections). If you don’t know if they are installed, check the previous section, above.
Now that we have Perl and fuse-libs
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:
# pwd
/tmp
# vmware-tools-distrib/vmware-install.pl
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?
[/usr/bin]
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.2 build-1688356 for Linux
completed successfully. You can decide to remove this software
from your system at any time by invoking the following command:
"/usr/bin/vmware-uninstall-tools.pl".
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.
The df
and mount
commands show what is mounted, so we will use them below to verify that we have successfully unmounted the CD device sr0
. Use the umount
command (and note the spelling) to do the actual unmounting:
# df
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/sda1 1479088 1042696 359592 75% /
tmpfs 124400 0 124400 0% /dev/shm
/dev/sr0 60934 60934 0 100% /mnt/cdrom
# mount | fgrep 'sr0'
/dev/sr0 on /mnt/cdrom type iso9660 (ro)
# umount /mnt/cdrom # note the spelling!
# df
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/sda1 1479088 1042696 359592 75% /
tmpfs 124400 0 124400 0% /dev/shm
# mount | fgrep '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:
If you get a VMware error saying that the device is still in use, then you forgot to use the umount
command, above, to unmount the CD. Go back and unmount the device, then disconnect in in VMware.
Now that VMware Tools has been installed, let’s verify that it is working.
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 12345 # use process number printed by pgrep
12345 ? Sl 0:00 /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
, above.)
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.
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 198.50.239.57, stratum 2, offset 0.000084, delay 0.04436
server 142.137.247.109, stratum 2, offset -0.005645, delay 0.04707
server 208.80.96.96, stratum 3, offset -0.000439, delay 0.04239
server 216.234.161.11, stratum 2, offset -0.006661, delay 0.09264
29 Oct 13:12:59 ntpdate[13651]: adjust time server 198.50.239.57 offset 0.000084 sec
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.
Work-Around: This doesn’t always work. 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.
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 | fgrep 'offset'
29 Oct 13:13:59 ntpdate[13661]: adjust time server 198.50.239.57 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. Try the work-around in the Work-Around paragraph above, if that helps.
vmware-tools-distrib
directory from /tmp
This completes the installation and testing of VMware Tools.