This is an article which is discussing about how to create a Logical Volume which is going to be utilized for the sake of a Guest Machine or a Virtual Server created from an utility such as ‘libvirt’.
Scenario : Having created a Guest Machine based on Ubuntu Linux 16.04 as a baseline template for other Guest Machine which is selected to run with Ubuntu Linux 16.04, below is how to assign those images representing the already installed Guest Machine with Ubuntu Linux 16.04 so that the other new created Guest Machine can be executed and can be directly operated without having to install or to perform the installation step from the beginning. Below are the steps for achieving the scenario :
1. Creating a new Logical Volume which will become the base of the hard disk to be used with the new created Guest Machine. The syntax for creating a Logical Volume is shown as below :
lvcreate -L size -n logical_volume_name logical_volume_group_name
This is the execution of the command in the real situation :
[root@hostname images]# lvcreate -L 80G -n myserver-ubuntu fc_vms Logical volume "myserver-ubuntu" created. [root@hostname images]#
2. Select that logical volume to be attached with the creation of a new Guest Machine. It can be executed in the Webvirt or any other mechanism for creating a new one. Install Ubuntu Linux operating system in that new created Guest Machine.
3. Create another Guest Machine which is intended to be utilized further :
[root@hostname images]# lvcreate -L 80G -n ubuntu-server01 fc_vms Logical volume "ubuntu-server01" created. [root@hostname images]#
4. After creating a new Guest Machine image which is in the form of a Logical Volume, execute the following syntax. This is a syntax although it is meant to resize from the logical volume to another, but it can be used to copy the image so that the Ubuntu installation which has already done in the first logical volume can be duplicate in the other logical volume.
virt-resize logical_volume_1 logical_volume_2
The execution of the above syntax is shown below to follow the scenario described above :
virt-resize /dev/fc_vms/myserver-ubuntu /dev/fc_vms/ubuntu-server01
This is the process of the execution in a real situation :
[root@hostname images]# virt-resize /dev/fc_vms/myserver-ubuntu /dev/fc_vms/ubuntu-server01 [ 0.0] Examining /dev/fc_vms/myserver-ubuntu ◓ 25% ⟦▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒═══════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════⟧ --:-- 100% ⟦▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒⟧ 00:00 ********** Summary of changes: /dev/sda1: This partition will be left alone. /dev/sda2: This partition will be left alone. There is a surplus of 799.0K. The surplus space is not large enough for an extra partition to be created and so it will just be ignored. ********** [ 56.6] Setting up initial partition table on /dev/fc_vms/ubuntu-server01 [ 57.1] Copying /dev/sda1 100% ⟦▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒⟧ 00:00 [ 60.9] Copying /dev/sda2 100% ⟦▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒⟧ 00:00 Resize operation completed with no errors. Before deleting the old disk, carefully check that the resized disk boots and works correctly. [root@hostname images]#
The above newly created Logical Volume named ‘ubuntu-server01’ can be directly attached to the newly created Guest Machine. Turn and run it off, it will can be booted as the same output run with the Guest Machine attached with the Logical Volume named ‘myserver-ubuntu’.