Moving Volume Group to Another System - LVM Version 2



It is quite easy to move a whole EXT4 volume group to another system. To do this we use the vgexport and vgimport commands.

vgexport/vgimport is not necessary to move drives from one system to another. It is an administrative policy tool to prevent access to volumes in the time it takes to move them.

Assume that we are removing the volume group from host1 and then this will attach to host2. We will follow the steps below to work with two volumes group “media” and “staging” in this document.

Unmount the file system from Host1
First, make sure that no users are accessing files on the active volume, then unmount it

host1# umount /nfs/media
host1# umount /nfs/staging
         

Mark the volume group inactive
Marking the volume group inactive removes it from the kernel and prevents any further activity on it.

host1# vgchange –v -an media
volume group "media" successfully deactivated
         
host1# vgchange –v -an staging
volume group "staging" successfully deactivated

Export the volume group
It is now necessary to export the volume group. This prevents it from being accessed on the ``old'' host system and prepares it to be removed.

host1# vgexport media
vgexport -- volume group "design" successfully exported

host1# vgexport staging
vgexport -- volume group "staging" successfully exported


         
When the machine is next shut down, the disk can be unplugged and then connected to it's new machine

Import the volume group into Host 2
When plugged into the new system it becomes /dev/sd* so an initial fdisk/pvscan shows:
host2#fdsik –l
Disk /dev/sdd: 30000.6 GB, 30000556277760 bytes
255 heads, 63 sectors/track, 3647359 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

   Device Boot      Start         End      Blocks   Id  System
/dev/sdd1               1      267350  2147483647+  ee  GPT

WARNING: GPT (GUID Partition Table) detected on '/dev/sde'! The util fdisk doesn't support GPT. Use GNU Parted.


Disk /dev/sde: 21992.7 GB, 21992691466240 bytes
255 heads, 63 sectors/track, 2673792 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000


fdisk will show you the attached volume group with detail information including the space by which we can make sure that the volume group is recognizable by host2. After that we can use pvscan to let lvm finds the group.


host2# pvscan
[root@nasgateway ~]# pvscan
  PV /dev/mapper/mpathbp1   VG staging         lvm2 [20.01 TiB / 9.09 GiB free]
  PV /dev/sda5              VG vg_nasgateway   lvm2 [276.34 GiB / 0    free]
  PV /dev/mapper/mpathcp1   VG media           lvm2 [20.00 TiB / 2.29 GiB free]
  Total: 3 [40.28 TiB] / in use: 3 [40.28 TiB] / in no VG: 0 [0   ]

We can now import the volume group (which also activates it) and mount the file system.
If you are importing on an LVM 2 system, run: 


host2# vgimport media
  Volume group "media" successfully imported

host2# vgimport staging
  Volume group "staging" successfully imported

         

Activate the volume group

You must activate the volume group before you can access it.

host2# vgchange –v -ay media
host2# vgchange –v -ay staging
         

Mount the file system


host2# mkdir -p /nfs/media
host2# mkdir –p /nfs/staging

Run fdisk command to know the mouting file can be used, if volume groume group is created through lvm then it should show like this:


host2#fdisk –l
Disk /dev/mapper/media-lv_media: 21990.2 GB, 21990232555520 bytes
255 heads, 63 sectors/track, 2673493 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000


Disk /dev/mapper/staging-lv_staging: 21990.2 GB, 21990232555520 bytes
255 heads, 63 sectors/track, 2673493 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes


host2# mount /dev/mapper/media-lv_media  /nfs/media
host2# mount /dev/mapper/media-lv_media /nfs/media
          


Edit the fstab file for boot mounting:
Append the following two lines in fstab file and then run the mount command to manually mount from fstab file:

host2#vi /etc/fstab

/dev/mapper/media-lv_media /nfs/media                   ext4    defaults        0 0
/dev/mapper/staging-lv_staging /nfs/staging             ext4    defaults        0 0     

host2#mount –a
Filesystem            Size  Used Avail Use% Mounted on

/dev/mapper/media-lv_media
                       20T  5.3G   19T   1% /nfs/media
/dev/mapper/staging-lv_staging
                       20T  5.3G   19T   1% /nfs/staging   

Comments

  1. Great website. Lots of useful info here. I'm sending it to a few friends ans also sharing in delicious. And obviously, thank you on your sweat!

    Review my site :: pozycjonowanie

    ReplyDelete
  2. This kind of training is remarkably strict and systematic.
    Certain is the acquire to do a specific product so others has the ability to see what you
    could have done.

    Also visit my web-site pobierowo

    ReplyDelete
  3. It can be accomplished online, whether you are in Bangkok, Pattaya, Chiangmai or Phuket.
    They experimented and specifically created Jawi script by
    analyzing Arabic.

    Stop by my webpage: pobierowo

    ReplyDelete

Post a Comment

Popular Posts