Creating an LVM logical volume turns free extents in an existing volume group into a named block device for a filesystem, swap area, database volume, or another storage layer. Choose the size and name before running lvcreate because the new LV reserves capacity from the VG immediately.
The lvcreate command allocates space from the volume group and activates the new device under paths such as /dev/vgdata/projects and /dev/mapper/vgdata-projects. The example creates a standard linear logical volume for one ordinary block device from existing LVM free space.
Check the volume group's VFree value before creating the LV, and leave unallocated space for snapshots, growth, or sibling volumes when those are planned. The new logical volume remains raw storage until it is formatted, mounted, encrypted, or assigned to an application.
Related: How to create an LVM physical volume
Related: How to create an LVM volume group
Related: How to remove an LVM logical volume
Steps to create an LVM logical volume:
- Check free space in the target volume group.
$ sudo vgs vgdata VG #PV #LV #SN Attr VSize VFree vgdata 2 0 0 wz--n- 200.00g 120.00g
Replace vgdata with the volume group that should provide space for the new logical volume. The VFree column must be at least as large as the size requested in the next step.
- Create the logical volume.
$ sudo lvcreate --size 20G --name projects vgdata Logical volume "projects" created.
The command creates /dev/vgdata/projects from 20G of free space in vgdata. Use a name that describes the workload because changing it later can require updates to mounts, service configs, or application paths.
- List the new logical volume.
$ sudo lvs --options lv_name,vg_name,lv_size,lv_attr,devices vgdata/projects LV VG LSize Attr Devices projects vgdata 20.00g -wi-a----- /dev/sdb1(0)
The -wi-a—– attribute shows a writable, inherited-allocation, active linear logical volume. The Devices column shows where LVM placed the first extent.
- Confirm the active block device path.
$ lsblk /dev/vgdata/projects NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS vgdata-projects 253:0 0 20G 0 lvm
No filesystem appears in the MOUNTPOINTS column until the logical volume is formatted and mounted or used by another storage layer.
Mohd Shakir Zakaria is a cloud architect with deep roots in software development and open-source advocacy. Certified in AWS, Red Hat, VMware, ITIL, and Linux, he specializes in designing and managing robust cloud and on-premises infrastructures.