Virtual machines on Linux can be created both from the console or by using the control panels. Let's compare these ways and decide the most convenient one.
System administrators of the SMB companies choose the console, while hosting providers prefer the panels.
Administrators choose the console because they don’t have a lot of tasks for VPS management so they prefer to handle them manually rather than learning to use an additional tool. And because they can, obviously. Providers prefer the panels because they deal with hundreds and thousands of VMs so they want to automate everything they can and accelerate solving other routine tasks.
However if an admin from SMB company will face more tasks related with virtualization, they’ll need more VMs for testing needs, debugging, for hosting new websites. In this case the console may become inconvenient for them.
Let’s check how the panel may boost the work on routine tasks: VM creation, migration, and further management.
VM creation
Let's start from the basic task and create a virtual machine. At first we’ll create it from the console and then try to do the same from VMmanager
The console
We will use Ubuntu OS, because it supports KVM hypervisor. Libvirt library will be used for a hypervisor management and virsh utility for management the system.
At first we will prepare the tools for virtualization, and then we will start creating our first virtual machine. We use the console to install KVM, check the hardware virtualization supportt in Ubuntu, and install the packets for working with KVM and libvirt.
After that it we proceed with creating the first virtual machine — 64-bit Ubuntu 18.04.3 LTS (Bionic Beaver).
At first we download an ISO image:
cd /var/lib/libvirt/boot
sudo wget http://releases.ubuntu.com/18.04.3/ubuntu-18.04.3-desktop-amd64.iso
Then we start installation with the server configuration we need:
sudo virt-install \
--virt-type=kvm \
--name testvps\
--ram 2048 \
--vcpus=2 \
--os-variant=ubuntu16.04 \
--hvm \
--cdrom=/var/lib/libvirt/boot/ubuntu-16.04.1-server-amd64.iso \
--network network=default,model=virtio \
--graphics vnc \
--disk path=/var/lib/libvirt/images/ubuntu1604.img,size=50,bus=virt
As a result we get Ubuntu virtual server with 2GB RAM, 2 CPU, a standard network interface card and 50 GB HDD.
With VMmanager 6
Now we will create the virtual machine with VMmanager 6. VMmanager supports KVM virtualization and uses libvirt library for VM management. QEMU hypervisor does server emulation so every VM is provided with the virtual equipment.
In VMmanager the process of creating VMs is automated. Users should take only three steps in a simple interface:
- Press Create VM button on the main page.
- Choose VPS configuration.
- Start installation.
- All done! You are breathtaking!
Users can use pre-configured templates of servers with the needed OS and recipes for automatic installation of other software. Custom disk images allow them to create virtual machines quickly.
VM Management
When a virtual server is created, it’s necessary to manage it.
The console
We will use the same virsh utility to manage virtual machine from the console.Here is the list of main commands:
Список основных команд:
|help | Quick Reference.|
|list | View all virtual machines. |
|start | Start an inactive virtual machine.|
|destroy | Forced shut down of the chosen VM.|
|reboot | Reboot the virtual machine.|
|restore | Restore a saved virtual machine.|
|resume | Resume the suspended virtual machine.|
|save | Save the condition of the virtual machine as a file.|
|shutdown | Safe shut down the virtual machine.|
|suspend | Suspend the virtual machine.|
|undefine | Delete all files of virtual machine.|
For example, to reboot a virtual machine, you need to enter the following command:sudo virsh reboot testvps
With VMmanager 6
VMmanager allows managing virtual machines, reinstalling OS, managing virtual disks, network interfaces, and performing many other operations right from the interface.
If you have many virtual servers, you can easily find active, disabled and suspended machines. Every server has an information about the owner, IP address, installed OS and configuration.
VMmanager 6 supports group operations for multiple servers. You can start, reboot and shut these servers down with a couple of clicks. It saves a lot of time for admins if they manage more than two servers.
VM migration
The console
When you create a cluster of several servers, sometimes you need to move virtual machine disks between the nodes. This process is usually called migration.
In order to move the VM to another node from the console, it’s necessary to make sure that the following conditions are obeyed:
- There is an available disk on the destination node with the same volume as the disk of VM we want to move.
- Both nodes must have the same network configuration and bridge name.
- Nodes must resolve each other by HOSTnames.
- Both nodes should communicate with each other by ssh without asking a password.
- All disk images used by the virtual machine must be migrated to the new node with the same path.
If these conditions are obeyed, it is possible to migrate the virtual machine with a single command. It’s necessary to specify the name of the VM and node, the parameters of the migration.
sudo virsh migrate –live testvps qemu+ssh://root@node2/system –copy-storage-all
This is how we migrated the test VM to the node2 with a full disk transfer.
With VMmanager 6
In VMmanager the migration is made through libvirt. For migrating the VM in the panel, you just need to specify a new host and choose the live migration option, if necessary:
The console or VMmanager 6
VMmanager simplifies VM creation, management, migration and allows to automate VPS provisioning. As your infrastructure grows, VMmanager can manage all clusters, nodes and every particular VM from the single interface and provide flexible tools for monitoring the system and collecting statistics.