How to properly setup Kubuntu in a VMware virtual machine

Well, this is the end of a long day, and I used WAY TOO MUCH time on getting a simple Kubuntu installation in a VMware virtual machine running.

The scenario is the following:

  • VMware Player will be used for “playing back” the machine
  • Copy & Paste must work
  • Auto mouse-grabbing and -releasing must work

Those requirements make installing Kubuntu in a VM more tricky than you might think – here is a cookbook recipe:

  • Use VMXBuilder or some other tool to generate the Virtual Machine (because VMplayer can only play it back, as the name suggests)
  • Make sure that you have TWO IDE controllers (like most real PCs), and connect a virtual harddisk (10 GB or so) to the first controller. Connect a virtual CD drive to the second IDE controller. If you try to use only one IDE controller and connect both devices to that one, the VM will be AWFULLY slow. At least that’s what happened here.
  • Supply the Kubuntu-CD-image to the virtual CD drive.
  • Boot up the VM.
  • Install Kubuntu to the virtual harddrive, that shouldn’t be much of a problem.
  • After the installation is finished, shutdown the VM.
  • Boot up the VM and disable the CD drive, or press ESC during bootup and select harddisk. Now it will boot your newly installed Kubuntu. Apply all the pending updates (as of today that were 125). Go and do something else, if you don’t have a REALLY fast machine & internet connection.
  • Install “alien”, a program that will convert .rpm packages to .deb packages, and thus will enable you to use Kubuntu’s package manager to install VMware tools, which is imo the best solution available.
  • Shutdown your VM.

Now the trouble begins. How to get VMware Tools into this VM, because only with those, you can have Copy & Paste and automatic mouse grabbing/releasing. Here’s the solution.

  • You need to have access to a VMware Workstation installation, or some other way to obtain the file “VMwareTools-5.5.0-18463.i386.rpm” (or perhaps a different version). It’s part of the linux.iso file which itself is part of VMware Workstation, and usually installed under “VMware Workstation installation/lib/isoimages/linux.iso”. Perhaps you can find it somewhere on the net, too – didn’t check. The file has 15 MB, the whole iso image has around 30 MB.
  • Open your VMX file again and put the ISO into your virtual CD drive.
  • Boot your VM again. Copy the VMwareTools-5.5.0-18463.i386.rpm file to /tmp or somewhere else where you have write access and run alien --script VMwareTools-5.5.0-18463.i386.rpm. This will take a surprisingly long time, but will give you a file called VMwareTools-5.5.0-18463.i386.deb (or something like it). Now you can conveniently install the deb by running dpkg -i VMwareTools-5.5.0-18463.i386.deb.

VMware Tools are now installed into your Kubuntu VM, but that doesn’t mean they work. In fact they don’t. Not at all.

  • First, run ln -s /usr/lib/vmware-tools/lib32/libgdk-1.2.so.0/libgdk-1.2.so.0 /usr/lib/libgdk-1.2.so.0.
  • Then, run vmware-config-tools.pl as root, let it compile the kernel module and set your desired Xorg resolution.
  • Now, the vmmouse driver for Xorg has to be copied to an Xorg directory – don’t know why this isn’t done automatically, perhaps the rpm-deb-conversion doesn’t work so well after all – this could also be the reason for the libgdk stuff… Do it by running cp /usr/lib/vmware-tools/configurator/XOrg/7.0/vmmouse_drv.so /usr/lib/xorg/modules/input/.
  • Activate the vmmouse driver in xorg.conf (change “Driver “mouse”” to “Driver “vmmouse”” in Section “InputDevice”), which will finally give you auto mouse-grabbing/releasing (after you restart your X server, of course).
  • You still won’t be able to copy & paste text between the VM and your host system – to get this to work, there must be an instance of “vmware-toolbox” running inside your user’s X session. I recommend to use the following .desktop file and place it under ~/.kde/Autostart/vmware-toolbox.desktop or something like that.

[Desktop Entry]
Comment=
Comment[en_US]=
Encoding=UTF-8
Exec=ksystraycmd --ownicon --window "VMware Tools Properties" --icon "/usr/share/app-install/icons/vmware-player.png" --hidden vmware-toolbox
GenericName=
GenericName[en_US]=
Icon=/usr/share/app-install/icons/vmware-player.png
MimeType=
Name=VMWare Toolbox to Tray
Name[en_US]=VMWare Toolbox to Tray
Path=
StartupNotify=true
Terminal=false
TerminalOptions=
Type=Application
X-DCOP-ServiceType=
X-KDE-SubstituteUID=false
X-KDE-Username=
X-Ubuntu-Gettext-Domain=desktop_kdebase

Notice the line with ksystraycmd --ownicon --window "VMware Tools Properties" --icon "/usr/share/app-install/icons/vmware-player.png" --hidden vmware-toolbox, where ksystraycmd is being used to put that ugly VMware toolbox program into the tray, and give it a nice icon.

  • Open the VMX file again and remove the Kubuntu ISO from the CD drive. Instead specify that the VM should use your real CD/DVD drive. Turn off legacy emulation (I had trouble with this some other time, don’t remember the specific problem though).

You’re done! Finally…