VM Template Setup Ubuntu

From ConShell
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 Ubuntu 7.10 Server but is mostly applicable to other Ubuntu versions.

Procedure

Create a new VM called ubuntu of

  • Type Ubuntu
  • Use a 8-12GB disk (do not preallocate or split)
  • Use an LSI Logic SCSI controller
  • 1024MB RAM(1)

(1) Since this will affect the size of the swap partition, so you may want to adjust that upwards for future clones.

Install operating system.

Next, reboot, login and update all the software.

sudo -s 
aptitude update
aptitude safe-upgrade

Install some other bits

aptitude install openssh-server build-essential linux-headers-server

(Optional) Add any base users you want to exist in future clones. I use Justin Case (justincase) but this could just be a real person too.

adduser justincase
password justincase

Now, add the user(s) to the admin group in /etc/group and adjust this line in /etc/sudoers

%admin ALL=(ALL) NOPASSWD:ALL

Adjust grub (in boot/grub/menu.lst)

  • set timeout to 12
  • comment out hiddenmenu
  • Adjust kernel options...
    • add clocksource=acpi_pm
    • add noacpi

Edit /etc/apt/sources.list

  • Comment out the deb cdrom... line

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 ubuntu, CDROM appears under /media/cdrom0

mount /media/cdrom0
cd /tmp
tar xvf /media/cdrom0/VMwareTools-1.0.4-56528.tar.gz
cd vmware-tools-distrib/
./vmware-install.pl
umount /media/cdrom0

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

Thank you Ubuntu, there don't appear to be any :)

Final Steps: cleanup & storage

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

See VM Template Setup Fedora for explanation of storage and resuscitation.

Notes

Initial memory footprint about 40M on Ubuntu.

Compressing the template reduces disk usage from 1.5G to 531M on Ubuntu.

Ubuntu makes for a much smaller and more efficient out-of-the-box system.

It may be necessary to add this line to /etc/modprobe.d/blacklist

blacklist pcnet32