6.4.7 Synchronizing a
Volume Group
Physical volumes and volume groups are normally not addressed directly by users and applications to access data, and they cannot be manipulated to provide disk space for use by users and applications. However, logical volumes provide the mechanism to make disk space available for use, giving users and applications the ability to access data stored on them.
When you create a logical volume, you specify the number of logical
partitions for the logical volume. A logical partition maps to one, two, or
three physical partitions depending on the number of copies of your data you
want to maintain. For example, you can specify a logical volume to be mirrored
and have more than one copy as shown in Figure 48. One
copy of the logical volume (the default) indicates that there is a direct
mapping of one logical partition to one physical partition.
Figure 48: Mapping of LP to PP for Mirrored and Unmirrored
Data
The management of logical volumes is, therefore, the management of disk space that is available for use. This section will review the functions that can be performed by users on logical volumes.
You can create additional logical volumes with the mklv command. This command allows you to specify the name of the logical volume and define its characteristics including the number of the logical partitions to allocate for it. The default maximum size for a logical volume at creation is 128 logical partitions.
The mklv command is used to create a new logical volume. The following is the syntax of the mklv command, and the most commonly used flags are shown in Table 26.
mklv [ -a Position ] [ -b BadBlocks ] [ -c Copies ] [ -d Schedule ] [ -e Range ] [ -i ] [ -L Label ] [ -m MapFile ] [ -r Relocate ] [ -s Strict ] [ -t Type ] [ -u UpperBound ] [ -v Verify ] [ -w MirrorWriteConsistency ] [ -x Maximum ] [ -y NewLogicalVolume | -Y Prefix ] [ -S StripeSize ] [ -U Userid ] [ -G Groupid ] [-P Modes ] VolumeGroup Number [ PhysicalVolume ... ]

The following example shows the use of mklv command to create a new logical volume, newlv. This will create a logical volume called newlv in the rootvg, and it will have 10 logical partitions, and each logical partition consists of two physical partitions.
mklv -y newlv -c 2 rootvg 10
You can use the following SMIT dialog to create a logical volume.
You may need to remove a logical volume if it is no longer in use for storage purposes by users and applications. The rmlv command can be used to remove a logical volume.
The rmlv command is used to remove a logical volume. The following shows the general syntax of the command, and its commonly used flags are shown in Table 27.
rmlv [ -f ] [ -p Physical Volume ] LogicalVolume ...

The following shows the command to remove a logical volume, newlv.
# rmlv newlv Warning, all data on logical volume newlv will be destroyed. rmlv: Do you wish to continue? y(es) n(o) y #
Entering a y as the response to this dialogue and pressing Enter will complete the process of deletion of a logical volume.
Alternatively, you can use the SMIT fast path command, smitty rmlv, to remove a logical volume.
The following steps can be performed to reduce the size of a logical volume to free up excess logical partition allocation.
The resulting free space could be put to better use by allocating it to other logical volumes requiring it.
An existing logical volume can be increased in size by using the extendlv command or SMIT.
If the logical volume is used by a journaled file system, you can also use the chfs command or the SMIT fast path command smitty chjfs to increase the size of the logical volume.
The extendlv command is used to increase the size of a logical volume. The following is the general syntax of the command and its commonly used flags.
extendlv [ -a Position ] [ -e Range ] [ -u Upperbound ] [ -s Strict ] LogicalVolume Partitions [ PhysicalVolume ... ]
The following example shows the use of the extendlv command to add three more logical partitions to the logical volume you created.
extendlv newlv 3
The following SMIT fast path command can be used to increase the size of a logical volume.
smitty extendlv
Logical volumes may need to be copied for a number of reasons. If a disk is to be removed and replaced with a new disk, the logical volumes on that disk will need to be copied to the new disk. Logical volumes can be copied to new logical volumes or to existing logical volumes that are then overwritten.
The following example shows the use of the cplv command to copy a logical volume.
cplv -v myvg -y newlv oldlv
This copies the contents of oldlv to a new logical volume called newlv in the volume group myvg. If the volume group is not specified, the new logical volume will be created in the same volume group as the old logical volume. This command creates a new logical volume.
The following example demonstrates how to copy a logical volume to an existing logical volume.
cplv -e existinglv oldlv
This copies the contents of oldlv to the logical volume existinglv in the same volume group. Confirmation for the copy will be requested since all data in existinglv will be overwritten.
If existinglv is smaller than oldlv, then data will be lost probably resulting in corruption.
| Note |
|---|
|
Do not copy from a larger logical volume containing data to a smaller one. Doing so results in a corrupted file system because some data is not copied. This command will fail if the cplv creates a new logical volume, and the volume group is varied on in concurrent mode. |
Alternatively, you can use the SMIT fast path command, smitty cplv,
to obtain a screen similar to that shown in Figure 51.
Figure 51: cplv - Step 1
| Note |
|---|
|
You might encounter the following error: cplv : Destination logical volume must have type set to copy If this is the case, use the following command: chlv -t copy <Destination Logical Volume Name> Return to your SMIT session. Now, the system will allow you to copy the logical volume. This has been done to ensure extra security so that you do not overwrite your data accidently. |
The following logical volumes are automatically created at the system installation time.
hd1 This logical volume is used by the /home file system.
The following command will list all the logical volumes defined on the system as shown in Figure 53.
lsvg | lsvg -il
Figure 53: Logical Volume Listing
The lslv command can be used to view all the attributes related to
a logical volume (newlv) as shown in Figure 54.
Figure 54: Logical Volume Attributes
The size of a logical volume is the space that is allocated to the logical volume and is a factor of the number of logical partitions that are allocated to the logical volume and the number of copies that you have told the system to maintain. Therefore, the total space taken up by the logical volume is determined by the following formula:
Total LV size=PP size * LPs assigned to LV * Number of copies of the LV
The following example shows how to calculate the logical volume size.
If PP size is 4 MB, LPs assigned to the logical volume are 10, and the number of copies of the logical volume are 2, then the total space that will be allocated to this logical volume will be 80 MB (4*10*2).