Virtualization is a technology that allows multiple operating systems to run simultaneously on a single physical hardware by utilizing a hypervisor.
KVM (Kernel-based Virtual Machine): A kernel-based hypervisor for Linux that leverages hardware virtualization capabilities like Intel VT-x and AMD-V.
Xen: An open-source hypervisor that supports full virtualization and paravirtualization.
Make sure the CPU supports hardware virtualization:
egrep -c '(vmx|svm)' /proc/cpuinfo
Ensure virtualization is enabled in BIOS/UEFI.
Install KVM packages:
sudo zypper install qemu-kvm libvirt virt-manager
Enable and start the libvirt service:
sudo systemctl enable libvirtd
sudo systemctl start libvirtd
Use virt-manager or the CLI command:
virt-install \
--name vm_name \
--ram 2048 \
--vcpus 2 \
--disk path=/var/lib/libvirt/images/vm_name.qcow2,size=20 \
--os-type linux \
--os-variant ubuntu20.04 \
--cdrom /path/to/iso
Libvirt is a library and toolset for managing hypervisors such as KVM and Xen. The main CLI tool is virsh.
List all VMs:
virsh list –all
Start a VM:
virsh start vm_name
Shut down a VM:
virsh shutdown vm_name
Remove a VM:
virsh undefine vm_name
View VM information:
virsh dominfo vm_name
Virt-manager is a GUI tool for managing VMs.
Run virt-manager:
virt-manager
Main features:
Create, delete, and manage VMs.
View VM consoles.
Configure resources like CPU, RAM, and networking.
Docker is a containerization platform that allows applications to run in isolated environments.
Add the repositori Docker:
sudo zypper addrepo https://download.docker.com/linux/sles/docker-ce.repo
Install Docker:
sudo zypper install docker-ce
Enable and start the Docker service:
sudo systemctl enable docker
sudo systemctl start docker
Verify the installation:
docker –version
Run a container:
docker run -d -p 80:80 nginx
View running containers:
docker ps
Stop a container:
docker stop container_id
Remove a container:
docker rm container_id
Download an image:
docker pull image_name
Build an image from a Dockerfile:
docker build -t image_name .
Docker Compose is a tool for managing multi-container applications.
Install Docker Compose:
sudo zypper install docker-compose
Example docker-compose.yml file:
version: '3'
services:
web:
image: nginx
ports:
- "80:80"
db:
image: mysql
environment:
MYSQL_ROOT_PASSWORD: password
Run the application:
docker-compose up -d