6.4.7 Synchronizing a Volume Group

6.5 Managing Logical Volumes

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.

6.5.1 Adding a Logical Volume

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.

6.5.1.1 Creating a Logical Volume Using Command Line

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 ... ]



Table 26: mklv Command Flags

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

6.5.1.2 Creating a Logical Volume Using SMIT

You can use the following SMIT dialog to create a logical volume.

  1. Run the command: smitty mklv

  2. Press F4 to get a list of all the volume groups that are defined in the system. A screen similar to Figure 49 will be shown:



    Figure 49: mklv - Step 1

  3. Use the arrow keys to select the volume group in which you want to create your new logical volume and press Enter. A screen similar to Figure 50 will be shown:



    Figure 50: mklv - Step 2

  4. In the Logical volume NAME field, enter the name of the logical volume you are creating (newlv in this case).

  5. In the Number of LOGICAL PARTITIONS field, enter the number of logical partitions you want to assign to your new logical volume (10 in this case). Each logical partition corresponds to one or more physical partitions depending upon the number of copies of data you want to keep.

  6. In the PHYSICAL VOLUME names field, enter the physical volumes that you want to use for this logical volume. If you do not specify any names, the first PV in the system will be used to place all the data on.

  7. In the Number of COPIES of each logical partition field, enter the number of LP copies that you want for your data. A value of 1 to 3 is allowed.

  8. Press Enter to create the logical volume.

6.5.2 Removing 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.

6.5.2.1 Removing a Logical Volume Using Command Line

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 ...



Table 27: rmlv Command Flags

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.

6.5.2.2 Removing a Logical Volume Using SMIT

Alternatively, you can use the SMIT fast path command, smitty rmlv, to remove a logical volume.

6.5.3 Reducing the Size of a Logical Volume

The following steps can be performed to reduce the size of a logical volume to free up excess logical partition allocation.

  1. Back up all data in the logical volume.

  2. Remove the logical volume.

  3. Recreate the logical volume with the reduced logical partition allocation.

  4. Restore the data.

The resulting free space could be put to better use by allocating it to other logical volumes requiring it.

6.5.4 Increasing the Size of a Logical Volume

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.

6.5.4.1 Extending a Logical Volume Using Command Line

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

6.5.4.2 Extending a Logical Volume Using SMIT

The following SMIT fast path command can be used to increase the size of a logical volume.

smitty extendlv

6.5.5 Copying a Logical Volume

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.

6.5.5.1 Copying a Logical Volume Using Command Line

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.

6.5.5.2 Copying a Logical Volume Using SMIT

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

  1. Select Copy over an existing logical volume. A screen similar to Figure 52 will be shown.



    Figure 52: cplv - Step 2

  2. Enter the name of the logical volume you want to copy in the SOURCE logical volume name field.

  3. Enter the name of the logical volume on which you want to copy your existing logical volume onto in the DESTINATION logical volume name field. This name can be of an existing logical volume that you have already created, or it can be a new logical volume that you want to create. Press Enter to complete this step.

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.

6.5.6 Listing Logical Volumes

The following logical volumes are automatically created at the system installation time.

hd5
This is the boot logical volume that holds the boot code. It is available only at the system startup time.
hd6
This is the default paging space logical volume that is used by the system to perform paging.
hd8
This logical volume is used as the default logging space for the journaled file systems.
hd4
This logical volume in used by the /, root file system.
hd2
This logical volume is used by the /usr file system.
hd9var
This logical volume is used by the /var file system.
hd3
This logical volume used by the /tmp file system.

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

6.5.7 Logical Volume Size

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).

6.6 Managing Journaled File Systems