6.3.5.6 Migrating the
Contents of a Physical Volume
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.
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.
| Note |
|---|
|
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. |
The following sections discuss the tasks required to modify a volume group's 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
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
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
| Note |
|---|
|
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.
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.
| Note |
|---|
|
The reducevg command provides the -d and -f flags.
|
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.
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
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.
| Note |
|---|
|
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:
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.
| Note |
|---|
|
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
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.
The following example shows the use of the lsvg command without any flag to list all the volume groups known to the system.
# lsvg rootvg altinst_rootvg datavg testvg #
The following example shows how to list the volume groups that are currently active (varied on).
# lsvg -o testvg datavg rootvg
The example in Figure 45 shows the command to list
detailed information and status about volume group characteristics.
Figure 45: lsvg rootvg Command
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
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 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.
| Note |
|---|
|
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
reorgvg vg02 lv03 lv04 lv07
Only the listed logical volumes are reorganized on vg02.
echo "hdisk04 hdisk06" | reorgvg -i vg02 lv203 lv205
Only the partitions located on physical volumes hdisk04 and hdisk06 of volume group vg02, which belong to the logical volumes lv203 and lv205, are reorganized.
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.
syncvg -p hdisk04 hdisk05
syncvg -v vg04 vg05