How to activate volume group in linux

Activating-and-Deactivating-volume-groups_840x268

In this post, we are going to discuss how to activate volume group in linux and how to deactivate volume group in linux. When we create a new volume group by default it gets activated during creation so we can access all the logical volumes inside the volume group and able to mount and start using in Linux.

A scenario like if this volume group is of replicated category and you have to perform DR you need to deactivate the volume group from currently active production server and need to activate the volume group once you failover to DR and ready to mount the file system on DR as part of your activity in Linux.

We are sharing here how you can deactivate the volume group and reactivate it. Your scenario may be different but commands still will be relevant.

There will be two scenarios either you want to deactivate all the LV in the system or particular as there may not be all the file systems on the server is replicated. It may have a few non replicated file systems lying on non-replicated storage.

Activate and Deactivate Volume Group LINUX

If you want to activate system-wide – all VG including all LV in the system. vgchange command in linux is the command-line tool that can be used for activating and deactivating VG in linux basically vgchange command in linux is used for changing the parameter of the volume group.

For example how to change the maximum number of the logical volume in VG.

# vgchange -l 128 /dev/loc_pcr-dg

This will change the maximum number of logical volumes in VG to 128.

vgchange command in Linux

# vgchange -a y              How to activate volume group in linux 
# vgchange -a n              How to deactivate volume group in linux

Activating and Deactivating Volume Group in Linux

If you want to activate a specific volume group-wise  – all VG including all LV in the system.

# vgchange -a y <vg> How to Activate Volume Group in Linux
# vgchange -a n <vg> How to Deactivate Volume Group in Linux

That’s it about how to activate volume group in linux and how to deactivate volume group in linux. Please have a look at other Redhat Linux related topics of your interest.

Let me add some bonus to it.

How to check VG is active or not in Linux

vgdisplay command in linux is used to display all the properties of the VG like Size, extents, number of physical volumes, etc. Please find below the sample output for your review. Using the vgdisplay command in linux you can see the VG Size and also you can find how much space is available in VG or you can say how much free space available in VG.
# vgdisplay
--- Volume group ---
VG Name               loc_pcr-dg
System ID
Format                lvm2
Metadata Areas        2
Metadata Sequence No  5
VG Access             read/write
VG Status             resizable
MAX LV                0
Cur LV                3
Open LV               3
Max PV                0
Cur PV                2
Act PV                2
VG Size               59.99 GiB
PE Size               4.00 MiB
Total PE              15358
Alloc PE / Size       15358 / 59.99 GiB
Free  PE / Size       0 / 0
VG UUID               9qU82L-Q6ZA-afvW-s8fi-zeRK-hRAp-gXJEYa

Another command-line tool is vgs command in linux is also very handy to understand the VG status. Attr here is showing wz–n- where w stands for writable and z stands for Resizable and n is allocation policy which is normal. You can refer to the vgs man page for more details on the Attribute value referred here. Oh, we were close but still, we missed it information we are looking for.

# vgs
VG           #PV #LV #SN Attr   VSize     VFree
loc_pcr-dg   2   3   0   wz--n- 59.99g    0
So now it is our turn to find a real answer to the main bonus question of how to check VG is active or not in Linux. In this case, the lvs command in linux is really handy and it can reveal the information we are looking for. It will display all the logical volumes as well as associated VG name with Attr which is called Attributes as we have seen in vgs command in linux but it will have details on what we are looking for. So let’s see.
# lvs
LV          VG                Attr         LSize    
pc          loc_pcr-dg        -wi-ao----   1020.00m
pcr         loc_pcr-dg        -wi-ao----   20.00g
pcr1        loc_pcr-dg        -wi-ao----   39.00g
OK. Attribute value here is -wi-ao—- where w stands for (w)writeable i stands for (i)inherited a represents state which shows (a)active o stands for (o)open.
So if you see a in attributes it means your VG is active. Other State parameters are as below.
State: (a)active, (h)historical, (s)suspended, (I)invalid snapshot, invalid (S)suspended snapshot, snapshot (m)merge failed, suspended snapshot (M)erge failed, mapped (d)device present without tables, mapped device present with (i)inactive table, thin-pool (c)heck needed, suspended thin-pool (C)heck needed, (X) unknown
That`s it about how to check VG is active or not in Linux. I hope you will find it helpful. Please like and subscribe to our blog to get noticed immediately about our latest article whenever published.
Other Similar Articles you may like…