HostOnNet Blog

lvcreate – Create a logical volume

lvcreate command is used to create logical volume.

To create a logical volume with disk size 10 GB inside volume group vg1, run

lvcreate --size 20G --name LV-NAME-HERE VG-NAME-HERE

First lets list all logical volumes on our server with command “lvs”.

[root@hon ~]# lvs
  LV         VG   Attr       LSize  Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
  kvm101_img vg1  -wi-a----- 33.00g                                                    
  kvm102_img vg1  -wi-a----- 50.00g                                                    
  kvm103_img vg1  -wi-a----- 20.00g                                                    
[root@hon ~]# 

Now create a logical volume with size 20 GB, name testlv1 inside volume group vg1.

[root@hon ~]# lvcreate --size 20G --name testlv1 vg1
  Logical volume "testlv1" created.
[root@hon ~]# 

Let verify the logical volume created with lvs command.

[root@hon ~]# lvs
  LV         VG   Attr       LSize  Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
  kvm101_img vg1  -wi-a----- 33.00g                                                    
  kvm102_img vg1  -wi-a----- 50.00g                                                    
  kvm103_img vg1  -wi-a----- 20.00g                                                    
  testlv1    vg1  -wi-a----- 20.00g                                                    
[root@hon ~]# 

lvdisplay

You can also use lvdisplay command to list logical volumes.

[root@hon ~]# lvdisplay vg1/testlv1
  --- Logical volume ---
  LV Path                /dev/vg1/testlv1
  LV Name                testlv1
  VG Name                vg1
  LV UUID                W0yUvI-wpQz-TfJR-aCko-Gk98-oyPD-SIDSo4
  LV Write Access        read/write
  LV Creation host, time hon.hostonnet.com, 2017-09-02 20:53:55 -0700
  LV Status              available
  # open                 0
  LV Size                20.00 GiB
  Current LE             5120
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:3
   
[root@hon ~]#

To delete a logical volume use command lvremove


Posted in Linux