4.2. Creating LVM logical volume
This procedure describes how to create mylv LVM logical volume (LV) from the myvg volume group, which is created by using the /dev/vdb1, /dev/vdb2, and /dev/vdb3 physical volumes.
Conditions préalables
-
The
lvm2package is installed. - The volume group is created. For more information, see Creating LVM volume group.
Procédure
Create a logical volume:
lvcreate -n mylv -L 500M myvg
# lvcreate -n mylv -L 500M myvgCopy to Clipboard Copied! Toggle word wrap Toggle overflow Use the
-noption to set the LV name to mylv, and the-Loption to set the size of LV in units of Mb, but it is possible to use any other units. The LV type is linear by default, but the user can specify the desired type by using the--typeoption.ImportantThe command fails if the VG does not have a sufficient number of free physical extents for the requested size and type.
View the created logical volumes by using any one of the following commands as per your requirement:
The
lvscommand provides logical volume information in a configurable form, displaying one line per logical volume:lvs
# lvs LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert mylv myvg -wi-ao---- 500.00mCopy to Clipboard Copied! Toggle word wrap Toggle overflow The
lvdisplaycommand displays logical volume properties, such as size, layout, and mapping in a fixed format:Copy to Clipboard Copied! Toggle word wrap Toggle overflow The
lvscancommand scans for all logical volumes in the system and lists them:lvscan
# lvscan ACTIVE '/dev/myvg/mylv' [500.00 MiB] inheritCopy to Clipboard Copied! Toggle word wrap Toggle overflow
Create a file system on the logical volume. The following command creates an
xfsfile system on the logical volume:Copy to Clipboard Copied! Toggle word wrap Toggle overflow Mount the logical volume and report the file system disk space usage:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow