17.3 About Logical Volume Manager

17.3.1 Initializing and Managing Physical Volumes
17.3.2 Creating and Managing Volume Groups
17.3.3 Creating and Managing Logical Volumes

You can use Logical Volume Manager (LVM) to manage multiple physical volumes and configure mirroring and striping of logical volumes to provide data redundancy and increase I/O performance. In LVM, you first create volume groups from physical volumes, which are storage devices such as disk array LUNs, software or hardware RAID devices, hard drives, and disk partitions. You can then create logical volumes in a volume group. A logical volume functions as a partition that in its implementation might be spread over multiple physical disks.

You can create file systems on logical volumes and mount the logical volume devices in the same way as you would a physical device. If a file system on a logical volume becomes full with data, you can increase the capacity of the volume by using free space in the volume group so that you can then grow the file system (provided that the file system has that capability). If necessary, you can add physical storage devices to a volume group to increase its capacity.

LVM is non-disruptive and transparent to users. You can increase the size of logical volumes and change their layout dynamically without needing to schedule system down time to reconfigure physical storage.

LVM uses the device mapper (DM) that provides an abstraction layer that allows the creation of logical devices above physical devices and provides the foundation for software RAID, encryption, and other storage features.

17.3.1 Initializing and Managing Physical Volumes

Before you can create a volume group, you must initialize the physical devices that you want to use as physical volumes with LVM.


If the devices contain any existing data, back up the data.

To set up a physical device as a physical volume, use the pvcreate command:

# pvcreate [options] device ...

For example, set up /dev/sdb, /dev/sdc, /dev/sdd, and /dev/sde as physical volumes:

# pvcreate -v /dev/sd[bcde]
Set up physical volume for “/dev/sdb” with 6313482 available
Zeroing start of device /dev/sdb
Physical volume “/dev/sdb” successfully created

To display information about physical volumes, you can use the pvdisplay, pvs, and pvscan commands.

To remove a physical volume from the control of LVM, use the pvremove command:

# pvremove device

Other commands that are available for managing physical volumes include pvchange, pvck, pvmove, and pvresize.

For more information, see the lvm(8), pvcreate(8), and other LVM manual pages.

17.3.2 Creating and Managing Volume Groups

Having initialized the physical volumes, you can add them to a new or existing volume group.

To create a volume group, use the vgcreate command:

# vgcreate [options] volume_group physical_volume ...

For example, create the volume group myvg from the physical volumes /dev/sdb, /dev/sdc, /dev/sdd, and /dev/sde:

# vgcreate -v myvg /dev/sd[bcde]
Wiping cache of LVM-capable devices
Adding physical volume ‘/dev/sdb’ to volume group ‘myvg’
Adding physical volume ‘/dev/sdc’ to volume group ‘myvg’
Adding physical volume ‘/dev/sdd’ to volume group ‘myvg’
Adding physical volume ‘/dev/sde’ to volume group ‘myvg’
Archiving volume group “myvg” metadata (seqno 0).
Creating volume group backup “/etc/lvm/backup/myvg” (seqno 1).
Volume group “myvg” successfully created

LVM divides the storage space within a volume group into physical extents, which are the smallest unit that LVM uses when allocating storage to logical volumes. The default size of an extent is 4 MB.

The allocation policy for the volume group and logical volume determines how LVM allocates extents from a volume group. The default allocation policy for a volume group is normal, which applies rules such as not placing parallel stripes on the same physical volume. The default allocation policy for a logical volume is inherit, which means that the logical volume uses the same policy as for the volume group. You can change the default allocation policies by using the lvchange or vgchange commands, or you can override the allocation policy when you create a volume group or logical volume. Other allocation policies include anywhere, contiguous and cling.

To add physical volumes to a volume group, use the vgextend command:

# vgextend [options] volume_group physical_volume ...

To remove physical volumes from a volume group, use the vgreduce command:

# vgreduce [options] volume_group physical_volume ...

To display information about volume groups, you can use the vgdisplay, vgs, and vgscan commands.

To remove a volume group from LVM, use the vgremove command:

# vgremove volume_group

Other commands that are available for managing volume groups include vgchange, vgck, vgexport, vgimport, vgmerge, vgrename, and vgsplit.

For more information, see the lvm(8), vgcreate(8), and other LVM manual pages.

17.3.3 Creating and Managing Logical Volumes

Having create a volume group of physical volumes, you can create logical volumes from the storage space that is available in the volume group.

To create a logical volume, use the lvcreate command:

# lvcreate [options] --size size --name logical_volume volume_group

For example, create the logical volume mylv of size 2 GB in the volume group myvg:

# lvcreate -v --size 2g --name mylv myvg
Setting logging type to disk
Finding volume group “myvg”
Archiving volume group “myvg” metadata (seqno 1).
Creating logical volume mylv
Create volume group backup “/etc/lvm/backup/myvg” (seqno 2).

lvcreate uses the device mapper to create a block device file entry under /dev for each logical volume and uses udev to set up symbolic links to this device file from /dev/mapper and /dev/volume_group. For example, the device that corresponds to the logical volume mylv in the volume group myvg might be /dev/dm-3, which is symbolically linked by /dev/mapper/myvolg-myvol and /dev/myvolg/myvol.


Always use the devices in /dev/mapper or /dev/volume_group. These names are persistent and are created automatically by the device mapper early in the boot process. The /dev/dm-* devices are not guaranteed to be persistent across reboots.

Having created a logical volume, you can configure and use it in the same way as you would a physical storage device. For example, you can configure a logical volume as a file system, swap partition, Automatic Storage Management (ASM) disk, or raw device.

You can also use lvcreate to create a snapshot of an existing logical volume such as mylv in the volume group myvg, for example:

# lvcreate --size 500m –-snapshot –-name mylv-snapshot myvg/mylv
  Logical volume “mylv-snapshot” created

You can mount and modify the contents of the snapshot independently of the original volume or preserve it as a record of the state of the original volume at the time that you took the snapshot. The snapshot usually takes up less space than the original volume, depending on how much the contents of the volumes diverge over time. In the example, we assume that the snapshot only requires one quarter of the space of the original volume. You can use the value shown by the Snap% column in the output from the lvs command to see how much data is allocated to the snapshot. If the value of Snap% approaches 100%, indicating that a snapshot is running out of storage, use lvresize to grow it. Alternatively, you can reduce a snapshot's size to save storage space. To merge a snapshot with its original volume, use the lvconvert command, specifying the --merge option.

To display information about logical volumes, you can use the lvdisplay, lvs, and lvscan commands.

To remove a logical volume from a volume group, use the lvremove command:

# lvremove volume_group/logical_volume

You must specify both the name of the volume group and the logical volume.

Other commands that are available for managing logical volumes include lvchange, lvconvert, lvmdiskscan, lvmsadc, lvmsar, lvrename, and lvresize.

For more information, see the lvm(8), lvcreate(8), and other LVM manual pages.