What your are asking is called a Hypervisor. Xen Hypervisor is one of those.
What is Xen?
Xen is an open-source type-1 or baremetal hypervisor, which makes it possible to run many instances of an operating system or indeed different operating systems in parallel on a single machine (or host). Xen is the only type-1 hypervisor that is available as open source. Xen is used as the basis for a number of different commercial and open source applications, such as: server virtualization, Infrastructure as a Service (IaaS), desktop virtualization, security applications, embedded and hardware appliances. Xen is powering the largest clouds in production today.
Components in detail:
- The Xen Hypervisor is an exceptionally lean (<150,000 lines of code) software layer that runs directly on the hardware and is responsible for managing CPU, memory, and interrupts. It is the first program running after the bootloader exits. The hypervisor itself has no knowledge of I/O functions such as networking and storage.
(more details when you click the link)
Image of the setup (source of the image). The source has a very nice comparison between VMWare, MS Viridian and Xen.
The Ubuntu official documentation has installation method and tips and tricks on how to set this up:
During installation of Ubuntu
During the install of Ubuntu for the Partitioning method choose
"Guided - use the entire disk and setup LVM". Then, when prompted to
enter "Amount of volume group to use for guided partitioning:" Enter a
value just large enough for the Xen Dom0 system, leaving the rest for
virtual disks. Enter a value smaller than the size of your
installation drive. For example 10 GB or even 5 GB should be large
enough for a minimal Xen Dom0 system. Entering a percentage of maximum
size (e.g. 25%) is also a reasonable choice.
Install a 64-bit hypervisor. (A 64-bit hypervisor works with a 32-bit
dom0 kernel, but allows you to run 64-bit guests as well.)
sudo apt-get install xen-hypervisor-amd64
Modify GRUB to default to booting Xen ("Xen 4.1-amd64" should be
replaced with the appropriate name, in 12.10 the line is "Ubuntu
GNU/Linux, with Xen hypervisor"):
sudo sed -i 's/GRUB_DEFAULT=.*\+/GRUB_DEFAULT="Xen 4.1-amd64"/'
/etc/default/grub sudo update-grub
Set the default toolstack to xm (aka xend):
sudo sed -i 's/TOOLSTACK=.*\+/TOOLSTACK="xm"/' /etc/default/xen
And then verify that the installation has succeeded:
sudo xm list
Name ID Mem VCPUs State Time(s)
Domain-0 0 945 1 r----- 11.3