Here is how I create Red Hat Enterprise Linux 6 VM to use as templates in VMware vSphere.

  1. Update the OS and install vmware tools
    # yum update
    
  2. Clean the yum cache
    # yum clean all
    
  3. Remove SSH host keys
    # rm -f /etc/ssh/ssh_host_*
    
  4. Remove MAC and UUID’s from network configuration files.
    # sed -i ‘/^(HWADDR|UUID)=/d’ /etc/sysconfig/network-scripts/ifcfg-eth*
    
  5. Remove persistent device rules
    # rm -f /etc/udev/rules.d/70-persistent-*
    
  6. Force the log rotate and clean the log files
    # logrotate –f /etc/logrotate.conf
    # rm –f /var/log/*-???????? /var/log/*.gz
    # cat /dev/null > /var/log/audit/audit.log
    # cat /dev/null > /var/log/wtmp
    # cat /dev/null > /var/log/messages
    
  7. Clean the /tmp
    # rm -rf /tmp/*
    # rm -rf /var/tmp/*
    
  8. un-configured the system if you’r not using customization specification
    # touch /.unconfigured
    
  9. Remove the shell history
    # rm -f ~/.bash_history
    # unset HISTFILE
    
  10. Finally poweroff the system.
    # poweroff