VGTech is a blog where the developers and devops of Norways most visited website share code and tricks of the trade… Read more



Are you brilliant? We're hiring. Read more

How to make Ubuntu play nice with VMware

DevOps

ubuntuvmware

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:

Show code
$ echo acpi_memhotplug | sudo tee -a /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:

Show code
$ 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.

Systems administrator


5 comments

  • Bjarne Øverli

    Greate article. Keep 'em coming!


  • Serge van Ginderachter

    Nice tip about the hotplugging.

    You might want to add the -a option to tee:

    echo acpi_memhotplug | sudo tee -a /etc/modules

    to *add* that line, otherwise now, you are overwriting it and deleting the current content.


    • Trygve André Tønnesland

      Thanks for correcting me on that one! Blog post updated :-)

  • How to make Ubuntu play nice with VMWare « LinuxLife Blog

    […] http://tech.vg.no/2014/01/08/how-to-make-ubuntu-play-nice-with-vmware […]


  • David

    Hi!

    Thanks for this post, I tried to apply in my Ubuntu 14 box but is not possible because I have this message:

    FATAL: Module acpi_memhotplug not found

    I tried to install but can't find it.
    Can anybody tell me how can I install this module?

    Thanks!


Leave your comment