6.4 Exporting and Importing Volume Groups

     

Most people associate exporting and importing volume groups with the process of sharing volume groups between machines (a common task in a high-availability Serviceguard cluster). However, it is a good policy to keep a mapfile representing the configuration of each of your volume groups. In the event that you have to reinstall the operating system, your new OS disk will know nothing of the LVM structures on your data disks. With the mapfile (s), you will be able to import the LVM structures stored on your data disks, recreating the volume groups as they were configured before you had to reinstall the operating system. Let's look at an example of creating the mapfile :

 

 root@hpeos003[]  vgexport -m /etc/lvmconf/vgora1.map -p /dev/vgora1  vgexport: Volume group "/dev/vgora1" is still active. root@hpeos003[]  cat /etc/lvmconf/vgora1.map  1 db 2 stripy 3 Dstripe 4 Kstripe root@hpeos003[] root@hpeos003[]  strings /etc/lvmtab  /dev/vg00 /dev/dsk/c1t15d0 /dev/dsk/c3t15d0 /dev/vgora1 /dev/dsk/c0t1d0 /dev/dsk/c0t2d0 /dev/dsk/c0t3d0 /dev/dsk/c4t9d0 /dev/dsk/c4t10d0 /dev/dsk/c5t1d0 /dev/dsk/c5t2d0 /dev/dsk/c5t3d0 /dev/dsk/c4t11d0 root@hpeos003[] 

When we want to create a mapfile for our volume group, we use the preview option (-p ) to vgexport . This does not remove the volume group from the /etc/lvmtab files. As you can see, the content of the mapfile is simple ”a number followed by a name . In this way, when we import the volume group, LVM knows which extents belong to which logical volume. In the VGRA is an extent map for that particular disk. Marked against an individual extent is the logical volume number to which it belongs. In this way, when vgimport recreates the device files under the /dev/vgX directory, it knows (1) how many device files to create and (2) what to call those device files. Without a mapfile, vgimport would simply call the device files (and hence the logical volumes ), lvol1 , lvol2 , lvol3 , etc. This is not catastrophic, but it does mean that we have a bit more investigating to do to work out which logical volume contains which information. Here I will actually remove the volume group from this system. (Notice that there is no entry in /etc/lvmtab , and all device files pertaining to the volume group have been deleted.) For vgexport to work, no filesystems, swap, or dump devices can be open , and the volume group must be deactivated:

 

 root@hpeos003[]  vgchange -a n /dev/vgora1  Volume group "/dev/vgora1" has been successfully changed. root@hpeos003[]  vgexport -m /etc/lvmconf/vgora1.map -s /dev/vgora1  Physical volume "/dev/dsk/c0t1d0" has been successfully deleted from physical volume group "PVG0". Physical volume "/dev/dsk/c0t2d0" has been successfully deleted from physical volume group "PVG0". Physical volume "/dev/dsk/c0t3d0" has been successfully deleted from physical volume group "PVG0". Physical volume "/dev/dsk/c4t9d0" has been successfully deleted from physical volume group "PVG1". Physical volume "/dev/dsk/c4t10d0" has been successfully deleted from physical volume group "PVG1". Physical volume "/dev/dsk/c4t11d0" has been successfully deleted from physical volume group "PVG1". root@hpeos003[] root@hpeos003[]  strings /etc/lvmtab  /dev/vg00 /dev/dsk/c1t15d0 /dev/dsk/c3t15d0 root@hpeos003[]  ll /dev/vgora1  /dev/vgora1 not found root@hpeos003[] root@hpeos003[]  cat /etc/lvmconf/vgora1.map  VGID 355803d93f9fb09a 1 db 2 stripy 3 Dstripe 4 Kstripe root@hpeos003[] 

Notice that I have used the “s option on the vgexport command this time. This has stored the VGID of the volume group in the mapfile . This may be useful later when we import the volume group. I will now import the volume group. In this instance, I will call the volume group the same name, although this is technically not necessary.

 

 root@hpeos003[]  mkdir /dev/vgora1  root@hpeos003[]  mknod /dev/vgora1/group c 64 0x010000  root@hpeos003[] root@hpeos003[]  vgimport -m /etc/lvmconf/vgora1.map -s /dev/vgora1  root@hpeos003[] root@hpeos003[]  strings /etc/lvmtab  /dev/vg00 /dev/dsk/c1t15d0 /dev/dsk/c3t15d0 /dev/vgora1 /dev/dsk/c0t1d0 /dev/dsk/c0t2d0 /dev/dsk/c0t3d0 /dev/dsk/c4t9d0 /dev/dsk/c4t10d0 /dev/dsk/c4t11d0 /dev/dsk/c5t1d0 /dev/dsk/c5t2d0 /dev/dsk/c5t3d0 root@hpeos003[] root@hpeos003[]  ll /dev/vgora1  total 0 brw-r-----   1 root       sys         64 0x010003 Oct 30 19:12 Dstripe brw-r-----   1 root       sys         64 0x010004 Oct 30 19:12 Kstripe brw-r-----   1 root       sys         64 0x010001 Oct 30 19:12 db crw-rw-r--   1 root       sys         64 0x010000 Oct 30 19:11 group crw-r-----   1 root       sys         64 0x010003 Oct 30 19:12 rDstripe crw-r-----   1 root       sys         64 0x010004 Oct 30 19:12 rKstripe crw-r-----   1 root       sys         64 0x010001 Oct 30 19:12 rdb crw-r-----   1 root       sys         64 0x010002 Oct 30 19:12 rstripy brw-r-----   1 root       sys         64 0x010002 Oct 30 19:12 stripy root@hpeos003[] root@hpeos003[]  vgchange -a y /dev/vgora1  Activated volume group Volume group "/dev/vgora1" has been successfully changed. root@hpeos003[]  vgcfgbackup /dev/vgora1  Volume Group configuration for /dev/vgora1 has been saved in /etc/lvmconf/vgora1.conf root@hpeos003[] 

Notice that I used the “s option with the vgimport command. This is the scan option. When we exported the volume group, the “s option stored the VGID in the mapfile . When we imported the volume group, vgimport scanned every disk on the system for any disk that reported it had the same VGID as stored in the mapfile . This scan option sounds like a fantastic idea. In reality, if you have a large number of disks ( especially Fibre Channel disks), then the scan option can take a considerable amount of time to complete. If you decide not to use it, then you will need to list all of the disks belonging to the volume group on the command line.

 

 root@hpeos003[]  vgimport -m /etc/lvmconf/vgora1.map /dev/vgora1 /dev/dsk/c0t1d0 /dev/dsk graphics/ccc.gif /c0t2d0 /dev/dsk/c0t3d0 /dev/dsk/c4t9d0 /dev/dsk/c4t10d0 /dev/dsk/c4t11d0 /dev/dsk5t1d0 graphics/ccc.gif /dev/dsk/c5t2d0 /dev/dsk/c5t3d0  vgimport: Warning: Volume Group contains "6" PVs, "9" specified. Continuing. 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 graphics/ccc.gif group. root@hpeos003[] root@hpeos003[]  strings /etc/lvmtab  /dev/vg00 /dev/dsk/c1t15d0 /dev/dsk/c3t15d0 /dev/vgora1 /dev/dsk/c0t1d0 /dev/dsk/c0t2d0 /dev/dsk/c0t3d0 /dev/dsk/c4t9d0 /dev/dsk/c4t10d0 /dev/dsk/c4t11d0 /dev/dsk/c5t1d0 /dev/dsk/c5t2d0 /dev/dsk/c5t3d0 root@hpeos003[] root@hpeos003[]  vgchange -a y /dev/vgora1  Activated volume group Volume group "/dev/vgora1" has been successfully changed. root@hpeos003[]  vgcfgbackup /dev/vgora1  Volume Group configuration for /dev/vgora1 has been saved in /etc/lvmconf/vgora1.conf root@hpeos003[] 

As you can see, the Warning is simply a warning; vgimport has identified the Alternate PV Links. I have seen in some instances that the vgimport does not accept all of the Alternate PV Link disks listed on the command line. In such circumstances, you may have to add them to the volume group with vgextend :

 

 root@hpeos003[]  vgdisplay -v vgora1  --- Volume groups --- VG Name                     /dev/vgora1 VG Write Access             read/write VG Status                   available Max LV                      255 Cur LV                      4 Open LV                     4 Max PV                      16 Cur PV                      6 Act PV                      6 Max PE per PV               17501 VGDA                        12 PE Size (Mbytes)            4 Total PE                    104994 Alloc PE                    1700 Free PE                     103294 Total PVG                   0 Total Spare PVs             0 Total Spare PVs in use      0    --- Logical volumes ---    LV Name                     /dev/vgora1/db    LV Status                   available/syncd    LV Size (Mbytes)            1000    Current LE                  250    Allocated PE                500    Used PV                     2    LV Name                     /dev/vgora1/stripy    LV Status                   available/syncd    LV Size (Mbytes)            1200    Current LE                  300    Allocated PE                300    Used PV                     3    LV Name                     /dev/vgora1/Dstripe    LV Status                   available/syncd    LV Size (Mbytes)            1200    Current LE                  300    Allocated PE                600    Used PV                     6    LV Name                     /dev/vgora1/Kstripe    LV Status                   available/syncd    LV Size (Mbytes)            1200    Current LE                  300    Allocated PE                300    Used PV                     3    --- Physical volumes ---    PV Name                     /dev/dsk/c0t1d0    PV Name                     /dev/dsk/c5t1d0  Alternate Link    PV Status                   available    Total PE                    17499    Free PE                     16949    Autoswitch                  On    PV Name                     /dev/dsk/c0t2d0    PV Name                     /dev/dsk/c5t2d0  Alternate Link    PV Status                   available    Total PE                    17499    Free PE                     17199    Autoswitch                  On    PV Name                     /dev/dsk/c0t3d0    PV Name                     /dev/dsk/c5t3d0  Alternate Link    PV Status                   available    Total PE                    17499    Free PE                     17199    Autoswitch                  On    PV Name                     /dev/dsk/c4t9d0    PV Status                   available    Total PE                    17499    Free PE                     17149    Autoswitch                  On    PV Name                     /dev/dsk/c4t10d0    PV Status                   available    Total PE                    17499    Free PE                     17399    Autoswitch                  On    PV Name                     /dev/dsk/c4t11d0    PV Status                   available    Total PE                    17499    Free PE                     17399    Autoswitch                  On root@hpeos003[] 

Assuming that this was a reinstalled/new system, I would simply restore the mapfile , recreate my group file, and then vgimport the volume group.

If you have misplaced your mapfile and you have to import the volume group without a mapfile , you will end up with logical volumes called lvol1 , lvol2 , lvol3 , and so on:

 

 root@hpeos003[vgora1]  pwd  /dev/vgora1 root@hpeos003[vgora1]  ll  total 0 crw-rw-r--   1 root       sys         64 0x010000 Oct 30 19:23 group brw-r-----   1 root       sys         64 0x010001 Oct 30 19:23 lvol1 brw-r-----   1 root       sys         64 0x010002 Oct 30 19:23 lvol2 brw-r-----   1 root       sys         64 0x010003 Oct 30 19:23 lvol3 brw-r-----   1 root       sys         64 0x010004 Oct 30 19:23 lvol4 crw-r-----   1 root       sys         64 0x010001 Oct 30 19:23 rlvol1 crw-r-----   1 root       sys         64 0x010002 Oct 30 19:23 rlvol2 crw-r-----   1 root       sys         64 0x010003 Oct 30 19:23 rlvol3 crw-r-----   1 root       sys         64 0x010004 Oct 30 19:23 rlvol4 root@hpeos003[vgora1] root@hpeos003[vgora1]  lvdisplay /dev/vgora1/lvol1  --- Logical volumes --- LV Name                     /dev/vgora1/lvol1 VG Name                     /dev/vgora1 LV Permission               read/write LV Status                   available/syncd Mirror copies               1 Consistency Recovery        MWC Schedule                    parallel LV Size (Mbytes)            1000 Current LE                  250 Allocated PE                500 Stripes                     0 Stripe Size (Kbytes)        0 Bad block                   on Allocation                  strict IO Timeout (Seconds)        default root@hpeos003[vgora1] 

If you later realize what your logical volumes should be called, the simplest way to rename a logical volume is to rename the device files:

 

 root@hpeos003[vgora1]  mv lvol1 db  root@hpeos003[vgora1]  mv rlvol1 rdb  root@hpeos003[vgora1]  mv lvol2 stripy  root@hpeos003[vgora1]  mv rlvol2 rstripy  root@hpeos003[vgora1]  mv lvol3 Dstripe  root@hpeos003[vgora1]  mv rlvol3 rDstripe  root@hpeos003[vgora1]  mv lvol4 Kstripe  root@hpeos003[vgora1]  mv rlvol4 rKstripe  root@hpeos003[vgora1] root@hpeos003[vgora1]  lvdisplay /dev/vgora1/db  --- Logical volumes --- LV Name                     /dev/vgora1/db VG Name                     /dev/vgora1 LV Permission               read/write LV Status                   available/syncd Mirror copies               1 Consistency Recovery        MWC Schedule                    parallel LV Size (Mbytes)            1000 Current LE                  250 Allocated PE                500 Stripes                     0 Stripe Size (Kbytes)        0 Bad block                   on Allocation                  strict IO Timeout (Seconds)        default root@hpeos003[vgora1] 

This makes sense, because the minor number is simply a key into the extent map stored in the VGRA indicating which extents belong to which logical volume.



HP-UX CSE(c) Official Study Guide and Desk Reference
HP-UX CSE(c) Official Study Guide and Desk Reference
ISBN: N/A
EAN: N/A
Year: 2006
Pages: 434

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net