Linux - The Linux Logical Volume Manager (Logical Partition)


LVM adds an abstraction layer between filesystems and partitions.

Logical volume management is a widely-used technique for deploying logical rather than physical storage. With LVM, “logical” partitions can span across physical hard drives and can be resized (unlike traditional ext3 “raw” partitions). A physical disk is divided into one or more physical volumes (Pvs), and logical volume groups (VGs) are created by combining PVs as shown below. Notice the VGs can be an aggregate of PVs from multiple physical disks.

Linux Lvm

LVM adds an abstraction layer between filesystems and partitions. This is extremely handy because it's easy to add a disk (which is made physical volume) to a volume group which makes space available, which can be added to any logical volume in the volume group. When that's done, the filesystem in the logical volume can be enlarged with resize2fs, even online. Without LVM, it's not possible or very hard at best to do that.

To know all the command of the Logical Volume Manager tape:

man lvm

because lvm use a lot of symlink.

Basic LVM commands

The basic

To start lvm (the logical volume manager software), just tape lvm on the command prompt. To have:

  • a list of all lvm command, tape help
  • an help for one specific command, tape “help lvmcommand


[root@oel11g ~]# lvm
lvm> help
  Available lvm commands:
  Use 'lvm help <command>' for more information

  dumpconfig      Dump active configuration
  formats         List available metadata formats
  help            Display help for commands
  lvchange        Change the attributes of logical volume(s)
lvm> help pvresize
  pvresize: Resize physical volume(s)

        [--setphysicalvolumesize PhysicalVolumeSize[kKmMgGtTpPeE]
        PhysicalVolume [PhysicalVolume...]

Converting disks or disk partitions into physical volumes (PVs)

To use LVM, partitions and whole disks must first be converted/initialized into physical volumes (PVs) using the pvcreate command.

In a “normal” production system it is recommended that only one PV exists on a single real disk, for the following reasons:

  • Administrative convenience

It's easier to keep track of the hardware in a system if each real disk only appears once. This becomes particularly true if a disk fails.

  • To avoid striping performance problems

LVM can't tell that two PVs are on the same physical disk, so if you create a striped LV then the stripes could be on different partitions on the same disk resulting in a decrease in performance rather than an increase.

Whole disks

For example, to convert /dev/sda and /dev/sdb into PVs use the following commands:

pvcreate /dev/sda
pvcreate /dev/sdb


If a Linux partition is to be converted make sure that it is given partition type 0x8E using fdisk:

[root@ebs121 ~]# fdisk -l

Disk /dev/sda: 375.8 GB, 375809638400 bytes
255 heads, 63 sectors/track, 45689 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          13      104391   83  Linux
/dev/sda2              14        2610    20860402+  8e  Linux LVM

then use pvcreate:

pvcreate /dev/sda2

Creating/Managing a volume group (VG)

Once you have one or more physical volumes created, you can create a volume group from these PVs using the vgcreate command.

The following command:

vgcreate  volume_group_one /dev/hda /dev/hdb

creates a new VG called volume_group_one with two disks, /dev/hda and /dev/hdb, and 4 MB PEs. If both /dev/hda and /dev/hdb are 128 GB in size, then the VG volume_group_one will have a total of 2**16 physical extents that can be allocated to logical volumes.

Additional PVs can be added to this volume group using the vgextend command. The following commands convert /dev/hdc into a PV and then adds that PV to volume_group_one:

pvcreate /dev/hdc
vgextend volume_group_one /dev/hdc

This same PV can be removed from volume_group_one by the vgreduce command:

vgreduce volume_group_one /dev/hdc

Note that any logical volumes using physical extents from PV /dev/hdc will be removed as well. This raises the issue of how we create an LV within a volume group in the first place.

pvdisplay will show an which VG belongs a PV

[root@ebs121 ~]# pvdisplay
  /dev/hdc: open failed: No medium found
  --- Physical volume ---
  PV Name               /dev/sda2
  VG Name               VolGroup00
  PV Size               19.89 GB / not usable 19.49 MB
  Allocatable           yes (but full)
  PE Size (KByte)       32768
  Total PE              636
  Free PE               0
  Allocated PE          636
  PV UUID               rg85Xj-lu0n-HWmE-50D5-8SfC-AGtC-Ln0JaL

Logical Volume

[root@ebs121 ~]# lvdisplay
  --- Logical volume ---
  LV Name                /dev/VolGroup00/LogVol00
  VG Name                VolGroup00
  LV UUID                B0EwV0-5XTH-1GLF-LTW2-8q9q-3Ou0-rsggEM
  LV Write Access        read/write
  LV Status              available
  # open                 1
  LV Size                347.94 GB
  Current LE             11134
  Segments               2
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:0

Extending a logical volume

An LV can be extended by using the lvextend command. You can specify either an absolute size for the extended LV or how much additional storage you want to add to the LVM. For example:

[root@ebs121 ~]# lvextend -L+330G /dev/VolGroup00/LogVol00
  Extending logical volume LogVol00 to 347.94 GB
  Logical volume LogVol00 successfully resized

will extend LV /dev/VolGroup00/LogVol00 by an additional 330 GB.

Once a logical volume has been extended, the underlying file system can be expanded to exploit the additional storage now available on the LV.

Documentation / Reference

Discover More
Card Puncher Data Processing
Data Storage - Data Striping (I/O parallelism)

In computer data storage, data striping is the technique of segmenting logically sequential data, such as a file, in a way that accesses of sequential segments are made to different physical storage devices....
Windows Disk
File System - Partition table (Sector 0)

A partition table is data that holds partition division information. The partition table is stored within the Master Boot Record of the disk (found in the first sector (0) of the disk) Partition table...
Linux - Adding storage depends of LVM

When you need to add disk storage to a linux environement, the tasks depend of if you want to use or not the Linux Logical Volume Manager.. Without LVM, a filesystem is created inside a partition....
Linux - Adding storage without LVM

When you add a disk device to your system, you need to add this storage in your Linux environment When you improve the disk capacity of your Virtual Vmware Machine, you just need to configure the device...
Windows Disk
Linux - Disk Partition (logical disk)

Hard disks can be divided into one or more logical disks called partition. This division is described in the partition table found in sector 0 of the disk. The partition is the last part of...
Linux - How to add storage to an OEL 5 update 4 Linux VMWare Machine

When you increase the disk capacity of a VMWare virtual machine, you need to perform some operation to add this capacity to the file system. The basic installation of Oracle Entreprise Linux use Linux...
Linux Skip Mounting File System
Linux - How to reduce a root LVM logical volume

How to reduce a root LVM logical volume on a default FC3 Boot in rescue mode Skip mounting of the system partitions. Enter the following command Verify: Space get the Logical Volume...
Linux - Mounting File Systems (CDROM, NFS, SMB, )

All files accessible in a Unix system are arranged in one big tree, the file hierarchy, rooted at /. These files can be spread out over several devices. The mount command serves to attach the file...
Linux - Storage

Linux - Storage
Card Puncher Data Processing
Oracle Database - ASM (Automatic Storage Management)

Starting with Oracle Database 10g ( or later), Automatic Storage Management is a high-performance storage management solution. For Oracle Database files, it simplifies the management of a dynamic...

Share this page:
Follow us:
Task Runner