Migrating the Contents of a Physical Volume

6.4 Managing Volume Groups

This section discusses the functions that can be performed on volume groups. As with physical volumes, volume groups can be created and removed, and their characteristics can be modified. Additional functions, such as activating and deactivating volume groups, can also be performed.

6.4.1 Adding a Volume Group

Before a new volume group can be added to the system, one or more physical volumes, not used in other volume groups and in an available state, must exist on the system.

It is important to decide upon certain information, such as the volume group name and the physical volumes to use, prior to adding a volume group.

New volume groups can be added to the system by using the mkvg command or by using SMIT. Of all the characteristics set at creation time of the volume group, the following are the most important:

The following example shows the use of the mkvg command to create a volume group, myvg, using the physical volumes hdisk1 and hdisk5, with a physical partition size of 4 KB. The volume group is limited to a maximum of 10 physical volumes.

mkvg -y myvg -d 10 -s 8 hdisk1 hdisk5

Alternatively, you can use the SMIT fast path command smitty mkvg to obtain the screen shown in Figure 42 and enter the characteristics of the volume group to be created in the fields.

Figure 42: smitty mkvg Command

The smitty mkvg command will automatically activate the volume group by calling the varyonvg command. Moreover, the SMIT command limits the followings function as compared to executing from the command line.


For a new volume group to be successfully added to the system using the mkvg command, the root file system should have about 2 MB of free space. Check this using the df command. This free space is required because a file is written in the directory /etc/vg each time a new volume group is added.

6.4.2 Modifying Volume Group Characteristics

The following sections discuss the tasks required to modify a volume group's characteristics. Modifying Volume Group Activation Characteristics

The following command allows the volume group, newvg, to be varied on automatically each time a system is restarted.

chvg -ay newvg

The following command will turn off the automatic varying on of a volume group at the system restart.

chvg -an VGname Unlocking a Volume Group

A volume group can become locked when an LVM command terminates abnormally due to a system crash while an LVM operation was being performed on the system.

In AIX Version 4, it is now also possible to unlock a volume group. The following example shows the command to unlock a volume group (newvg).

chvg -u newvg Adding a Physical Volume

It may be necessary to increase the free space available in a volume group so that existing file systems and logical volumes within the volume group can be extended, or new ones can be added. To do this requires additional physical volumes be made available within the volume group.

It is possible to add physical volumes to a volume group up to the maximum specified at creation time. A physical volume can be added using the extendvg command. The following example shows the command to add the physical volume hdisk3 to volume group newvg.

extendvg newvg hdisk3


The extendvg command will fail if the physical volume being added already belongs to a varied on volume group on the current system. Also, if the physical volume being added belongs to a volume group that is currently not varied on, the user will be asked to confirm whether or not to continue.

Alternatively, you can use the SMIT fast path command smitty vgsc and select Add a Physical Volume to a Volume Group. Removing a Physical Volume

The volume group must be varied on before it can be reduced. The following example shows how to remove a physical volume hdisk3 from a volume group, myvg.

reducevg myvg hdisk3

Alternatively, you can use the SMIT fast path command smitty reducevg to remove a physical volume from a volume group.


The reducevg command provides the -d and -f flags.

  • The -d flag can be dangerous because it automatically deletes all logical volume data on the physical volume before removing the physical volume from the volume group. If a logical volume spans multiple physical volumes, the removal of any of those physical volumes may jeopardize the integrity of the entire logical volume.

  • The -f flag makes the -d flag even more dangerous by suppressing interaction with a user requesting confirmation that the logical volume should be deleted.

If the logical volumes on the physical volume specified to be removed also span other physical volumes in the volume group, the removal operation may destroy the integrity of those logical volumes regardless of the physical volume on which they reside.

When you remove all physical volumes in a volume group, the volume group itself is also removed. Removing a Physical Volume Reference

Sometimes a disk is removed from the system without first running reducevg VolumeGroup PhysicalVolume. The VGDA still has the removed disk's reference, but the physical volume name no longer exists or has been reassigned. To remove references to the disk that has been removed, you can still use the reducevg command using the PVID of the physical volume removed. The following command will remove the reference of a physical volume (with PVID of 000005265ac63976) from the volume group newvg.

reducevg VolumeGroup 000005265ac63976

6.4.3 Importing and Exporting a Volume Group

There may be times when a volume group needs to be moved from one RISC System/6000 system to another, so that logical volume and file system data in the volume group can be accessed directly on the target system.

To remove the system definition of a volume group from the ODM database, the volume group needs to be exported using the exportvg command. This command will not remove any user data in the volume group but will only remove its definition from the ODM database.

Similarly, when a volume group is moved, the target system needs to add the definition of the new volume group. This can be achieved by importing the volume group by using the importvg command, which will add an entry to the ODM database.

The following example shows the export of a volume group myvg.

exportvg myvg

And, the following example shows the import of a volume group myvg.

importvg myvg hdiskx

You can also use the SMIT fast path commands, smitty exportvg or smitty importvg, to export or import a volume group.

If the specified volume group name is already in use, the importvg command will fail with an appropriate error message since duplicate volume group names are not allowed. In this instance, the command can be rerun with a unique volume group name specified. The command can also be rerun without the -y flag or the volume group name, which gives the imported volume group a unique system default name.

It is also possible that some logical volume names may also conflict with those already on the system. The importvg command will automatically reassign these with system default names. The important thing to remember when moving volume groups from system to system is that the exportvg command is always run on the source system prior to importing the volume group to the target system. Consider that a volume group is imported on system Y without actually performing an exportvg on system X. If system Y makes a change to the volume group, such as removing a physical volume from the volume group, and the volume group is imported back onto system X, the ODM database on system X will not be consistent with the changed information for this volume group.

However, it is worth noting that a volume group can be moved to another system without first being exported on the source system.

  • The importvg command changes the name of an imported logical volume if there currently is a logical volume with the same name already on the system. An error message is printed to standard error if an imported logical volume is renamed. The importvg command also creates file mount points and entries in /etc/filesystems if possible (if there are no conflicts).

  • A volume group that has a paging space volume on it cannot be exported while the paging space is active. Before exporting a volume group with an active paging space, ensure that the paging space is not activated automatically at system initialization by running the following command:
    chps -a n paging_space_name

    Then, reboot the system so that the paging space is inactive.

  • If you do not activate the volume group through smitty importvg, you must run the varyonvg command to enable access to the file systems and logical volumes.

  • If you imported a volume group that contains file systems, or if you activated the volume group through smitty importvg, it is highly recommended that you run the fsck command before you mount the file systems. If you are moving the volume group to another system, be sure to unconfigure the disks before moving them.

  • The smitty exportvg command deletes references to file systems in /etc/filesystems, but it leaves the mount points on the system.

6.4.4 Varying On and Varying Off a Volume Group

Once a volume group exists, it can be made available for use for system administrative activities using the varyonvg command. This process involves the following steps:

  1. Each VGDA on each physical volume in a volume group is read.

  2. The header and trailer time stamps within each VGDA are read. These time stamps must match for a VGDA to be valid.

  3. If a majority of VGDAs (called the quorum) are valid, then the vary on process proceeds. If they are not, then the vary on fails.

  4. The system will take the most recent VGDA (the one with the latest time stamp) and write it over all other VGDAs so they all match.

  5. The syncvg command is run to resynchronize any stale partition present (in the case where mirroring is in use).

The varyonvg command has the following options that can be used to overcome damage to the volume group structure or give status information.

The following example shows the command to activate a volume group, newvg.

varyonvg newvg

You can also use the SMIT fast path command, smitty varyonvg, to obtain output similar to what is presented in Figure 43. Enter the name of volume group to be varied on along with all the options.

Figure 43: smitty varyonvg Command

The varyoffvg command will deactivate a volume group and its associated logical volumes. This requires that the logical volumes be closed, which requires that file systems associated with logical volumes be unmounted. The varyoffvg command also allows the use of the -s flag to move the volume group from being active to being in the maintenance or systems management mode.


In AIX Version 4, when a volume group is imported, it is automatically varied on; whereas, in AIX Version 3, the volume group has to be varied on separately.

The following example shows the command to deactivate a volume group, myvg.

varyoffvg myvg

You can also use the SMIT fast path command, smitty varyoffvg, which will show a screen as is shown in Figure 44. You can enter the name of volume group to be varied off, and you can also put the volume group into system management mode.

Figure 44: smitty varyoffvg Command

6.4.5 Monitoring a Volume Group

The lsvg command interrogates the ODM database for all volume groups currently known to the system. The following are a few examples showing the use of the lsvg command to monitor volume groups. Listing the Volume Groups

The following example shows the use of the lsvg command without any flag to list all the volume groups known to the system.

# lsvg

The following example shows how to list the volume groups that are currently active (varied on).

# lsvg -o
rootvg Listing the Characteristics of a Volume Group

The example in Figure 45 shows the command to list detailed information and status about volume group characteristics.

Figure 45: lsvg rootvg Command Listing the Logical Volumes in a Volume Group

The example in Figure 46 shows the command used to display the names, characteristics, and status of all the logical volumes in the volume group rootvg.

Figure 46: lsvg -l rootvg Command List the Physical Volume Status within a Volume Group

The example shown in Figure 47 shows the use of the lsvg command with the -p flag to display a list of physical volumes contained in a volume group, as well as some status information including physical partition allocation. This form of the lsvg command is useful for summarizing the concentrations of free space on the system.

Figure 47: lsvg -p vgname Command

The following is the description of the various fields shown in the preceding example.

The name of the physical volume.
Whether or not this physical volume is active.
The total number of physical partitions on this physical volume.
The total number of unused physical partitions on this physical volume.
The location of the free physical partitions on the physical volumes. There are five columns, one for each disk region, in the following order: Outside edge, Outside middle, Center, Inside middle, Inside edge.

6.4.6 Reorganizing a Volume Group

The reorgvg command is used to reorganize the physical partition allocation for a volume group according to the allocation characteristics of each logical volume.

The following is the syntax of the reorgvg command:

reorgvg [ -i ] VolumeGroup [ LogicalVolume ... ]

The volume group must be varied on and must have free partitions before you can use the reorgvg command. The relocatable flag of each logical volume must be set to y using the chlv -r command for the reorganization to take effect; otherwise, the logical volume is ignored.

  1. The reorgvg command does not reorganize the placement of allocated physical partitions for any striped logical volumes.

  2. At least one free physical partition must exist on the specified volume group for the reorgvg command to run successfully.

  3. In AIX Version 4.2, or later, if you enter the reorgvg command with the volume group name and no other arguments, it will only reorganize the first logical volume in the volume group. The first logical volume is the one listed by the lsvg -l VolumeName command.

You can also use the SMIT fast path command, smitty reorgvg, to do the same task. See Table 24 for details on a flag for the reorgvg command.

Table 24: reorgvg Command Flags

6.4.7 Synchronizing a Volume Group

The syncvg command is used to synchronize logical volume copies that are not current (stale).

The following is the syntax of syncvg command:

syncvg [ -f ] [ -i ] [ -H ] [ -P NumParallelLps ] { -l | -p | -v }
Name ...

The syncvg command synchronizes the physical partitions, which are copies of the original physical partition that are not current. The syncvg command can be used with logical volumes, physical volumes, or volume groups, with the Name parameter representing the logical volume name, physical volume name, or volume group name. The synchronization process can be time consuming depending on the hardware characteristics and the amount of data.

When the -f flag is used, an uncorrupted physical copy is chosen and propagated to all other copies of the logical partition whether or not they are stale.

Unless disabled, the copies within a volume group are synchronized automatically when the volume group is activated by the varyonvg command. The commonly used flags with the syncvg command are shown in Table 25.

Table 25: Key Flags for the syncvg Command

The following examples show the use of the syncvg command.

6.5 Managing Logical Volumes