No Title[an error occurred while processing this directive]
Reference: Cisco: Internetworking Basics
The following article presents an overview of the commands used to manage physical and logical volumes for use with Logical Volume Manager (LVM) in Linux.
Before considering the various commands for LVM, lets first look at just what is meant by some of the terminology of LVM.
A logical volume lives in a volume group that is made up of one or more physical volumes. All volume groups are part of the Logical Volume Manager. Here is a table that lists the three types of Logical Volume's.
|Logical Volume||Physical Device||File System|
|volume group||one or more disks||vgdisplay|
|physical volume group||physical extents on a drive||pvdisplay|
|logical volume group||multiple physical volume groups, one or more disks||lvdisplay|
The following table provides an overview of some of the commands used in LVM and the functions they service.
|vgcreate||Create a Volume Group. (Create a subset of the overall LVM)|
|pvcreate||Create a Physical Volume, assign to Volume Group. (Specify a disk for inclusion in the overall LVM)|
|vgextend||Add a new physical disk to a volume group.|
|lvcreate||Create a Logical Volume. (Storage area for related files that is part of a Volume Group. A Volume Group consists of many logical volumes)|
|lvextend||Increase the size of a Logical Volume.|
|lvreduce||Decrease the size of a Logical Volume.|
|lvremove||Removes a Logical Volume. (Frees the storage area set aside for a logical volume)|
|vgreduce||Reduce a Volume Group. (Reduces the number of disks in a Volume Group)|
|vgremove||Remove a Volume Group. (Removes the designation of a group of disks as a Volume Group)|
|vgdisplay||Volume Group Display. (Displays information about one or more Volume Groups)|
|pvdisplay||Physical Volume Display. (Displays information about one or more Volume Groups)|
|lvdisplay||Logical Volume Display. (Displays information about one or more Logical Volumes)|
The following subsections describe the commands used for creating logical volumes.
Before using a hard disk as a physical volume, decide if the physical volume will use the entire disk (/dev/sdc) or a disk partition (/dev/sdc1).
To create the physical volume using a partition, set the partition type to 0x8e (Linux LVM) using fdisk or some other similar program.
Each logical volume in this section will use the entire hard disk. This requires that no partition table exists on the disk. When using the whole disk, the partition table must be erased, which will effectively destroy all data on that disk. An existing partition table can be removed by zeroing the first sector on the disk using the dd command.
Verify that the partition table has been removed from both hard disks.
Use the pvcreate command to initialize a block device to be used as a physical volume. The following commands will initialize the whole disk for each hard disk.
Use the lvmdiskscan command to scan for block devices and verify that the two hard disks can be used as physical volumes.
Use the vgcreate command to create a volume group from one or more physical volumes. The vgcreate command creates a new volume group by name (vg_oradata and vg_orafra for example) and adds at least one physical volume to it. Create a new volume group on each hard disk.
This creates a volume group descriptor at the start of each disk. When using partitions, run the vgcreate command on the partition (for example, vgcreate vg_oradata /dev/sdc1) which will create a volume group descriptor at the start of the partition.
With the new volume groups in place, use the lvcreate command to create the appropriate logical volumes (lv_oradata and lv_orafra). Logical volumes can be created as linear volumes, striped volumes, and mirrored volumes. For the purpose of this example, create a single linear volume within each of the volume groups that uses all of the unallocated space within the volume group.
Use the vgscan and lvscan commands to verify the new volume groups and logical volumes respectively.
LVM volume groups and underlying logical volumes are included in the device special file directory tree in the /dev directory with the following layout.
Before describing how to drop physical and logical volumes, note
that it is very common to only want to remove a logical volume
from a volume group. For example, if users no longer need the
The logical volume can be removed and its physical extents placed
back in the empty pool for the volume group. First, the file system
will need to be unmounted (if it is mounted). Next, deactive it
lvchange and finally delete it with
Here is an example that removes the
Use the following to delete all physical and logical volumes created in this guide.
Jeffrey Hunter is an Oracle Certified Professional, Java Development Certified Professional, Author, and an Oracle ACE. Jeff currently works as a Senior Database Administrator for The DBA Zone, Inc. located in Pittsburgh, Pennsylvania. His work includes advanced performance tuning, Java and PL/SQL programming, developing high availability solutions, capacity planning, database security, and physical / logical database design in a UNIX / Linux server environment. Jeff's other interests include mathematical encryption theory, tutoring advanced mathematics, programming language processors (compilers and interpreters) in Java and C, LDAP, writing web-based database administration tools, and of course Linux. He has been a Sr. Database Administrator and Software Engineer for over 20 years and maintains his own website site at: http://www.iDevelopment.info. Jeff graduated from Stanislaus State University in Turlock, California, with a Bachelor's degree in Computer Science and Mathematics.
Copyright (c) 1998-2018 Jeffrey M. Hunter. All rights reserved.
All articles, scripts and material located at the Internet address of http://www.idevelopment.info is the copyright of Jeffrey M. Hunter and is protected under copyright laws of the United States. This document may not be hosted on any other site without my express, prior, written permission. Application to host any of the material elsewhere can be made by contacting me at firstname.lastname@example.org.
I have made every effort and taken great care in making sure that the material included on my web site is technically accurate, but I disclaim any and all responsibility for any loss, damage or destruction of data or any other property which may arise from relying on it. I will in no case be liable for any monetary damages arising from such loss, damage or destruction.
Last modified on
Monday, 16-Jan-2012 18:23:37 EST
Page Count: 172858