19.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.

Note

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.

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
Note

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.