Virtualization In Linux With Xen
- 1 Virtualization Technology
- 2 Hardware Virtualization
- 3 Why Use Virtualization
- 4 Virtualization In Linux With Xen
Virtualization means creating a virtual version of something like computer hardware, storage devices, and network resources, etc. It allows you to create multiple simulated environments from a single physical hardware system. For example, a Windows operating system can host a system with Linux Os or it can be any other operating system. It provides the functionality of a physical computer. Each virtual system that is hosted on a system (like Windows in this case)is known as a virtual machine(VM) or a guest machine. And the system that is used for virtualization is known as the host machine.
Using a single physical computer hardware to create multiple virtual machines that are running different operating systems. The software that is executed on the virtual machine is separated from the underlying hardware resources. The software, hardware or firmware that creates a virtual machine on the host hardware is known as a hypervisor or virtual machine monitor(VMM). Broadly hardware virtualization can be categorized into two primary types-
1. Full virtualization –
Also, know as type-1 virtualization is almost complete Simulation of the actual hardware. It requires every salient feature of hardware to be reflected in virtual machines including full instruction set, input/output operations, interrupts, Memory access and many other features that are used by a software that runs on the bare machine. Examples of software that supports full virtualization are VMware ESXi/ESX, Hyper-V, Xen, VMWare Server, etc.
In this type of virtualization, the programs that are running in virtual machines are executed in their own isolated domain as if they are running on a separate system, but the hardware environment is not simulated. The programs of guest machines need to be specifically modified to run in this environment. Example of software that supports paravirtualization are IBM LPAR, Oracle VM for SPARC(LDOM), Xen(supports both type of virtualization)
Other types of virtualization are hybrid and OS-level virtualization that are explained below-
3. OS level virtualization –
This type of virtualization is widely used. Os level virtualization also know as “containerization”. In this type of virtualization, kernel allows the existence of multiple isolated user-space instances. Such instances, called containers, zones, virtual private servers, virtual kernels, jails, etc. Examples of the software that supports this type of virtualization are Solaris, Docker, dragonfly BSD, free BSD jail, etc.
4. Hybrid virtualization –
It is the combination of both full and paravirtualization. In this paravirtualization can be used for one feature while full virtualization can be used for other features. Examples of the software that support this type of virtualization are Oracle VM for x86, Xen, VMware ESXi, etc.
Why Use Virtualization
- Isolated, virtual networks can be created from one original network
- A single server can be made to act like multiple servers
- A computer can be transformed to run multiple different operating systems
- Computing infrastructure which is expensive to maintain can be virtualized for optimal use
Virtualization In Linux With Xen
Xen project creates a VMM or hypervisor that allows the execution of multiple virtual guest operating systems on a physical machine. Since it is a type 1 hypervisor it runs directly on the top of a physical machine instead of running within the operating system.
Guest virtual machines running on Xen hypervisor are known as domains. A special domain known as domain0(or dom0) is responsible for controlling hypervisor and starting of guest Operating systems. other operating systems are known as domUs(or unprivileged domain) as these don’t control hypervisor.
apt-get install xen-system-amd64
This will install a 64bit hypervisor. If you are using a recent version of grub, it will automatically get listed in the boot menu. Now reboot your system. And use
sudo xl list in the terminal to verify the installation success.
Setup LVM storage for guests –
LVM stands for “logical volume manager”. It is a technology that allows Linux to manage logical volumes or filesystem that is much more advanced and flexible than the traditional method of partitioning of disk into one or more parts. Unlike disk partitions, these virtualized blocks don’t need to be contiguous. Generally, Linux distributions come with preinstalled LVM but if you don’t have in your system you can use the following command to install it-
apt-get install lvm2
Now configure the lvm to use one or more physical volumes like given below-
pvcreate /dev/sda4 (you can use other disk to create physical volumes )
Create a volume group to use the available spaces of created physical volumes-
vgcreate vg0 /dev/sda4
A group of physical volumes is created. Now we can create multiple logical volumes to utilize it in virtual machine-
lvcreate -n Volume_name -L Size_of_volume(with M-megabyte or G-Gigabyte) volume_group
For example, if you want to create volume with 20GB use the following command
lvcreate -n vol1 -L 20G vg0
and if you want to remove this volume at a later stage you can use the following command
Once the lvm storage is set up follow the next step to configure the network interface for it.
Network configuration –
To connect virtual machines from the external network we need to set up the Linux bridge in our system which can be done by creating a virtual switch in dom0. This switch will send/receive the data to or from the physical network from the virtual machine. The software used to implement this switch is called a Linux bridge.
Use the following command to install it-
sudo apt-get install bridge-utils
The network can be configured via
Open this file using a text editor-
Depending on hardware it will look something like this-
Edit it so that it should look like this-
now restart the networking by using given command
service networking restart
Check if it is working or not by using the given command
bridge networking will now start automatically on every boot.
Some basic commands used in the Xen are –
xl info– will return the information about the hypervisor and dom0 including version, free memory, etc
xl list– List running domains, their IDs, Memory, state and CPU time consumed
xl top– Will display the running domains
Creating Virtual Machines –
You can manually create a VM or the process can be automated by using tools like virt-builder, virt-manager or Xen-tools.
To install the Xen-tools in your system use the following command in the terminal & within the domain-
sudo apt-get install xen-tools
and used the given command to create a guest –
xen-create-image --hostname= Guest_OS \
This process will take some time to complete.
Starting guest in the console –
Use the command below to start a guest
xl create -c /etc/xen/Guest_OS.cfg
xm(in older versions of Xen) that we wish to connect the guest’s virtual console.
you can leave the console by using the given command-
xl shutdown Guest_OS
For creating a para-virtualized VM guest manually or setting up an HVM i.e Hardware virtualized guest you can follow Create PV Guest and HVM Manually which explains it in detail. If you still have a query you can drop a comment below.
You might also like
FTP or File Transfer Protocol is a standard networking protocol used to transfer files between client and server. An FTP user may authenticate themselves by using username and a password.
A system backup is a process in which the state, files, and data of a computer system are copied and stored somewhere. Later if primary data is corrupted, deleted or
Contents1 What is apt-fast?2 How to install it?3 How to use it? What is apt-fast? apt-fast is a shell script wrapper for apt-get and aptitude that can drastically improve the