VM Template Setup Fedora

From ConShell
Revision as of 12:29, 4 March 2008 by Fostermarkd (talk | contribs)
Jump to navigation Jump to search

Introduction

This page describes what I do to setup a "gold master" template of Linux virtual machine (VM) running on VMware Server. The example is based on Fedora 7 but is mostly applicable to other Linux distributions.

Procedure

Install operating system. Use a 8-12GB disk (do not preallocate)

Use an LSI Logic SCSI controller unless otherwise indicated.

Assign 800MB RAM or whatever you can afford. Since this will affect the size of the swap partition, so you may want to adjust that upwards for future clones.

I typically use a "boot" ISO which means just enough to get the box on the network and finish the package installation using HTTP/FTP or whatever.

Next, reboot and update all the software.

Use either yum update or on debian/ubuntu: aptitude update; aptitude upgrade

Install some other bits

yum install sudo sysstat gcc gcc-c++ kernel-devel

Adjust grub timeout (in /etc/grub.conf or /boot/grub/menu.lst) to 12s

Adjust kernel options...

  • add clock=pit or clocksource=acpi_pm divider=10
  • add noacpi

Now reboot especially if a newer kernel was installed above.

We're going to load the vmware-tools now. To do this needs a virtual CDROM Right-click on the VM and choose "Install VMware Tools" from the menu

On fedora, CDROM appears under /misc/cd but only with autofs running

/etc/init.d/autofs start
ls /misc/cd
rpm -ivh /misc/cd/VMwareTools-1.0.4-56528.i386.rpm
vmware-config-tools.pl

This should result in vmxnet and other drivers being compiled and/or loaded. Reboot and verify vmxnet is loaded (and not pcnet32)

lsmod | egrep 'vmxnet|pcnet32'

Disable unnecessary services Fedora

for s in atd auditd avahi-daemon bluetooth cpuspeed cups firstboot gpm hplip ip6tables iptables isdn kudzu mcstrans pcscd sendmail setroubleshoot smartd xfs yum-updatesd; do
/sbin/chkconfig ${s} off
/etc/init.d/${s} stop
done

Optional stuff

Remove sendmail, install postfix

rpm -e --nodeps sendmail
yum install postfix

Disable selinux

vim /etc/selinux/config
( set SELINUX=disabled )

Remove older kernels

rpm -e kernel-2.6.21-1.3194.fc7

Final Steps: cleanup & storage

rm -f /etc/ssh/*host*
rm -f /var/lib/dhcp*/*leases*
yum clean all
/sbin/shutdown -h now


Right-click the VM template name and choose Remove from Inventory

Then I tar up the VM into a compressed tarball for future cloning.

cd /opt/vm/
mkdir -p templates
cd vmname
tar cjvf ../templates/vmname.tbz2 *vmx *vmdk
cd ..
rm -rf vmname
chmod a-w templates/vmname.tbz2

Resuscitation

It can be cloned/deployed like so

cd /opt/vm
mkdir newvm
cd newvm
tar xjvf ../templates/vmname.tbz2

Then use vmware-server-console application to "Open" the corresponding vmx file.

Notes

Removing/disabling the boot-time software above saves 50MB off the memory footprint (180MB -> 130MB) on Fedora.