Optimizing CentOS as a virtual machine

Removing packages

The following line removes a packages that virtual machines don't need (which are done by the host machine instead):

 # rpm -e --allmatches wpa_supplicant bluez-utils \
   irqbalance autofs cpuspeed irda-utils conman mdadm psacct \

Because of dependencies, we can't remove some stuff but we can at least turn them off:

 # chkconfig netplugd off
 # chkconfig gpm off

If you don't use NFS or NIS, the following packages can also be removed:

 # rpm -e --allmatches nfs-utils portmap ypbind yp-tools \
   NetworkManager nscd nss_ldap

If your machine runs 24/7:

  # rpm -e anacron

If your machine is not a multi-user system:

 # rpm -e psacct

Now turning off some things that don't make sense on an apache box:

 # chkconfig mcstrans off
 # chkconfig messagebus off
 # chkconfig oddjobd off

You can shave off an extra two to four megs of memory by turning off the auditd daemon:

 # chkconfig auditd off

Edit /etc/inittab and remove all virtual console entries (each of which have mgetty running). These don't use much, since mgetty is so small, however, they're not used so they can be safely removed.

Disk performance

Under some loads, the mountoption noatime (and nodiratime) can speed up disk access considerably. First edit /etc/fstab so the mounted partitions look as follows:

  LABEL=/    /        ext3   defaults,noatime,nodiratime     1 1

Note that this example uses logical volumes (with labels) instead of partitions. If that's not used then instead of LABEL=/, you'll see a partition such as /dev/sda2.

To make this change effective immediately, remount the partitions wih the new options:

  # mount -o remount,noatime,nodiratime LABEL=/ /

Or, if you're using partitions:

  # mount -o remount,noatime,nodiratime /dev/sda2 /

Memory requirements

Now that we've turned lots of stuff off, see what this machine uses for memory:

 # free -m