web123456

【Linux】Linux command: lvcreate trick

Creates a logical volume of LVM. Logical volumes are created on top of volume groups. The device file corresponding to the logical volume is saved in the volume group directory. For example, create a logical volume "lvol0" on the volume group "vg1000", and the device file corresponding to the logical volume is "/dev/vg1000/lvol0".

From:/lvcreate
Creates a logical volume of LVM. Logical volumes are created on top of volume groups. The device file corresponding to the logical volume is saved in the volume group directory. For example, create a logical volume "lvol0" on the volume group "vg1000", and the device file corresponding to the logical volume is "/dev/vg1000/lvol0".

From:/lvcreate
Use the lvcreate commandCreate a logical volume of LVM

A logical volume is created on a volume group, and the device files corresponding to the logical volume are saved in the volume group directory;

For example: create a logical volume "lv_1" on the volume group "vg_1", and the device file corresponding to this logical volume is "/dev/vg_1/lv_1".

Syntax lvcreate(option)(parameters)

From:/lvcreate
grammar
lvcreate(option)(parameters)

Command description

[root@mwd ~]# lvcreate --help

lvcreate: Create a logical volume
lvcreate
[-A|--autobackup {y|n}] (autobackup)
        [-a|--activate [a|e|l]{y|n}]
[--addtag ​​Tag] (add tag)
[--alloc AllocationPolicy] (Assignment Policy)
[--cachemode CacheMode] (Cache mode)
        [-C|--contiguous {y|n}]
        [-d|--debug]
        [-h|-?|--help]
[--ignoremonitoring] (ignoremonitoring)
[--monitor {y|n}] (monitor)
        [-i|--stripes Stripes [-I|--stripesize StripeSize]]
        [-k|--setactivationskip {y|n}]
        [-K|--ignoreactivationskip]
        {-l|--extents LogicalExtentsNumber[%{VG|PVS|FREE}] | (Logical extension number)
         -L|--size LogicalVolumeSize[bBsSkKmMgGtTpPeE]} (logical volume size)
        [-M|--persistent {y|n}] [--major major] [--minor minor]
[-m|--mirrors Mirrors [--nosync] [{--mirrorlog {disk|core|mirrored}|--corelog}]] (mirrors)
        [-n|--name LogicalVolumeName] (logical volume name)
        [--noudevsync]
        [-p|--permission {r|rw}]
        [--[raid]minrecoveryrate Rate]
        [--[raid]maxrecoveryrate Rate]
[-r|--readahead ReadAheadSectors|auto|none] (read head sector)
[-R|--regionsize MirrorLogRegionSize] (mirror logic region size)
[-T|-thin [-c|--chunksize  ChunkSize] (block size)
          [--discards {ignore|nopassdown|passdown}]
          [--poolmetadatasize MetadataSize[bBsSkKmMgG]]]
          [--poolmetadataspare {y|n}]
[--thinpool ThinPoolLogicalVolume{Name|Path}] (Simplified pool logic volume)
        [-t|--test]
[--type VolumeType] (volume type)
        [-v|--verbose]
        [-W|--wipesignatures {y|n}]
        [-Z|--zero {y|n}]
        [--version]

        VolumeGroupName [PhysicalVolumePath...]

Common examples:

(1) Create a lv of the specified size and specify the name lv_2

lvcreate -L 2G -n lv_2 vg_1

(2) Create a lv that accounts for all volume groups and specify the name lv_3 (note that vg does not create lv)

lvcreate -l 100%VG -n lv_3 vg_1

(3)Create an lv with 80% of the size of free space and specify the name lv_4 (commonly used)

lvcreate -l 80%Free -n lv_4 vg_1