[CentOS-virt] CentOS 5.1 guide for VMware Fusion

Bradley Sepos bradleysepos at gmail.com
Mon Feb 18 00:11:47 UTC 2008

Hello all,

I recently created a VM running CentOS 5.1 x86-64 for development
purposes. Along the way, I found a number of fixes to various issues
one can experience under VMware and decided to turn my documentation
into a general guide that others might benefit from. I have not found
any guides for VMware Fusion on OS X, so I figured it is a worthwhile
endeavor. It is likely that most or all of this guide applies to
VMware Workstation as well.

I welcome any additions or corrections. I am open to reposting on the wiki.

Look forward to your replies... Cheers.

(See the attached text document.)
-------------- next part --------------
Setup guide for CentOS 5.1 64-bit on VMware Fusion OS X
        author: Bradley Sepos <bradleysepos at gmail.com>
       created: 17 February 2007
      modified: 17 February 2007
centos version: CentOS 5.1 x86-64
vmware version: VMware Fusion 1.1.1

This guide assumes a configuration for development, not deployment. As such, 
use care when deploying any VM based on this guide. For one, you may wish to 
enable SELinux contrary to this guide's recommendation.

This article assumes you know a bit about what you're doing. For instance, 
it assumes you know how to insert characters (a), write files (:w), and quit 
vi (:q). Please do not e-mail the author with questions about such tasks. 
Google and IRC are your friends.

Lastly, if you do have a meaningful update to this guide, feel free to contact 
the author.

Initial setup (netinstall)

1) Download netinstall ISO from http://centos.org/

2) Create VM using Red Hat Enterprise Linux 5 64-bit target

   For 32-bit CentOS, use Red Hat Enterprise Linux 5 (sans 64-bit at the end)

3) Boot from netinstall ISO and begin install process

4) Disable SELinux

   SELinux as configured by CentOS 5.1 causes problems with VMware Tools. 
   Alternatively, this issue is fixed in a later SELinux policy update and you 
   may choose to enable SELinux and apply the update before installing VMware 
   Tools (not covered). See: http://rhn.redhat.com/errata/RHBA-2007-0544.html

5) Accept most defaults

   Choose any desired packages or categories, like "server" and "development"

6) When install completes, login to the graphical desktop as a normal user

7) Perform any software updates if prompted

   40 updates were available at the time of this writing.

Additional installations

Open terminal and log in as superuser (su -).

Use yum to install any additional packages you may need, for example:

	$ yum -y install subversion

You may also use the graphical package manager. From the main menu, select 
Applications > Add/Remove Software.

Installing VMware Tools

First, enable Shared Folders on the host, even if you do not intend to add 
any. Otherwise, the hgfs filesystem may fail to mount on boot with a warning.

Initiate the install process from the host, "Install VMware Tools"

Open a terminal and log in as superuser (su -).

Create a mount point for the VMware Tools virtual disc (if one does not 
exist), and mount it:

	$ mkdir /mnt/cdrom
	$ mount /dev/cdrom /mnt/cdrom

Extract the VMware Tools archive to /tmp:

	$ tar -C /tmp -zxvf /mnt/cdrom/[archive.tar.gz]

Substitute the actual filename for [archive.tar.gz] above, such as 

Unmount the disc:

	$ umount /dev/cdrom

Launch the installer and answer the interactive questions (NO to experimental):

	$ /tmp/vmware-tools-distrib/vmware-install.pl

The installer will prompt you to run the configuration script automatically at 
the end. Do this and choose a desired screen resolution.

Configure Xorg to include missing mouse driver

VMwareTools, as of this writing, does not properly configure Xorg to include 
the mouse driver, leading to artifacting around the cursor and other anomalies.

Open terminal and log in as superuser (su -).

Edit the Xorg configuration file:

	$ vi /etc/X11/xorg.conf

Update the server layout section to include two new input devices, "Configured 
Mouse" and "XOrgMouseWorkaround" as follows:

	Section "ServerLayout"
			Identifier     "Default Layout"
			Screen      0  "Screen0" 0 0
			InputDevice    "Keyboard0" "CoreKeyboard"
			InputDevice    "Configured Mouse"
			InputDevice    "XOrgMouseWorkaround"

Then create two input device sections at the end of the file:

	Section "InputDevice"
			Identifier "XOrgMouseWorkaround"
			Driver "void"
	Section "InputDevice"
			Identifier "Configured Mouse"
			Driver "vmmouse"
			Option "CorePointer"
			Option "Device" "/dev/input/mice"
			Option "Protool" "ps/2"
			Option "ZAxisMapping" "4 5"
			Option "Emulate3Buttons" "true"

If you are at the login for or are logged into a graphical desktop (such as 
Gnome or KDE), restart the X server now by typing Control-Alt-Backspace. 
Note: this will log you out of your graphical desktop session.



Configure the kernel interrupt frequency to avoid high cpu usage on the host

Because the kernel under CentOS 5.1 is compiled with HZ=1000, high cpu usage 
may result on the host as it tries to fulfill the guest's request for 
interrupt 1000 times per second. The following configuration instructs the 
kernel to keep this frequency when booting to avoid problems, and later switch 
to 100Hz to alleviate the cpu issue when running in a VM.

Open terminal and log in as superuser (su -).

Edit the grub configuration file:

	$ vi /boot/grub/grub.conf

The contents should look something like this:

	# grub.conf generated by anaconda
	title CentOS (2.6.18-53.1.13.el5)
			root (hd0,0)
			kernel /vmlinuz-2.6.18-53.1.13.el5 ro root=/dev/VolGroup00/LogVol00 rhgb quiet
			initrd /initrd-2.6.18-53.1.13.el5.img

Create a new "title" entry identical to and above the first. Give it a unique 
name, perhaps adding "100Hz" at the end. Now, append the following to the 
kernel line:

	divider=10 notsc

Then, add the following above the "title" entries:

	fallback 1

This instructs grub to use the second entry if the first one fails.

Your file should now look something like this:

	# grub.conf generated by anaconda
	fallback 1
	title CentOS (2.6.18-53.1.13.el5) 100Hz
			root (hd0,0)
			kernel /vmlinuz-2.6.18-53.1.13.el5 ro root=/dev/VolGroup00/LogVol00 rhgb quiet divider=10 notsc
			initrd /initrd-2.6.18-53.1.13.el5.img
	title CentOS (2.6.18-53.1.13.el5)
			root (hd0,0)
			kernel /vmlinuz-2.6.18-53.1.13.el5 ro root=/dev/VolGroup00/LogVol00 rhgb quiet
			initrd /initrd-2.6.18-53.1.13.el5.img

Note that this is only for 64-bit guests!
(Not tested, but 32-bit guests may instead use: divider=10 clock=pit)



Set up a guest user account with your host user's UID

In order to facilitate seamless file transfer to and from your shared folders, 
you will likely want to create a new normal user account on the guest with 
account and group UIDs matching the user account on the host.

First, create a shared folder in VMware on the host. We will call it 
CentOS-shared here.

Then on the guest, open a terminal and check the status of the new directory:

	$ cd /mnt/hgfs
	$ ls -ld CentOS-shared
	drwxrwxrwx 1 501 501 102 Feb 17 02:07 CentOS-shared

Note the owner and group UID: in this case, 501.

The next step is detailed using the Gnome graphical desktop.

Log into the graphical desktop as a normal user, or root if not available. 
From the top menu, choose System > Administration > Users and Groups. Normal 
users will need to authenticate at this point.

In the User Manager, choose File > Add User. Give this user whatever 
names and credentials suit you. Make sure "Create home directory" and "Create 
a private group for the user" are checked.

Check the box labeled "Specify user ID manually" and type the UID we gathered 
previously (501) in the associated input. Select OK to create the user and 
group now. You should now see your user and group in the lists, with the 
proper, matching UIDs.

Logout. Now, login using the username and password for the new account we just 
created. Files and folders transfered using the shared folder we created 
(CentOS-shared) will have matching user and group UIDs, bidirectionally 
between the two systems.

To create a symbolic link (shortcut) to the shared folder on the new user's 
desktop, make sure to login at least once to the graphical desktop to ensure 
that the Desktop directory is created. Then, open a terminal and run the 
following as the same user:

	$ cd ~/Desktop
	$ ln -s /mnt/hgfs/CentOS-shared

An icon pointing to the shared folder should appear on the desktop. Repeat as 
necessary for each shared folder.

Configure services to initialize on boot

You may want certain services to automatically start with the system. 
Runlevels 3 and up make a service active when booted to the console, even if 
you do not boot to a graphical desktop. Use only runlevel 5 to init at the 
graphical desktop only.

Open a terminal and log in as superuser (su -).

To configure the system to automatically start the Apache (httpd) service:

	$ chkconfig --levels 345 httpd on

Substitute other services for httpd, such as mysqld for MySQL and postgresql 
for PostgreSQL.

You may also change this configuration from the graphical desktop. From the 
Gnome main menu, select System > Administration > Server Settings > Services.

More information about the CentOS-virt mailing list