LINUX – LEARN HOW TO MERGE 2 VG INTO 1

In this post we will learn how to merge two vg ( volume group ) into one . This is one of best trick to increase size of vg ( volume group ) .

merge 2 vg into one

  • First i’m going to create partition
[root@3usageeks ~]# fdisk /dev/sda
The number of cylinders for this disk is set to 68514.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
   (e.g., DOS FDISK, OS/2 FDISK)

Command (m for help): n
Command action
   l   logical (5 or over)
   p   primary partition (1-4)
l
First cylinder (57368-68514, default 57368):
Using default value 57368
Last cylinder or +size or +sizeM or +sizeK (57368-68514, default 68514): +1000M

Command (m for help): n
Command action
   l   logical (5 or over)
   p   primary partition (1-4)
l
First cylinder (57491-68514, default 57491):
Using default value 57491
Last cylinder or +size or +sizeM or +sizeK (57491-68514, default 68514): +1000M

Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
WARNING: Re-reading the partition table failed with error 16: Device or resource busy.
The kernel still uses the old table.
The new table will be used at the next reboot.
Syncing disks.
  • Mandatory – run partprobe command to save all changes made
[root@3usageeks ~]# partprobe /dev/sda
  • I have created two partition one is sda5 and other one is sda6
  • First i’m going to convert sda5 partition into physical volumes .
[root@3usageeks ~]# pvcreate /dev/sda5
  Physical volume "/dev/sda5" successfully created
  • Now create vg (volume group ) over this physical volume .
[root@3usageeks ~]# vgcreate vg22 /dev/sda5
  Volume group "vg22" successfully created
  • Time for second one .( sda 6)
  • Convert into pv ( physical volume )
[root@3usageeks ~]# pvcreate /dev/sda6
  Physical volume "/dev/sda6" successfully created
  • Then create vg ( volume group ) over this physical volume
[root@3usageeks ~]# vgcreate vg55 /dev/sda6
  Volume group "vg55" successfully created
  • Check volume group in your system through vgs command
[root@3usageeks ~]# vgs
  VG   #PV #LV #SN Attr   VSize   VFree
  vg22   1   0   0 wz--n- 964.00M 964.00M
  vg55   1   0   0 wz--n- 964.00M 964.00M
  • Now i’m going to merge vg22 into vg55
  • To type = vgmerge     -v       vg you want to keep      vg you want to merge into   
[root@3usageeks ~]# vgmerge -v vg55 vg22
    Checking for volume group "vg55"
    Checking for volume group "vg22"
    Archiving volume group "vg22" metadata (seqno 1).
    Archiving volume group "vg55" metadata (seqno 1).
    Writing out updated volume group
    Creating volume group backup "/etc/lvm/backup/vg55" (seqno 2).
  Volume group "vg22" successfully merged into "vg55"
  • Check by vgs command
  • Now you can see only vg55 is there .
[root@3usageeks ~]# vgs
  VG   #PV #LV #SN Attr   VSize VFree
  vg55   2   0   0 wz--n- 1.88G 1.88G

 

 

 

 

 

 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s