wiki:setup_virtual_machine

Version 1 (modified by Patrick G, 11 years ago) (diff)

--

A virtual machine is a simulated computer that runs in an operating system. For example, you might want to setup a development workstation without modifying your current operating system, so you create a virtual machine that runs Debian GNU/Linux and use it as a development environment.

Vocabulary and Basics

  • Host: the operating system you start with, probably the one running on your hardware.
  • Guest: the operating system that runs in the virtual machine.

There are a few types of virtualization / virtual machines, and each type has unique characteristics. See https://fedoraproject.org/wiki/Virtualization for an explanation of the different types. For example, "full virtualization" takes up more hard disk space than "operating system-level virtualization".

Steps for full virtualization in GNU/Linux

  • Check if your kernel supports virtualization.

At a command prompt, type

egrep '(vmx|svm)' /proc/cpuinfo

If a result appears, then your kernel supports kernel-based virtualization. If nothing shows up, then your kernel doesn't support kernel-based virtualization.

  • Enable virtualization in your BIOS.

Restart your computer. When the computer first starts to boot, watch the screen and when it says "Press F1 for BIOS config" or something like that, press the indicated key. Look for CPU options, and look for something that mentions virtualization, and if it isn't already enabled, then enable it.

  • Save changes to BIOS and exit.
  • For the BIOS changes to take effect, you may have to turn off the computer (not just restart it -- actually turn it off) and turn it on again (maybe twice).

If those steps worked, your computer is ready to run a virtual machine.

Setting up a virtual machine for web development

Assuming GNU/Linux operating system:

  • Install VirtualBox and Puppet. The most common GNU?Linux distributions have these available as packages for easy installation.
  • Install Vagrant (it depends on VirtualBox and, optionally Puppet or Chef. I've emphasized Puppet here since the May First / People Link servers are configured using Puppet).

Your distribution might have a vagrant package available, or you might have to download the package from the Vagrant website: http://www.vagrantup.com .

  • If you want to run Drupal websites, then you might find the Drupal-up and Aegir-up projects useful. They use Vagrant to create virtual machines with Drupal installed and configured.
  • If you install Vagrant and get an error about failure to connect to the VM via SSH, then follow the instructions here: http://superuser.com/a/342477

Steps for operating system-level virtualization

Operating system-level virtualization is also called "resource containers," and has different names in different operating systems: BSD has "jails"; OpenSolaris/OpenIndiana has "zones"; and GNU/Linux has "chroot", "openvz" (and in Debian the ProxMox interface for OpenVZ), and "lxc" (newer than openvz, more integrated with the mainline Linux kernel and therefore seems to have more future). This kind of virtualization can isolate a single process, a set of processes, or an entire other operating system from the host operating system.