As the other article shows how to view existing Logical Volume in a host, workstation or server which has an LVM (Logical Volume Management) installed, titled ‘Using lvs Command to Display Logical Volume Information‘, this article focus on showing how to create the Logical Volume and it is performed in a bash prompt which is the command line interface to type the command for creating logical volume.
But first of all, to be able to create a logical volume, there is a need of an existing volume group.
Below is the command used to create logical volume :
lvcreate -L xx[B,S,K,M,G,T,P,E] -n logical_volume_name volume_group_name Description : lvcreate : It is the command used to create logical volume. -L : It is an additional parameter used to specify the size of the newly created logical volume. xx[B,S,K,M,G,T,P,E] : The xx represent number of the size which is allocated to create the new logical volume. B for Bytes, S for Sector, K for Kilobytes, M for Megabytes, G for Gigabytes, T for Terabytes, P for Petabytes and the last E for Exabytes. Those are the measurement character used to define the size of the new logical volume. -n : It is an additional parameter used to specify the name of the newly created logical volume. logical_volume_name : The name of the newly created logical volume. volume_group_name : The name of the volume group used to store the newly created logical volume.
Below is the execution of the command in real situation for an example :
[root@hostname ~]# lvcreate -L 100G -n mylogical-volume-dbdev fc_vms WARNING: dos signature detected on /dev/fc_vms/mylogical-volume-dbdev at offset 510. Wipe it? [y/n]: y Wiping dos signature on /dev/fc_vms/mylogical-volume-dbdev. Logical volume "mylogical-volume-dbdev" created. [root@hostname ~]#
After successfully create the logical volume, below is the command which can be used to view the newly created logical volume :
[root@hostname ~]# lvs LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert root centos_noc01 -wi-ao---- 50.00g swap centos_noc01 -wi-ao---- 64.00g tmp centos_noc01 -wi-ao---- 2.00g var centos_noc01 -wi-ao---- 50.00g var_log centos_noc01 -wi-ao---- 5.00g var_log_audit centos_noc01 -wi-ao---- 5.00g mylogical-volume-centos7 fc_vms -wi-a----- 20.00g mylogical-volume-dbdev fc_vms -wi-ao---- 100.00g mylogical-volume-tester fc_vms -wi-a----- 800.00g mylogical-volume-appdev fc_vms -wi-ao---- 20.00g mylogical-volume-db fc_vms -wi-ao---- 120.00g mylogical-volume-linux-repo fc_vms -wi-ao---- 200.00g mylogical-volume-app fc_vms -wi-ao---- 120.00g mylogical-volume-win2008r2local_vms -wi-ao---- 40.00g
As shown above, it can be seen that there is a newly created logical volume with the name of mylogical-volume-dbdev with the size of 100G as defined and executed with the previous ‘lvcreate’ command.
One thought on “Using lvcreate to Create Logical Volume via Command Line”