Check that the number of free physical extents (
Free PE
) matches the total number of physical
extents (
Total PE
). If they are not the same, do one of the following tasks:
•
Move the physical extents onto another physical volume in the volume group. See
“Moving
Data to a Different Physical Volume” (page 73)
.
•
Remove the logical volumes from the disk, as described in
“Removing a Logical Volume”
(page 57)
. The logical volumes with physical extents on the disk are shown at the end of
the
pvdisplay
listing.
2.
After the disk no longer holds any physical extents, use the
vgreduce
command to remove
it from the volume group. For example:
# vgreduce /dev/vgnn /dev/disk/disk3
IMPORTANT:
If you are using LVM pvlinks, as described in
“Increasing Hardware Path
Redundancy Through Multipathing” (page 28)
, you must run the
vgreduce
command for
each link to the disk.
Creating a Logical Volume
To create a logical volume, follow these steps:
1.
Decide how much disk space the logical volume needs.
For example, you can add 200 MB of device swap space, or you might have a new project
that you expect to grow to 10 GB.
2.
Find a volume group that has adequate free space.
To determine if there is sufficient disk space available for the logical volume within a volume
group, use the
vgdisplay
command to calculate this information.
vgdisplay
outputs data
on one or more volume groups, including the physical extent size (under
PE Size (MBytes)
)
and the number of available physical extents (under
Free PE
). By multiplying these two
figures, you get the number of megabytes available within the volume group. For more
information, see vgdisplay(1M).
3.
Create the logical volume using
lvcreate
. For example:
# lvcreate -L size_in_MB /dev/vgnn
This command creates the logical volume
/dev/vgnn/lvoln
with LVM automatically assigning
the
n
in
lvoln
.
When LVM creates the logical volume, it creates block and character device files for that logical
volume and places them in the
/dev/vgnn
directory.
Creating a Striped Logical Volume
To create a striped logical volume, use
lvcreate
with the
-i
and the
-I
options to specify the
number of disks and stripe width, respectively. For example, suppose you want to stripe across
three disks with a stripe size of 32K. Your logical volume size is 240 MB. To create the striped
logical volume, enter the following command:
# lvcreate -i 3 -I 32 -l 240 -n lvol1 /dev/vg01
The
lvcreate
command automatically rounds up the size of the logical volume to a multiple of
the number of disks times the extent size. For example, if you have three disks you want to stripe
across and the extent size is 4 MB, even though you indicate a logical volume size of 200 MB
(
-L 200
),
lvcreate
creates a 204 MB logical volume because 200 is not a multiple of 12.
52
Administering LVM