HowTo Install Virtual Machines with VMware Player

From OpenFOAMWiki

1 Introduction

Testing OpenFOAM installations on several different Operating Systems can take its toll. But at least with virtualization, one person can handle 3, 4 or even more virtual machines at the same time or in sequence, all with a single real machine.

For the readers that don't know what machine virtualization is, here are some pages on this subject at Wikipedia:


From the last link there are 2 popular and free virtualization applications for the general public:

  • VirtualBox - The preferred among the open-source community, given the code is open-source.
  • VMware Player - The one described in this How To page and which will be referred to from here on as VMplayer. Warning: VMPlayer is only free for non-commercial use.

The choice of using VMplayer is somewhat simple: it's free (for non-commercial use), very good (if not best) performance and easy to use. Nonetheless, VirtualBox is a very good competitor, specially for testing PXE boot images. (Wyldckat 00:11, 7 July 2012 (CEST))


This wiki page is divided into the following chapters:

Final introductory note: this tutorial would probably be more appreciated as a video tutorial, but that exercise is left to the readers that wish to contribute!

2 How to install VMplayer

First a few links for reference:

Go to the first link and take care of registering and downloading VMplayer for your desired Operating System (Windows, Linux or Mac OS X). (If you don't want to register... search online for other possible solutions, but be careful not to download damaged software.)
Note: The objective here is to install VMplayer on your real machine!

  • On Windows (and Mac OS X ?), you simply double-click on the downloaded file.
  • On Linux, you probably have to do it manually (click on images to enlarge):
1. Open a terminal.

Note: these images were actually taken from inside a virtual machine. But keep in mind that you are not meant to install VMplayer itself inside a virtual machine!
2. As shown in the instructions above:
  1. Go into the folder where you have downloaded to the .bundle file;
  2. Check if the file is executable:
    ll
    #or
    ls -l
    It should have the execution permissions. If it doesn't have execution permissions, run:
    chmod +x VMware*
  3. Now run it:
    gksu ./VMware<tab>
    The <tab> text is in reference to you pressing the Tab key. As for gksu, that's the GUI version of sudo; if it doesn't work, then try sudo instead or simply run the VMware package as root.


Now, once the installer is running, here is what appears on Linux, although it will be very similar on the other Operating Systems:

1. Here you pick Agree and press the Next button.
2. This is your choice to make. Next...
3. Again, your choice. Next...
4. Ready to go! Hit Install.
5. It will take a while to install.
6. When complete, Windows will ask for a reboot.


If using Windows, you can skip to the next chapter. If using Linux, here's what to do:

1. Run VMplayer. Either via programs menu or via terminal with the command vmplayer. *Note*: Pay no attention to the fact that this image was taken or another virtual machine...
2. This question will pop-up. It will ask for your super-user (root) access password after you press Install.
3. It will take a while to install the services. You might have to reboot for this to work properly.
4. If things don't go well, an error message like this one will pop-up. If this happens, check the chapter Getting Help



3 How to create a new virtual machine

Here it will be exemplified how to create and install a virtual machine with Xubuntu 12.04 x86_64 (64bit). This assumes you've already downloaded the desktop ISO of Xubuntu 12.04 x86_64, which we'll leave to the reader to figure out how and were to get it.


3.1 Create a New Virtual Machine

This section will take you step by step on how to create a new virtual machine, mainly oriented to test building OpenFOAM. This example will use Xubuntu 12.04 x86_64 (aka 64bits and amd64).

To run the VMplayer, it will depend on the Operating System you are using on your real machine:

Windows
Should be on the programs menu, on the lower left corner of the screen, in the button also known as the Start button.
Linux
Depends a bit on the distribution. The more modern ones work the same way you run any other application: you write the name of what you want to run (vmplayer, vmware or even player) and it will show you what it thinks you mean. On the more classic ones, it usually is put in the System Tools section.
You can also go old school and run in a terminal/console window:
vmplayer
Mac OS X
If you have one, then you should already know where to look ;)


So, after you've managed to figure out how to run VMplayer, here are the steps to be taken (you can click on the images to see them bigger):

0. This is the main window of VMplayer 4.0.4, as shown on Ubuntu. The Windows and Mac versions should be almost identical.

Press the giant button Create a New Virtual Machine.
1. Here you can either use the automagical OS installer that VMplayer provides, which provides an automated way for installing the Operating system. For that method, pick either the first or second method shown above.

For this tutorial, we'll use the manual installation procedure (the third one), so we can have more control over the process.
2. Here things can get tricky at times. You have to choose the Guest Operating System (Guest is the virtual machine you're creating) as close as possible to the one you're installing. That includes the architecture, i.e. 32 or 64bit!

For the exemplified Xubuntu 12.04 x86_64 is a derivative of Ubuntu, so we will choose Ubuntu 64-bit.
3. Now for the location: this one is a bit confusing at times, but it's quite simple. As shown in the example above, the Name is the name given to the machine; the Location is the path to the folder where the machine is to be stored in.

The confusion can be that one might assume that the Location is the parent folder for the virtual machine, where the Name would then give the folder name to the machine, which is not the case.
4. Disk size is the maximum size of the primary virtual hard-drive. 20GB is usually more than enough for just testing OpenFOAM and ParaView. The file is not completely allocated when creating it,s o it's a very good way to save space as well!
As shown in the example, keep the virtual disk in a single file, so you can have the best performance. The split option is very useful if you want to carry the virtual machine inside an external hard-drive that is formatted to FAT32.
5. This is the summary of the hardware to be used by the virtual machine. We will want to customize it because building OpenFOAM needs more power.
6. For memory, we'll need a bare minimum of 1.6GB of RAM for 2 virtual cores and about 2GB for 4 cores. As shown in the image, you can either use the vertical tick bar (the one with the blue, green and yellow ticks) or change the value directly in the box that says 2048. Note: If you change the value numerically, use the up and down arrow on the right of the edit box to update the value; otherwise the value might not be defined properly.
7. On the left, choose the Processors row. Now if your real machine has 4 or more cores (or even Hyper Threading), then choose 4 processor cores. If not, choose less cores, to avoid overloading your real machine.

As for the Virtualization Engine, leave the default values as shown in the image above. If you're curious about what they do, check the user guide or search online.
8. Pick the Display on the left. The feature Accelerate 3D graphics has been known to be very experimental, so if you want to, you can use it at your own risk. The advice here is to leave things as shown in this picture above.
9. Pick the New CD/DVD (IDE) on the left. Here you can choose right away the ISO image that has the Xubuntu CD image.

For now, this is it, so you can hit the Close button.

Keep in mind that you can add and remove virtual hardware, such as serial ports, hard disks, CD/DVD drives, sound cards, network cards, floppy drives and so on. You can add and remove them later on.
10. Here's the final summary for the virtual machine! You can click on the button Finish.
11. These are instructions about the next steps that can be taken. We'll show them step-by-step on this tutorial.


3.2 Installing Xubuntu 12.04 x86_64

Now onward to installing Xubuntu 12.04 x86_64 inside the virtual machine:

0. Now we are back to the main window of VMplayer. On the left you have a list of the latest virtual machines you've opened and clicking on them will show on the right a brief summary of what they have and how they are.

Press the giant Play virtual machine button.
1. This is the main window of your new virtual machine. On the top left you have a menu that you can use for configuring properties and sending hard commands to the machine, such as the power or reset buttons.

On the lower right corner you have a row of icons that represent the hardware in the virtual machine. Left or right clicking on each icon should give you control options, such as disabling or enabling the component, or changing the ISO to be used for installing an Operating System.

As disclaimed in the lower left corner of the window, a message indicates that you can get keyboard control inside the virtual machine if you hit the key combination Ctrl+G; you can also simply left click inside the window.

In the middle of the window you have the virtual BIOS screen. Pressing the key F2 (with keyboard control active inside it) will show you the set-up options for the virtual machine. In this tutorial we wont detail how to configure it, but it is in there that you can change the priority for booting first from the (virtual) CD/DVD drive or from the hard-drive.
If you take too long to press F2, you can use the key combination Ctrl+Alt+Insert, which is the same as if you pressed Ctrl+Alt+Delete on your real machine, i.e. sending the command for rebooting.

2. Since the hard-drive is empty, the CD will kick in and start the live CD with Xubuntu on it.

Ubuntu is a bit... minimalist when it comes to booting from the CD. So you'll have to press the up or down cursors for a menu to show up, otherwise it will do the default: boot the live session.
3. After the menu shows up, it will show a second menu for selecting the language you want to install. The advised language is English, because it is the default testing language for OpenFOAM. Use the cursor keys to select the language you want and press the Enter key to select.
4. Next press the F4 key, to select the keyboard map to be used, because if you don't have a USA keyboard, it can get very annoying during installation or live session.
5. Here choose the Install Xubuntu entry (use the cursor keys once again and Enter key).
6. And it's booting!
7. The window will probably resize for matching the new resolution used during installation.
8. Now the Xubuntu installation process starts. Here you can choose the language for the installation once again. Hit the Continue button.
9. Here the choice is yours: you can either leave the Download updates option checked or not.
Third-party is pretty useless inside the virtual machine.

Continue...
10. This is where you configure how the disk is used. Here you can leave the default as shown, since the objective is to test OpenFOAM, but it's up to you if you want to create a more representative disk partition structure.

Continue...
11. Here you choose the disk partition to be used. There should be only one, given the choices made so far.

Install now...
12. Wait a bit for it to think about what to do next...
13. Now it will install Xubuntu in the background, while you configure some important details. In this case, the time zone.

As shown, here's a big Hello from Portugal!

Continue...
14. Yep, Portuguese keyboard in my case (Wyldckat 11:51, 7 July 2012 (CEST)).

Continue...
15. Here you can configure your user information. Do not choose a username with spaces in it! Your name can have spaces and periods and so on, but the username should be as simple as possible!
Log in automatically is very useful for testing OpenFOAM installations, so leave it on.
Nonetheless, always define a password; it doesn't (or shouldn't) have to be the one you use on the real machine. Just because it's a virtual machine, it doesn't mean it's safe from potential security problems which arise due to vulnerabilities!

Continue...
16. And now you wait for it to install...
17. While you wait, press the key combination Ctrl+Alt, or move the mouse to the outside of the virtual machine. On the main window of VMplayer, choose the menu entry File -> Player Preferences. The window above will appear. The options shown in this image are personal preferences (Wyldckat 11:51, 7 July 2012 (CEST)), but feel free to configure as you desire.

Press the Close button when done.
18. In the mean time, Xubuntu might have finished installing. Press the Restart Now button.

*Note*: If you didn't already have control inside the virtual machine, you will have to click a second time. You have control in the virtual machine when the message on the lower left shows To release input, press Ctrl+Alt.
19. While starting to reboot, Xubuntu will ask you to hit the Enter key. This is because there is an intermediate step of ejecting the CD.
20. After it boots up, onward to installing the valuable VMware Tools for refining the interaction between real and virtual machines. This basically means that you'll be able resize the virtual screen on-demand, as well as using copy-paste for transferring text or files between the two.

Therefore, start a new terminal window.
21. Now press the key combination Ctrl+Alt, or move the mouse to the outside of the virtual machine. Go to the VMplayer's menu and choose Virtual Machine -> Install VMware tools. The window shown will pop-up. Press the Install button.
22. The ISO with the tools will be loaded into the virtual machine. So go back into the virtual machine and run the command shown in it:
tar -xf /media/VMware\ Tools/VMwareTools-8.8.4-743747.tar.gz

Note: the file name may be different, so use the Tab for auto-completion:
tar -xf /media/VM<tab>
tar -xf /media/VM\ Tools/VM<tab>
23. Next run the commands:
cd vmware-tools-distrib/
sudo ./vmware-install.pl -d
This will ask for root access, namely your user password that you defined for the virtual machine. It will then install the drivers that will establish the connection between virtual and real machine.

*Note:* In case you are using some other Linux distribution, make sure that before this command you install the GCC package!
*Another note*: the -d option is for using the default answers. Very useful, since there are a lot of questions. You can remove that option, if you want to do this step-by-step.
24. There is goes, building and installing on its own...
25. When complete, it ejects the CD that had the VMware tools. Nonetheless, there is still some cleaning up to do...
26. Let's go back the the parent folder and remove the temporary tools folder:
cd ..
rm -r vmware-tools-distrib
27. OK, it's going to ask a lot of questions... Hit the key combination Ctrl+C and run with an additional option:
rm -rf vmware-tools-distrib
Caution: the f (force) option is very useful, but it can doom you if you're not careful when using it!
28. This is a proof of concept. Switch to the real machine (Ctrl+Alt or move mouse outside) and resize the VMplayer window. As you can see, the virtual window didn't resize. So run the command:
vmware-user
When it's done executing, resize the window again!
29. A few error messages appeared in the terminal window, but we'll ignore them since we now have a resized virtual machien window, as big as your real screen can handle!
Nonetheless, the best would be to reboot the virtual machine... which you can do as is if it were the real machine: you go to the respective controls (upper right corner inside the virtual machine, the me text is a button with the username) and choose to reboot or even shutdown.
30. Finally, update the Xubuntu packages inside the virtual machine, but only if you want to...

Now that you have a virtual machine working, it's up to you to do whatever you want inside it!


3.3 Final hints

  • You can drag-and-drop files from the real machine file manager onto the file manager inside the virtual machine.
  • You can also define a folder to be shared between the real and virtual machines. For that, go to the menu Virtual Machine -> Virtual Machine Settings, then choose the Options tab, and on the left pick the row Shared Folders. The rest on the right should be self-explanatory... but the idea is that you define a folder in the real machine to be shared with the virtual machine.
    After you've accepted the changes, go back into the virtual machine and in the following folder you will find the shared folders:
    /mnt/hgfs/
  • In the VMplayer window, menu Virtual Machine -> Enter Full Screen switches the virtual machine to full screen mode, with a top bar with the VMplayer menu. The Ctrl+Alt key combination will still work as intended when in full screen.
  • The Unity mode, menu Virtual Machine -> Enter Unity is a merged mode that VMplayer provides, which virtualizes (in this case) the Xubuntu toolbar on the real machine, as well as any windows launched inside the virtual machine. This is a nice mode if you need a full immersion work environment.
  • You can run more than one virtual machine at once! All you have to do is launch one VMplayer window per virtual machine.
    • Caution: Building OpenFOAM on two or more virtual machines at the same time can be easily done, as long as you have enough real cores and memory in the real machine.
      For example, a real machine with 8GB of RAM and 6 real cores, can easily run 3 VMs (virtual machines) with 2 cores and 2GB each. But it won't be able to handle very well 3 VMs with 4 cores and 2 GB each, since it will overload the system and might end up crashing the real machine! (Wyldckat 12:38, 7 July 2012 (CEST))
    • Another reason for caution is to not install more than one Operating System on each VM at the same time. The heavy access to the real hard-drive might lock up things during installation of both VMs. (Wyldckat 12:38, 7 July 2012 (CEST))
  • You should not use two VMplayer windows to control the same virtual machine. If you try this, you're just asking for trouble.
  • If you want to install a Windows Operating System in a virtual machine, keep in mind that Windows will demand that you use a new license for each virtual machine! Also, portability of such a virtual machine might not be as easy, since the real machine's specifications are reflected inside the virtual machine!



4 Troubleshooting

On this chapter is shown various known issues and solutions. Other issues and solutions can be found in the official documentation (see chapter How to install VMplayer) and online.


4.1 The yield() function is not activated

Issue: A message dialogue box appears saying:

The yield() function is not activated

And doesn't allow running the machine.

Note: This is happens on Linux with kernel versions greater or equal to 2.6.31.

Solution: To fix this until next boot, run as root:

echo "1">/proc/sys/kernel/sched_compat_yield
sysctl -w kernel.sched_compat_yield="1"

For a permanent solution, run as root as well:

echo -e "\n\n#This is needed for Virtual Machines to run at full power\!\nkernel.sched_compat_yield = 1" >> /etc/sysctl.conf


4.2 Unable to operate the VMplayer window

Issue: Error and warning windows sometimes pop to the wrong side of the window, namely to the back of the VMplayer window!

Note: This is more common on Linux.

Solution: The main window is sometimes still usable, in the sense that it can still be moved out of the way, to reveal the small error/warning dialogue in the back of the main window.


4.3 /dev/vmmon does not exist

Issue: A dialogue appears with the message:

/dev/vmmon does not exist

Note: This is more common on Linux.

Solution: run as root:

/etc/init.d/vmware stop
/etc/init.d/vmware start



5 Getting Help

If even after this highly detailed step-by-step guide you still can't figure things out or if a weird error occurred, you've got several options:



6 History

Readers are welcome to improve this document if they so see fit to do it. Links to video tutorials directly related to this tutorial are also welcome.

Below is a short edit history. For the complete history, see the History link at the top-right of the page.

  • Wyldckat 14:01, 7 July 2012 (CEST) - All done.
  • Wyldckat 12:39, 7 July 2012 (CEST) - All that is left is the chapter about installing VMplayer itself...
  • Wyldckat 00:30, 7 July 2012 (CEST) - Still editing the page...