Tag: Virtualization

Virtualization

LXC – Linux Container

LXC – Linux Container

Introduction-

What are the different Container technology?

Container technology has started after 2013. There is a high potential of getting confused about available container types like Docker , LXC/LXD and CoreOS rocket.

What’s LXC?
LXC (Linux Containers) is an operating-system-level virtualization method for running multiple isolated Linux systems (containers) on a control host using a single Linux kernel.
LXC is a userspace interface for the Linux kernel containment features. Through a powerful API and simple tools, it lets Linux users easily create and manage system or application containers.

Benefits of Linux Containers:
1 – Lightweight built-in virtualization
2 – Application/server isolation
3 – Easy deployment and management
4 – No additional licensing

Weaknesses of Linux Containers:
1 – Locked into the host kernel
2 – Supported only on Linux

Current LXC uses the following kernel features to contain processes:
– Kernel namespaces (ipc, uts, mount, pid, network and user)
– Apparmor and SELinux profiles
AppArmor is a Linux kernel security module that allows the system administrator to restrict programs’ capabilities with per-program profiles.
Security-Enhanced Linux is a Linux kernel security module that provides a mechanism for supporting access control security policies.
Seccomp policies
Chroots (using pivot_root)
Kernel capabilities
CGroups (control groups)

LXC is currently made of a few separate components:
– The liblxc library
– A set of standard tools to control the containers
– Distribution container templates
– Several language bindings for the API:
– python3
– Go
– ruby
– Haskell

The Linux kernel provides the cgroups functionality that allows limitation and prioritization of resources (CPU, memory, block I/O, network, etc.) without the need for starting any virtual machines, and also namespace isolation functionality that allows complete isolation of an applications’ view of the operating environment, including process trees, networking, user IDs and mounted file systems.

LXC containers are often considered as something in the middle between a chroot and a full fledged virtual machine. The goal of LXC is to create an environment as close as possible to a standard Linux installation but without the need for a separate kernel.
LXC combines the kernel’s cgroups and support for isolated namespaces to provide an isolated environment for applications. Docker can also use LXC as one of its execution drivers, enabling image management and providing deployment services.

What’s LXD?
LXD is a next generation system container manager. It offers a user experience similar to virtual machines but using Linux containers instead. LXD isn’t a rewrite of LXC, in fact it’s building on top of LXC to provide a new, better user experience. Under the hood, LXD uses LXC through liblxc and its Go binding to create and manage the containers.

What is difference between LXD vs Docker?
– Docker focuses on application delivery from development to production, while LXD’s focus is system containers.
– LXC in market since 2008 as compare to Docker 2013.
– Earlier Docker was based on LXC. Later Docker replaced it with libcontainer.
– Docker specializes in deploying apps
– LXD specializes in deploying (Linux) Virtual Machines

Application build using LXC?
Anbox – Android in a Box
Anbox is a container-based approach to boot a full Android system on a regular GNU/Linux system like Ubuntu. In other words: Anbox will let you run Android on your Linux system without the slowness of virtualization.

Reference –
WebSite: https://linuxcontainers.org
Version: LXC 2.1.x
https://linuxcontainers.org/lxd/getting-started-cli
http://www.tothenew.com/blog/lxc-linux-containers

Thank you,
Arun Bagul

What is Virtualization and Types of Virtualization

What is Virtualization and Types of Virtualization

What is Virtualization and Type of Virtualization?

In general there are different types of virtualization like Memory,CPU, Storage, Hardware and Network virtualization. Howver here we are going to talk about OS virtualization only.

1] What is Hypervisor –

Hardware virtualization or platform virtualization refers to the creation of a virtual machine that acts like a real computer with an operating system. Software executed on these virtual machines is separated from the underlying hardware resources.
The words host and guest are used to distinguish the software that runs on the physical machine from the software that runs on the virtual machine.
The software or firmware that creates a virtual machine on the host hardware is called a hypervisor or Virtual Machine Manager.

2] Type of Virtualization –

a) Para-virtualization –
-Guest OS has to be modified
-VM does not simulate hardware
-Use special API that a modified guest OS must use
-Hypercalls trapped by the Hypervisor and serviced
-Xen, VMWare ESX Server

b) Full-virtualization (Native) –
VM simulates “enough” hardware to allow an unmodified guest OS to be run in
isolation. Same Hardware and CPU/Memory, eg- Vmware,IBM VM family,Parallels,
Xen.
* Full virtualization with Xen Hypervisor requires:
i) Intel processor with the Intel VT extensions, or
ii) AMD processor with the AMD-V extensions, or
iii) an Intel Itanium processor
* Full virtualization with KVM hypervisor requires:
i) Intel processor with the Intel VT and the Intel 64 extensions, or
ii) AMD processor with the AMD-V and the AMD64 extensions

c) Emulation –
-VM emulates/simulates complete hardware
-Unmodified guest OS for a different PC can be run
-VirtualPC for Mac, QEMU

d) OS-level virtualization –
-OS allows multiple secure virtual servers to be run
-Guest OS is the same as the host OS, but appears isolated apps see an
isolated OS. eg: Solaris Containers, BSD Jails, Linux Vserver,OpenVZ and LXC (LinuX Containers)

e) Application level virtualization –
-Application is gives its own copy of components that are not shared
(eg: own registry files, global objects) – VE prevents conflicts, JVM

Thank you,
Arun Bagul

Xen virtualization on CentOS linux

Xen virtualization on CentOS linux

Introduction ~

What is Virtualization? ~ virtualization is technique of  running multiple operating system (OS) on same physical hardware at same time.
There are three types of Virtualization technologies

1) Full virtualization –
a) Hardware emulation – KQEMU
b) Binary translation – VirtualBox
c) Classic virtualization – OpenVZ
2) Para-virtualization
3) OS-level virtualization – Linux-VServer and OpenVZ

** Xen is an open-source para-virtualizing virtual machine monitor (VMM), or “hypervisor”,for a variety of processor. Xen can securely execute multiple virtual machines on a single physical system with near native performance.

** Xen Prerequisites –

1) iproute2 package
2) Linux bridge-utils (/sbin/brctl)
3) Linux hotplug system (/sbin/hotplug and related scripts)

Step 1) How to install Xen on Centos ~

[root@arun ~]# yum install xen.i386 xen-devel.i386   xen-libs.i386 libvirt.i386  libvirt-devel.i386  libvirt-python.i386 virt-manager.i386 virt-clone.i386

Step 2) How to install Xen Kernel for Centos ~

[root@arun ~]# yum install kernel-xen.i686  kernel-xen-devel.i686

* Once installation is completed; Please check the CentOS boot loader configuration file ie “/boot/grub/grub.conf”… and make sure that the first boot entry should look like this…

title CentOS (2.6.18-164.15.1.el5xen)
root (hd0,4)
kernel /boot/xen.gz-2.6.18-164.15.1.el5
module /boot/vmlinuz-2.6.18-164.15.1.el5xen ro root=LABEL=/ rhgb quiet
module /boot/initrd-2.6.18-164.15.1.el5xen.img

Step 3) Reboot the system so that system will boot with Xen Kernel….

That’s it Xen infrastructure is installed on CentOS.

[[root@arun ~]# rpm -qa | egrep “xen|virt” | sort
kernel-xen-2.6.18-164.15.1.el5
kernel-xen-devel-2.6.18-164.15.1.el5
libvirt-0.6.3-20.1.el5_4
libvirt-devel-0.6.3-20.1.el5_4
libvirt-python-0.6.3-20.1.el5_4
python-virtinst-0.400.3-5.el5
virt-manager-0.6.1-8.el5
xen-3.0.3-94.el5_4.3
xen-devel-3.0.3-94.el5_4.3
xen-libs-3.0.3-94.el5_4.3
[[root@arun ~]#
Step 4 ) Test Xen setup – make sure that “libvirtd” service is running

Step 5) Install first Guest CentOS –

* Create Disk as file as shown below….

[[root@arun ~]# dd if=/dev/zero  of=/var/xen-disk/centOS.hdd bs=4k seek=2048k count=0
0+0 records in
0+0 records out
0 bytes (0 B) copied, 0.000191 seconds, 0.0 kB/s
[[root@arun ~]#  mke2fs -j /var/xen-disk/centOS.hdd
mke2fs 1.39 (29-May-2006)
/var/xen-disk/centOS.hdd is not a block special device.
Proceed anyway? (y,n) y
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
1048576 inodes, 2097152 blocks
104857 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=2147483648
64 block groups
32768 blocks per group, 32768 fragments per group
16384 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632

Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 30 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.
[[root@arun ~]# mount -o loop /var/xen-disk/centOS.hdd  /mnt/
[[root@arun ~]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/sda5              55G   12G   41G  22% /
tmpfs                 829M   12K  829M   1% /dev/shm
/dev/sda2              23G   15G  7.8G  65% /mydata
none                  829M  104K  829M   1% /var/lib/xenstored
/var/xen-disk/centOS.hdd
7.9G  147M  7.4G   2% /mnt
[[root@arun ~]#

* We are going to install guestOS from CD/DVD image so we will export this image via FTP so let us
configure ftp server….

* We have copied Centos CD/DVD in “/home/CentOS5.0/” location….

[root@arun ~]# ls /home/CentOS5.0/
CentOS            RELEASE-NOTES-cz.html  RELEASE-NOTES-fr       RELEASE-NOTES-nl.html     repodata
EULA              RELEASE-NOTES-de       RELEASE-NOTES-fr.html  RELEASE-NOTES-pt          RPM-GPG-KEY-beta
GPL               RELEASE-NOTES-de.html  RELEASE-NOTES-it       RELEASE-NOTES-pt_BR       RPM-GPG-KEY-CentOS-5
images            RELEASE-NOTES-en       RELEASE-NOTES-it.html  RELEASE-NOTES-pt_BR.html  TRANS.TBL
isolinux          RELEASE-NOTES-en.html  RELEASE-NOTES-ja       RELEASE-NOTES-pt.html
NOTES             RELEASE-NOTES-es       RELEASE-NOTES-ja.html  RELEASE-NOTES-ru
RELEASE-NOTES-cz  RELEASE-NOTES-es.html  RELEASE-NOTES-nl       RELEASE-NOTES-ru.html
[root@arun ~]#

* I have changed anonymous FTP home from default one to “/home/CentOS5.0/” Please details below….

[root@arun ~]# grep ftp /etc/passwd
ftp:x:14:50:FTP User:/var/ftp:/sbin/nologin
[root@arun ~]#  vi /etc/passwd
[root@arun ~]# grep ftp /etc/passwd
ftp:x:14:50:FTP User:/home/CentOS5.0:/sbin/nologin
[root@arun ~]#

* Now, restart FTP server and try to access to ftp with IPaddress assigned to bridge “virbr0”. In my case it is “ftp://192.168.122.1”

* Start installation now using “virt-install”

[root@arun ~]# virt-install –name arunOS –os-type=linux –ram=300 –file /var/xen-disk/centOS.hdd –location ftp://192.168.122.1 –nographics –bridge=virbr0

Starting install…

* Welcome to CentOS

+————–+ Manual TCP/IP Configuration +—————+
|                                                            |
| Enter the IPv4 and/or the IPv6 address and prefix          |
| (address / prefix).  For IPv4, the dotted-quad netmask     |
| or the CIDR-style prefix are acceptable. The gateway and   |
| name server fields must be valid IPv4 or IPv6 addresses.   |
|                                                            |
| IPv4 address: 192.168.122.2___ / 255.255.255.0___          |
| Gateway:      192.168.0.1______________________________    |
| Name Server:  _________________________________________    |
|                                                            |
|            +—-+                      +——+            |
|            | OK |                      | Back |            |
|            +—-+                      +——+            |
|                                                            |
|                                                            |
+————————————————————+

<Tab>/<Alt-Tab> between elements  | <Space> selects | <F12> next screen

* Welcome to CentOS

+—————————–+ Warning +——————————+
|                                                                      |
| /dev/xvda currently has a loop partition layout.  To use this disk   |
| for the installation of CentOS, it must be re-initialized, causing   |
| the loss of ALL DATA on this drive.                                  |
|                                                                      |
| Would you like to format this drive?                                 |
|                                                                      |
|         +————–+                  +————–+           |
|         | Ignore drive |                  | Format drive |           |
|         +————–+                  +————–+           |
|                                                                      |
|                                                                      |
+———————————————————————-+

<Tab>/<Alt-Tab> between elements   |  <Space> selects   |  <F12> next screen

* Welcome to CentOS

+————————-+ Partitioning Type +————————-+
|                                                                       |
|    Installation requires partitioning of your hard drive.  The        |
|    default layout is reasonable for most users.  You can either       |
|    choose to use this or create your own.                             |
|                                                                       |
| Remove all partitions on selected drives and create default layout.   |
| Remove linux partitions on selected drives and create default layout. |
| Use free space on selected drives and create default layout.          |
| Create custom layout.                                                 |
|                                                                       |
|       Which drive(s) do you want to use for this installation?        |
|                              [*] xvda ^                               |
|                                       #                               |
|                                                                       |
|                          +—-+   +——+                            |
|                          | OK |   | Back |                            |
|                          +—-+   +——+                            |
|                                                                       |
|                                                                       |
+———————————————————————–+

<Space>,<+>,<-> selection   |   <F2> Add drive   |   <F12> next screen

* Welcome to CentOS

+—————————-+ Partitioning +—————————-+
|                                                                        |
|      Device        Start    End     Size       Type     Mount Point    |
| /dev/xvda                                                            ^ |
|   Free space            1    1045    8192M  Free space               # |
|                                                                      : |
|                                                                      : |
|                                                                      : |
|                                                                      : |
|                                                                      : |
|                                                                      : |
|                                                                      : |
|                                                                      v |
|                                                                        |
|    +—–+   +——+   +——–+   +——+   +—-+   +——+      |
|    | New |   | Edit |   | Delete |   | RAID |   | OK |   | Back |      |
|    +—–+   +——+   +——–+   +——+   +—-+   +——+      |
|                                                                        |
|                                                                        |
+————————————————————————+

F1-Help     F2-New      F3-Edit   F4-Delete    F5-Reset    F12-OK

* Welcome to CentOS

+—————————-+ Partitioning +—————————-+
|                                                                        |
|      Device        Start    End     Size       Type     Mount Point    |
| /dev/xvda                                                            ^ |
|   xvda1                 1     829    6502M  ext3        /            # |
|   xvda2               830     893     502M  swap                     : |
|   Free space          894    1044    1184M  Free space               : |
|                                                                      : |
|                                                                      : |
|                                                                      : |
|                                                                      : |
|                                                                      : |
|                                                                      v |
|                                                                        |
|    +—–+   +——+   +——–+   +——+   +—-+   +——+      |
|    | New |   | Edit |   | Delete |   | RAID |   | OK |   | Back |      |
|    +—–+   +——+   +——–+   +——+   +—-+   +——+      |
|                                                                        |
|                                                                        |
+————————————————————————+

F1-Help     F2-New      F3-Edit   F4-Delete    F5-Reset    F12-OK


* Same way configure TZ,root password,packages,boot loader options etc…

* Welcome to CentOS

+———————+ Formatting +———————-+
|                                                         |
| Formatting / file system…                             |
|                                                         |
|                           70%                           |
|                                                         |
+———————————————————+

<Tab>/<Alt-Tab> between elements   |  <Space> selects   |  <F12> next screen

That’s it!

Thank you,
Arun Bagul