Thursday 29 March 2012

LVM Volume Group Export and Import

Before we start with the step by step process lets us know what vgexport, vgimport do:-

vgexport :- Removes a volume group from the system without modifying the information found on the physical volume(s).
vgimport :-

Adds a volume group to the system by scanning physical volumes which have been exported using vgexport.

Steps to Export volume group

1. Unmount file system

#umount /u01

2. Deactivate the Volume Group

#vgchange –a n vg02

Volume group "vg02" has been successfully changed.

3. Remove Entry from /etc/fstab file for this mount point

4. Export Volume Group to a map file

#vgexport –s –v –m /tmp/vg02.map /dev/vg02

Beginning the export process on Volume Group "/dev/vg02". /dev/dsk/c0t1d0 vgexport:Volume Group “/dev/vg02” has been successfully removed.

5. Copy the Map file to the destination server with scp, rcp, pen drive or any other method, we here use scp to transfer file

#scp /tmp/vg02.map username@other_server_ip:/tmp/

Steps to Import Volume Group

1. Make a directory in /dev for volume group and change owner as root and group as sys

#mkdir /dev/vg02

#chown root:sys /dev/vg02

#chmod 755 /dev/vg02

2. Select a unique minor number for the VG:

# ll /dev/*/group

crw-r--r-- 1 root sys 64 0x000000 Apr 4 2010 /dev/vg00/group crw-r--r-- 1 root sys 64 0x010000 Oct 26 15:52 /dev/vg01/group

 

Create the VG control file (group file):

#mknod /dev/vg01/group c 64 0x020000

3. Import the Map file with vgimport command

#vgimport –s –m /tmp/vg02.map /dev/vg02

vgimport: Volume group "/dev/vg02" has been successfully created. Warning: A backup of this volume group may not exist on this machine. Please remember to take a backup using the vgcfgbackup command after activating the volume group.

4. Activate Volume Group

#vgchange –a y /dev/vg02

Activated volume group Volume group "/dev/vg02" has been successfully changed.

5. Make entry in /etc/fstab file to make mount point permanent between reboots.

6. Mount file system

#mkdir data

#mount /dev/vg02/lvol1 /data