Here at VG a large amount of our services are deployed on virtualized servers in our VMware cluster. A majority of these servers are running CentOS, but from time to time there is a need for other distributions, like Ubuntu.
In this short write up we will go through a couple of things we find necessary to do to bring Ubuntu up to speed in a VMware environment.
First of all, you want some version of VMware Tools installed. Either the proprietary package from VMware, or open-vm-tools from Ubuntu’s repositories.
One of the things that doesn’t work out of the box when running Ubuntu in VMware is hot adding of CPUs and memory. The new hardware will be visible to the system, but not activated automatically. Even with VMware-tools installed on the virtual machine. In CentOS 6 this works out of the box, without any modifications to the system.
This can be solved by making sure the acpi_memhotplug module is loaded, and by adding two rules to udev:
$ echo acpi_memhotplug | sudo tee /etc/modules $ cat << EOF | sudo tee /etc/udev/rules.d/99-vmware-hotplug-udev.rules # Automatically enable hot-plugged CPUs and memory ACTION=="add", SUBSYSTEM=="cpu", ATTR{online}="1" ACTION=="add", SUBSYSTEM=="memory", ATTR{state}="online" EOF
And of course, if you are preparing a template you would want to clean up the SSH keys. This is necessary to avoid reusing the same host keys in every machine you deploy. Reusing host keys is a fairly common mistake, and has also been seen done from commercial VPS providers.
We issue the following commands as one of the last things before shutting down the VM before generating the template:
$ sudo rm /etc/ssh/ssh_host* $ sudo cp /etc/rc.local /etc/rc.local.orig $ sudo sed -i '$ i dpkg-reconfigure openssh-server\nmv /etc/rc.local.orig /etc/rc.local' /etc/rc.local
This will make sure that new keys are generated on the first boot after deploying your new template.