Move data quickly between AIX LPARs using Logical Volume Manager

Volume group export and import is fast, simple, and safe

Migrating data from one LPAR to another can be challenging. You need to set aside some disk space on the new LPAR and create file systems. And whether you choose to copy the data across the network or do a backup and restore, a large amount of data can take many hours to move. Wouldn't it be good if you could gift wrap your data, send it to a new LPAR, and then unwrap it ready to use? The IBM AIX operating system Logical Volume Manager (LVM) lets you do just that by exporting a volume group from one LPAR and importing it to another one.

Share:

Anthony English (anthonyenglish@levitar.com.au), Senior AIX Specialist, Freelance contractor

Anthony EnglishAnthony English is a freelance contractor in Sydney, Australia. He has worked on AIX systems since 1991 and writes the IBM developerWorks blog, AIX Down Under. He is also recognized as an IBM Champion for Power Systems. You can reach Anthony at anthonyenglish@levitar.com.au. Follow Anthony English on Twitter.



19 July 2011

Also available in Chinese

Migrate an entire volume group

Frequently used acronyms

  • FTP: File Transfer Protocol
  • LPAR: Logical Partition
  • LVM: Logical Volume Manager
  • ODM: Object Data Manager
  • SAN: Storage Area Network

From the earliest days of AIX, the LVM has made management of disks, logical volumes, and file systems easy. The LVM lets you group disks together into volume groups. You can slice off an entire volume group from an AIX system with the exportvg command. When you export the volume group, you effectively package all its logical volumes and file systems along with the directories and files in them. You can then remove the disks from the source system and assign them to the target.

On the target LPAR, you do the reverse by importing the volume group with the importvg command. This also makes the volume group active and updates the new LPAR with details of file systems associated with the logical volumes. You can then do an integrity check of those file systems before you mount them ready for use.

In short, there are three steps to moving a volume group:

  1. Remove the volume group and its disks from the source LPAR.
  2. Reassign the disks to the target LPAR.
  3. Configure the disks, volume group, and file systems on the target LPAR.

This article focuses on steps 1 and 3, which address the AIX-specific procedures at the LVM level. The reassignment of the disks (step 2) varies, depending on your storage configuration.


The fine print

Before getting into the detail of the commands to run, there are some hints and warnings that are worth keeping in mind.

What are disks?

The disks that belong to a volume group are what AIX knows as physical volumes. But they may not be dedicated physical disks. The physical volumes may be SAN logical unit numbers (LUNs) or file-backed devices presented via the Virtual I/O Server. Whatever sort of disks they are, you need to make them available to the target LPAR before you can do the import of the volume group.

The whole volume group gets moved

When you export a volume group, the whole volume group becomes unavailable until it is imported again. This means the volume group to be exported can only contain data you don't need to keep on the original LPAR.

Migrating between sites

The procedure outlined here works between two LPARs on the same physical server. It works just as well if the disks are being assigned to a different server. You could export a volume group, use SAN replication to copy the data to a server on a remote site, and then import the volume group. You can even use the AIX LVM to migrate to a completely new SAN storage subsystem (see Resources).

Helpful commands

The AIX commands used are shown below in Table 1. Check the AIX command documentation for the syntax for these commands (see Resources).

Table 1. Commands for relocating volume groups
CommandDescription
cfgmgrDiscover and configure new devices on the target LPAR.
dfDisplay file systems.
exportvgRemove the volume group definition from the system.
fsckCheck the file system consistency.
importvgImport a volume group definition from the system and activate the volume group.
lspvList physical volume.
lsvgfsList the file systems belonging to a volume group.
mountMount a file system.
rmdevRemove the physical volume definitions from the source LPAR.
umountUnmount a file system.
varyoffvgDeactivate a volume group.
varyonvgActivate a volume group.

Move or copy?

One benefit of using the volume group export and import procedure is that it allows you to move data rather than copy it. That saves you having to allocate additional storage to hold a copy of your data. It also saves you time. If you have a large amount of data or many thousands of files to move, the time saving can be significant.

But maybe you do want to create a spare volume group on the source LPAR and create a file system and copy data to it. You could then export your spare volume group so you can make it available on the target LPAR.

If you choose to do that, consider turning off JFS logging on your new file system before you start copying to it.

Improve performance with JFS2 NOLOG

You can speed up writes to a file system by mounting it with the NOLOG option. This feature of the IBM enhanced journaled file system (JFS2) was introduced with AIX V6.1. The NOLOG option is only intended for data you can easily copy or restore again or for temporary file systems with data that is not important or is easy to reproduce.

To mount a JFS2 file system without logging, use:

# mount -o log=NULL /mountpoint

Writes to this file system should be faster because journaling does incur a small performance penalty.

When the file system contains all the data it requires, you can export the volume group from the source LPAR and import it on the target. You should then mount the file system on the target LPAR using the normal JFS logging (without using the NOLOG option).

For more information about turning off JFS2 logging, see Resources.


Remove a volume group from the source LPAR

When you have your data ready to move, remove the volume group and its physical volumes from the source LPAR. To do that, the logical volumes belonging to that volume group must be closed. That requires you to unmount the file systems that belong to the volume group you are going to export.

List file systems in the volume group

To identify the file systems belonging to a volume group, use the lsvgfs command:

# lsvgfs sparevg

# /scratch

Unmount file systems

Unmount any file systems in the volume group using the umount command:

# umount /scratch

You also need to deactivate any paging spaces and de-configure any system dump devices that belong to the volume group (see Resources for details).

When the logical volumes are closed, you should be able to deactivate the volume group.

Deactivate the volume group

You can make the volume group inactive with the varyoffvg command:

# varyoffvg sparevg

You can check the volume group status by listing physical volumes with lspv. This shows the volume group name. The volume group status is no longer listed as active.

# lspv
# hdisk0          00cb07a4cee0b389                    rootvg          active
# hdisk1          00cb07a42fb87e1d                    sparevg

Export the volume group

You should now be able to export the volume group using exportvg:

# exportvg sparevg

After you run exportvg, lspv displays the volume group as None:

# lspv
# hdisk0          00cb07a4cee0b389                    rootvg          active
# hdisk1          00cb07a42fb87e1d                    None

You could import the volume group again on the source LPAR using importvg. However, because you're planning to move it to another LPAR, you need to remove the references to the disks from the operating system on the source LPAR.

Remove the physical volumes from the ODM

The ODM still keeps a record of the physical volumes at the operating system level. It is now safe to delete the physical volumes belonging to the volume group using rmdev. This removes references to the disks on the source LPAR, but it doesn't affect the data on the disks.

Volume group descriptor area and volume group status area

Each of the disks in the volume group has management data, including a volume group descriptor area and a volume group status area. This management data is stored on each physical volume of the volume group. When you remove the disks from the ODM, the disk management data remains intact.

# rmdev -d -l hdisk1
# hdisk1 deleted

Assign storage to target LPAR

The next step is to assign the storage to the target LPAR. How you do this depends on your storage configuration. Whoever is responsible for your storage subsystem should be able to present the disks to the new LPAR.


Import data on target LPAR

After you assign the disks to the target LPAR, you need to identify them at the operating system level and then make the volume group and file systems available.

Identify new disks on target LPAR

The new disks need to be discovered on the operating system of the target LPAR. A reboot of the LPAR would do this, but that's not necessary. You can run cfgmgr to configure the new devices:

# cfgmgr

The lspv command should show these disks with their Physical Volume Identifier (PVID). The volume group is shown as None, and the volume group status doesn't display as active.

# lspv
# hdisk0          00cb07a4b24eb714                    rootvg          active
# hdisk1          00cb07a42fb87e1d                    None

The disk name on the target LPAR (hdiskN) may not be the same name as the source LPAR. However, the PVID should be the same on the source and the target because it is a unique identifier for each physical volume.

Import the volume group on the target LPAR

Use the importvg command and a PhysicalVolume parameter to import the volume group. You only need to specify one physical volume, even if there are several physical volumes in the volume group. The importvg command finds any remaining physical volumes belonging to the same volume group and includes them in the import.

# importvg -y sparevg hdisk1

The system automatically runs the varyonvg command to activate the volume group after it is imported. If the volume group is concurrent capable, you will be prompted by the importvg command to activate the imported volume group manually using varyonvg.

Updating file systems

If the volume group has file systems in it, the /etc/filesystems file is updated with information for the imported volume group's logical volumes and mount points. This saves you rebuilding the logical volumes and file systems yourself, as you would need to do before running a traditional restore or copy operation. The logical volume and file system characteristics are also inherited.

Before mounting the file systems, you need to verify their integrity.

Run fsck on all file systems

You should check the file system consistency for each file system. You can do this with the fsck command:

# fsck /scratch

Mount the file systems on target LPAR

You are now ready to mount the file systems, check permissions, and verify the file system contents. Once again, you can list all the file systems belonging to the volume group with lsvgfs. The mount command makes the file system available, along with all of its contents.

# mount /scratch

You can check the mounted file systems using df. Be sure to check the permissions on the mount points, directories, and files.


Summary

The AIX LVM provides a simple way of moving large amounts of data from one LPAR to another. It can reduce or even eliminate system downtime when you want to do data migration.

You can use the volume group export and import to refresh a database or to perform a disaster recovery test. It has plenty of uses when you need to move data quickly without requiring additional disk or making unnecessary demands on your backup infrastructure.

Resources

Learn

Get products and technologies

  • Try out IBM software. Download a trial version, log into an online trial, work with a product in a sandbox environment, or access it through the cloud. Choose from over 100 IBM product trials.

Discuss

  • Get involved in the developerWorks community. Connect with other developerWorks users while exploring the developer-driven blogs, forums, groups, and wikis.

Comments

developerWorks: Sign in

Required fields are indicated with an asterisk (*).


Need an IBM ID?
Forgot your IBM ID?


Forgot your password?
Change your password

By clicking Submit, you agree to the developerWorks terms of use.

 


The first time you sign into developerWorks, a profile is created for you. Information in your profile (your name, country/region, and company name) is displayed to the public and will accompany any content you post, unless you opt to hide your company name. You may update your IBM account at any time.

All information submitted is secure.

Choose your display name



The first time you sign in to developerWorks, a profile is created for you, so you need to choose a display name. Your display name accompanies the content you post on developerWorks.

Please choose a display name between 3-31 characters. Your display name must be unique in the developerWorks community and should not be your email address for privacy reasons.

Required fields are indicated with an asterisk (*).

(Must be between 3 – 31 characters.)

By clicking Submit, you agree to the developerWorks terms of use.

 


All information submitted is secure.

Dig deeper into AIX and Unix on developerWorks


static.content.url=http://www.ibm.com/developerworks/js/artrating/
SITE_ID=1
Zone=AIX and UNIX
ArticleID=733094
ArticleTitle=Move data quickly between AIX LPARs using Logical Volume Manager
publish-date=07192011