System and processes
The lvcreate command
Creates a logical volume (LV) inside a group, like a flexible partition.
Most useful options
-L tamañoAbsolute size of the volume with a unit, for example 2G or 500M.-l extensionesSize in logical extents or as a percentage. 100%FREE uses all the free space in the group.-n nombreName of the volume. If you omit it, LVM generates one named lvol followed by a number.-i númeroNumber of disks (PV) across which the volume data is spread in stripes (striped).-W y|nControls detection and wiping of signatures left by previous data on the new volume.-yDoes not ask for confirmation and answers yes. Use it only in reviewed scripts.Copy-ready examples
$ sudo lvschecks the volumes that already exist before creating a new one.$ sudo lvcreate -L 2G -n web datoscreates a 2 GB volume named web in the datos group.$ sudo lvcreate -l 100%FREE -n todo datosuses all the free space in the group for a single volume.$ sudo lvcreate -L 4G -i 2 -n rapido datosspreads the volume in stripes over two PVs, so the group needs at least two.You can try them in the browser terminal: it does not touch your computer.
Common errors
| Message | Cause | Fix |
|---|---|---|
| Logical Volume "web" already exists in volume group "datos" | A volume with that name already exists in the group. | Pick another name with -n, or list the existing ones with sudo lvs datos. |
| Volume group "datos" has insufficient free space (512 extents): 1024 required. | You asked for more extents than the group has free. The numbers are the ones in the message and change case by case. | Ask for less space, or extend the group with vgextend first. |
Typical mistakes
- The LV lives at /dev/datos/web: group and name separated by a slash. That is where you format and mount it.
- Without a format the volume has no filesystem and cannot be mounted. Give it one with mkfs.ext4.
- If -L asks for more space than the group has, the operation fails. Check the free space with vgs first.
Differences from similar commands
FAQ
What does lvcreate do?
It reserves space inside a volume group and creates a logical volume with the name you give it.
What is the difference between -L and -l?
-L sets the size with a unit, such as 2G. -l sets it in logical extents or as a percentage, such as 100%FREE.
How do I make it ready to store files?
Create a filesystem on it with mkfs.ext4 on /dev/datos/web, then mount it on a folder with mount.
Learn to actually use it
The basic Linux course takes you from zero to console fluency with 24 self-grading lessons.
Start the free course