Tag Archives: vgdisplay

lvremove to remove logical volume from LVG

How to create spare Logical volume partition in linux server

We had a default install of

 

Screenshot from 2015-06-25 22:06:22

[root@SRV-01 ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/vg_srv01-lv_root
50G 2.6G 45G 6% /
tmpfs 7.8G 0 7.8G 0% /dev/shm
/dev/sda1 477M 67M 385M 15% /boot
/dev/mapper/vg_srv01-lv_home
860G 72M 816G 1% /home

As KVM virtualization need spare LVM to create vps on we had to free /home partition which has no data in it

So the process starts

#Using vgdisplay check the VG present

[root@SRV-01 ~]# vgdisplay
— Volume group —
VG Name vg_srv01
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 4
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 3
Open LV 3
Max PV 0
Cur PV 1
Act PV 1
VG Size 931.02 GiB
PE Size 4.00 MiB
Total PE 238341
Alloc PE / Size 238341 / 931.02 GiB
Free PE / Size 0 / 0
VG UUID tBHSEL-UIHM-OMbu-9KWk-ZTW9-97j5-UzwQDl
#lvscan to check the LVM name

[root@SRV-01 ~]# lvscan
ACTIVE ‘/dev/vg_srv01/lv_root’ [50.00 GiB] inherit
ACTIVE ‘/dev/vg_srv01/lv_home’ [873.17 GiB] inherit
ACTIVE ‘/dev/vg_srv01/lv_swap’ [7.85 GiB] inherit

Before removing the Logical volume partition need to unmount it  else you get below error

[root@SRV-01 ~]# lvremove /dev/vg_srv01/lv_home
Logical volume vg_srv01/lv_home contains a filesystem in use.

 

So unmounted /home which has  /dev/vg_srv01/lv_home

[root@SRV-01 ~]# umount /home/

 

Now removed the logical volume using lvremove

[root@SRV-01 ~]# lvremove /dev/vg_srv01/lv_home
Do you really want to remove active logical volume lv_home? [y/n]: y
Logical volume “lv_home” successfully removed

Now /home  alias  /dev/vg_srv01/lv_home is free to create  VM on it

[root@SRV-01 ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/vg_srv01-lv_root
50G 2.6G 45G 6% /
tmpfs 7.8G 0 7.8G 0% /dev/shm
/dev/sda1 477M 67M 385M 15% /boot