Home > Articles

  • Print
  • + Share This
This chapter is from the book

Understanding LVM

Logical Volume Manager, or LVM, is a storage management solution that allows administrators to divide hard drive space into physical volumes (PV), which can then be combined into logical volume groups (VG), which are then divided into logical volumes (LV) on which the filesystem and mount point are created.

As shown in Figure 7.1, because a logical volume group can include more than one physical volume, a mount point can include more than one physical hard drive, meaning the largest mount point can be larger than the biggest hard drive in the set. These logical volumes can be resized later if more disk space is needed for a particular mount point. After the mount points are created on logical volumes, a filesystem must be created on them.

Figure 7.1

Figure 7.1 How Logical Volume Manager Works

LVM is used by default during installation for all mount points except the /boot partition, which cannot exist on a logical volume. This section discusses how to perform LVM operations after installation such as creating a physical volume for a newly added hard drive, expanding logical volumes, and generating LV snapshots.

Table 7.1 summaries the LVM tools available after installation.

Table 7.1. LVM Tools

LVM Tool



Create physical volume from a hard drive


Create logical volume group from one or more physical volumes


Add a physical volume to an existing volume group


Remove a physical volume from a volume group


Create a logical volume from available space in the volume group


Extend the size of a logical volume from free physical extents in the logical volume group


Remove a logical volume from a logical volume group, after unmounting it


Show properties of existing volume group


Show properties of existing logical volumes


Show properties of existing physical volumes

Adding Additional Disk Space

One big advantage of using LVM is that the size of a logical volume can be increased and logical volumes can be added to create additional mount points. To modify the LVM configuration post-installation, the lvm2 package needs to be installed. Refer to Chapter 3, “Operating System Updates,” for details on installing packages.

To increase the size of an existing logical volume or to add a logical volume, you first need free disk space. This free disk space can either be disk space that already exists in the system as unpartitioned space (not part of an existing logical volume), an unused partition, physical volume that is not already a member of a logical volume, or disk space as a result of installing one or more additional hard drives to the system. The disk space can come from removing a logical volume to create space in the logical volume group, however, this is not common because if the LV already exists, it is most likely already being used and cannot be easily deleted without losing data.

After deciding which free disk space to use, the basic steps for increasing the size of a logical volume are as follows:

  1. Create new physical volume from free disk space.
  2. Add physical volume to the logical volume group.
  3. Expand the size of the logical volume to include the newly added disk space in the volume group.
  4. Expand the filesystem on the logical volume to include the new space.

To add a logical volume, use the following steps:

  1. Create new physical volume from free disk space.
  2. Add physical volume to the logical volume group.
  3. Create a logical volume with the new space in volume group.
  4. Create a filesystem on the logical volume.
  5. Create a mount point.
  6. Mount the logical volume.
  7. Test the filesystem.
  8. Add the new mount point to /etc/fstab.

Creating a Physical Volume

To create a new physical volume from free hard drive space or a hard drive partition, use the pvcreate command:

pvcreate <disk>

Replace <disk> with the device name of the hard drive:

pvcreate /dev/sda

or the partition name:

pvcreate /dev/sda1

The <disk> specified can also be a meta device or loopback device, but using an entire hard disk or partition is more common. After creating a physical volume, you can either add it to an existing volume group or create a new volume group with the physical volume.

Creating and Modifying Volume Groups

A volume group can be created from one or more physical volumes. To scan the system for all physical volumes, use the pvscan command as root. It displays all PVs on the system. If the PV is part of a VG, it will display the name of the VG next to it.

To create a VG, execute the vgcreate command as root, where <vgname> is a unique name for the volume group and <pvlist> is one or more physical volumes to use, each separated by a space:

vgcreate <vgname> <pvlist>

For example, to create a VG with the name DatabaseVG from the first and second SCSI hard drives:

vgcreate DatabaseVG /dev/sda /dev/sdb

If a volume group already exists but needs to be expanded, use the vgextend command to add additional physical volumes to it:

vgextend <vgname> <pvlist>

To remove a physical volume from a volume group:

vgreduce <vgname> <pvlist>

Use caution when reducing a volume group because any logical volume using the PVs are removed from the VG and can no longer be accessed.

Creating and Modifying Logical Volumes

Now that the physical volumes are formed into volume groups, the volume groups can be divided into logical volumes, and the logical volumes can be formatted with a filesystem and assigned mount points.

Use the lvcreate command to create a logical volume. Each LV must have a unique name. If one is not specified with the -n <name> option, a name will be assigned to it. To create a logical volume from the volume group <vgname> of a certain size, specify the size unit after the value of the size such as 300G for 300 gigabytes:

lvcreate -n <lvname> --size <size> <vgname>

Each physical volume consists of physical extents, which are 4 megabytes in size by default. When the size is given in gigabytes, this size must be converted to physical extents, meaning that some amount of disk space may not be used. So, the number of physical extents to use when creating the logical volume can be given with the -l <numpe> option:

lvcreate -n <lvname> -l <numpe> <vgname>

To determine the number of physical extents in a logical volume group, issue the following command as root:

vgdisplay <vgname>

The Total PE line shows the number of physical extents for the volume group. The output should look similar to Listing 7.5, which shows a total of 1189 physical extents. Look for the Free PE / Size line to determine whether any free PEs are available to allocate to a new logical volume. Listing 7.5 shows 220 free physical extents.

Listing 7.5. Example vgdisplay Output

--- Volume group ---
VG Name               VolGroup00
System ID
Format                lvm2
Metadata Areas        1
Metadata Sequence No  5
VG Access             read/write
VG Status             resizable
MAX LV                0
Cur LV                2
Open LV               2
Max PV                0
Cur PV                1
Act PV                1
VG Size               37.16 GB
PE Size               32.00 MB
Total PE              1189
Alloc PE / Size       969 / 30.28 GB
Free  PE / Size       220 / 6.88 GB
VG UUID               N60y5U-2sM2-uxHY-M1op-Q1v3-uVV2-Zkahza

By default, logical volumes are created linearly over the physical volumes. However, they can be striped over multiple PVs:

lvcreate -i<stripes> -I<stripesize> -l <numpe> -n <lvname> <vgname> <pvlist>

The -i<stripes> option sets the number of stripes, or physical volumes to use. The -I<stripesize> is the stripe size, which must be 2^n, where n is an integer from 2 to 9. Provide the number of PEs to use with the -l <numpe> option or give the size of the LV with the --size <size> option. The -n <lvname> option specifies the LV name, and <vgname> represents the name of the VG to use. Optionally, list the PVs to use, <pvlist>, at the end of the command separated by spaces. The number of PVs listed should be equal to the number of stripes.

After creating the logical volume, you must create a filesystem on it. To create an ext3 filesystem, execute the following as root:

mke2fs -j /dev/<vgname>/<lvname>

If the LV is to be used as swap, execute the following as root instead:

mkswap /dev/<vgname>/<lvname>

Next, still as the root user, create an empty directory as its mount point with the mkdir command, and use the mount command to mount the filesystem:

mount /dev/<vgname>/<lvname> /mount/point

If it mounts properly, the last step is to add it to /etc/fstab so it is mounted automatically at boot time. As root, add a line similar to the following, replacing with the appropriate values:

/dev/<vgname>/<lvname> /mount/point                   ext3    defaults        1 2

To extend a logical volume, expand the volume group if necessary, and then use the lvextend command. Either specify the final size of the logical volume:

lvextend --size <size> /dev/<vgname>/<lvname>

or specify how much to expand the logical volume:

lvextend --size +<addsize> /dev/<vgname>/<lvname>

Just like physical volumes are composed of 4KB physical extents, logical volumes consist of logical extents, which also have a default size of 4KB. Instead of specifying the size or amount of space to add in gigabytes, it is also possible to use the -l <numle> to provide the final number of logical extents or -l +<numle> to expand the logical volume by a certain number of logical extents.

After extending the logical volume, the filesystem on it must be expanded as well. If it is an ext3 filesystem (default filesystem for Red Hat Enterprise Linux), it can be expanded while it is still mounted (also known as online). To do so, execute the following as root:

resize2fs /dev/<vgname>/<lvname>

The filesystem is expanded to fill the entire logical volume unless a size is listed after the logical volume device name (be sure to list the size unit such as G for gigabyte after the size):

resize2fs /dev/<vgname>/<lvname> <size>

To remove a logical volume from a volume group, first unmount it with the umount command:

umount /dev/<vgname>/<lvname>

and then use the lvremove command:

lvremove /dev/<vgname>/<lvname>

To view the existing logical volumes along with information about them such as what VG they are a member of, the number of logical extents, and their size in gigabytes, execute the lvdisplay command as root as shown in Listing 7.6.

Listing 7.6. Example lvdisplay Output

--- Logical volume ---
LV Name                /dev/VolGroup00/LogVol00
VG Name                VolGroup00
LV UUID                tugMFo-PESp-3INs-nrGF-K0Wh-s3U0-l9FsTc
LV Write Access        read/write
LV Status              available
# open                 1
LV Size                12.94 GB
Current LE             414
Segments               1
Allocation             inherit
Read ahead sectors     0
Block device           253:0

--- Logical volume ---
LV Name                /dev/VolGroup00/LogVol01
VG Name                VolGroup00
LV UUID                fdKfYP-wIP9-M4Da-eoV3-pP99-w8Vb-0yhgZb
LV Write Access        read/write
LV Status              available
# open                 1
LV Size                78.12 GB
Current LE             2500
Segments               1
Allocation             inherit
Read ahead sectors     0
Block device           253:1

--- Logical volume ---
LV Name                /dev/VolGroup00/LogVol02
VG Name                VolGroup00
LV UUID                bzr4Ag-rDKT-y8zY-F3e8-SaBI-QY51-r6lJ3T
LV Write Access        read/write
LV Status              available
# open                 1
LV Size                1.94 GB
Current LE             62
Segments               1
Allocation             inherit
Read ahead sectors     0
Block device           253:2

Creating Snapshots

With LVM, it is possible to take a snapshot of a logical volume while the LV is still in read-write mode and being accessed by the system. As the root user, issue the following command:

lvcreate --size <size> -s -n <snapshotname> <lvname>

The lvcreate command is used to create a new logical volume, meaning there must be free physical extents in the logical volume group to create a snapshot. The -s option means that the LV is a snapshot, <snapshotname> is the name of the new LV created, and <lvname> is the name of the LV from which to create the snapshot.

A snapshot is not a copy of the entire LV. Instead, it keeps track of the changes from the time the snapshot is taken and the present time. Thus, the size of the snapshot LV does not need to be as large as the LV from which it is created. It just needs to be as big as all the changes from the time the snapshot is taken until the snapshot is used. Snapshots are not intended to be left around for long periods of time. Reasons to create snapshots include performing backups (most common), creating virtual machines using the Virtualization feature (refer to Appendix B, “Creating Virtual Machines”), creating a duplicate testing system, and transferring data from one logical volume group (and possibly a different hard drive) to another.

If a snapshot LV reaches disk capacity, it will become unusable. When the backup or data transfer has been completed, the snapshot logical volume should be unmounted and removed with the lvremove /dev/<vgname>/<lvname> command. Because the snapshot LV is storing a copy of all changes made to the original LV, performance for the original LV can be reduced because of this copy process.

  • + Share This
  • 🔖 Save To Your Account

InformIT Promotional Mailings & Special Offers

I would like to receive exclusive offers and hear about products from InformIT and its family of brands. I can unsubscribe at any time.


Pearson Education, Inc., 221 River Street, Hoboken, New Jersey 07030, (Pearson) presents this site to provide information about products and services that can be purchased through this site.

This privacy notice provides an overview of our commitment to privacy and describes how we collect, protect, use and share personal information collected through this site. Please note that other Pearson websites and online products and services have their own separate privacy policies.

Collection and Use of Information

To conduct business and deliver products and services, Pearson collects and uses personal information in several ways in connection with this site, including:

Questions and Inquiries

For inquiries and questions, we collect the inquiry or question, together with name, contact details (email address, phone number and mailing address) and any other additional information voluntarily submitted to us through a Contact Us form or an email. We use this information to address the inquiry and respond to the question.

Online Store

For orders and purchases placed through our online store on this site, we collect order details, name, institution name and address (if applicable), email address, phone number, shipping and billing addresses, credit/debit card information, shipping options and any instructions. We use this information to complete transactions, fulfill orders, communicate with individuals placing orders or visiting the online store, and for related purposes.


Pearson may offer opportunities to provide feedback or participate in surveys, including surveys evaluating Pearson products, services or sites. Participation is voluntary. Pearson collects information requested in the survey questions and uses the information to evaluate, support, maintain and improve products, services or sites, develop new products and services, conduct educational research and for other purposes specified in the survey.

Contests and Drawings

Occasionally, we may sponsor a contest or drawing. Participation is optional. Pearson collects name, contact information and other information specified on the entry form for the contest or drawing to conduct the contest or drawing. Pearson may collect additional personal information from the winners of a contest or drawing in order to award the prize and for tax reporting purposes, as required by law.


If you have elected to receive email newsletters or promotional mailings and special offers but want to unsubscribe, simply email information@informit.com.

Service Announcements

On rare occasions it is necessary to send out a strictly service related announcement. For instance, if our service is temporarily suspended for maintenance we might send users an email. Generally, users may not opt-out of these communications, though they can deactivate their account information. However, these communications are not promotional in nature.

Customer Service

We communicate with users on a regular basis to provide requested services and in regard to issues relating to their account we reply via email or phone in accordance with the users' wishes when a user submits their information through our Contact Us form.

Other Collection and Use of Information

Application and System Logs

Pearson automatically collects log data to help ensure the delivery, availability and security of this site. Log data may include technical information about how a user or visitor connected to this site, such as browser type, type of computer/device, operating system, internet service provider and IP address. We use this information for support purposes and to monitor the health of the site, identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents and appropriately scale computing resources.

Web Analytics

Pearson may use third party web trend analytical services, including Google Analytics, to collect visitor information, such as IP addresses, browser types, referring pages, pages visited and time spent on a particular site. While these analytical services collect and report information on an anonymous basis, they may use cookies to gather web trend information. The information gathered may enable Pearson (but not the third party web trend services) to link information with application and system log data. Pearson uses this information for system administration and to identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents, appropriately scale computing resources and otherwise support and deliver this site and its services.

Cookies and Related Technologies

This site uses cookies and similar technologies to personalize content, measure traffic patterns, control security, track use and access of information on this site, and provide interest-based messages and advertising. Users can manage and block the use of cookies through their browser. Disabling or blocking certain cookies may limit the functionality of this site.

Do Not Track

This site currently does not respond to Do Not Track signals.


Pearson uses appropriate physical, administrative and technical security measures to protect personal information from unauthorized access, use and disclosure.


This site is not directed to children under the age of 13.


Pearson may send or direct marketing communications to users, provided that

  • Pearson will not use personal information collected or processed as a K-12 school service provider for the purpose of directed or targeted advertising.
  • Such marketing is consistent with applicable law and Pearson's legal obligations.
  • Pearson will not knowingly direct or send marketing communications to an individual who has expressed a preference not to receive marketing.
  • Where required by applicable law, express or implied consent to marketing exists and has not been withdrawn.

Pearson may provide personal information to a third party service provider on a restricted basis to provide marketing solely on behalf of Pearson or an affiliate or customer for whom Pearson is a service provider. Marketing preferences may be changed at any time.

Correcting/Updating Personal Information

If a user's personally identifiable information changes (such as your postal address or email address), we provide a way to correct or update that user's personal data provided to us. This can be done on the Account page. If a user no longer desires our service and desires to delete his or her account, please contact us at customer-service@informit.com and we will process the deletion of a user's account.


Users can always make an informed choice as to whether they should proceed with certain services offered by InformIT. If you choose to remove yourself from our mailing list(s) simply visit the following page and uncheck any communication you no longer want to receive: www.informit.com/u.aspx.

Sale of Personal Information

Pearson does not rent or sell personal information in exchange for any payment of money.

While Pearson does not sell personal information, as defined in Nevada law, Nevada residents may email a request for no sale of their personal information to NevadaDesignatedRequest@pearson.com.

Supplemental Privacy Statement for California Residents

California residents should read our Supplemental privacy statement for California residents in conjunction with this Privacy Notice. The Supplemental privacy statement for California residents explains Pearson's commitment to comply with California law and applies to personal information of California residents collected in connection with this site and the Services.

Sharing and Disclosure

Pearson may disclose personal information, as follows:

  • As required by law.
  • With the consent of the individual (or their parent, if the individual is a minor)
  • In response to a subpoena, court order or legal process, to the extent permitted or required by law
  • To protect the security and safety of individuals, data, assets and systems, consistent with applicable law
  • In connection the sale, joint venture or other transfer of some or all of its company or assets, subject to the provisions of this Privacy Notice
  • To investigate or address actual or suspected fraud or other illegal activities
  • To exercise its legal rights, including enforcement of the Terms of Use for this site or another contract
  • To affiliated Pearson companies and other companies and organizations who perform work for Pearson and are obligated to protect the privacy of personal information consistent with this Privacy Notice
  • To a school, organization, company or government agency, where Pearson collects or processes the personal information in a school setting or on behalf of such organization, company or government agency.


This web site contains links to other sites. Please be aware that we are not responsible for the privacy practices of such other sites. We encourage our users to be aware when they leave our site and to read the privacy statements of each and every web site that collects Personal Information. This privacy statement applies solely to information collected by this web site.

Requests and Contact

Please contact us about this Privacy Notice or if you have any requests or questions relating to the privacy of your personal information.

Changes to this Privacy Notice

We may revise this Privacy Notice through an updated posting. We will identify the effective date of the revision in the posting. Often, updates are made to provide greater clarity or to comply with changes in regulatory requirements. If the updates involve material changes to the collection, protection, use or disclosure of Personal Information, Pearson will provide notice of the change through a conspicuous notice on this site or other appropriate way. Continued use of the site after the effective date of a posted revision evidences acceptance. Please contact us if you have questions or concerns about the Privacy Notice or any objection to any revisions.

Last Update: November 17, 2020