Creating and Managing Logical Volumes
This example creates the logical volume
mylv of size 2 GB in the volume group
myvg:
sudo lvcreate -v --size 2g --name mylv myvg
The following output is displayed:
Archiving volume group “myvg” metadata (seqno 1). Creating logical volume mylv Create volume group backup “/etc/lvm/backup/myvg” (seqno 2). Activating logical volume myvg/mylv. ... Logical volume "mylv" created.
lvcreate uses the device mapper to create a
block device file entry under /dev for each
logical volume. The command also 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,
to which /dev/mapper/myvg-mylv and
/dev/myvg/mylv are symbolically linked.
In commands or scripts, always refer to the devices in /dev/mapper or
/dev/
volume_group, rather than to /dev/dm-*. Those names are
persistent and are created automatically by the device mapper early in the boot process. In
contrast, the /dev/dm-* devices aren't guaranteed to be persistent across
reboots.
You manage and use a logical volume as you would a physical storage device, such as configuring a logical volume as a file system, a swap partition, an Automatic Storage Management (ASM) disk, or a raw device.
To display information about logical volumes, use the lvdisplay, lvs, and lvscan commands.
To remove a logical volume from a volume group, use the lvremove command:
sudo lvremove vol_group/logical_vol
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.