LVM2 Logical Volume Manager 详解(八)--LVM逻辑卷Logical Volume命令实战

1.创建逻辑卷

root@king:~# lvcreate --help
  lvcreate: Create a logical volume

lvcreate 
        [-A|--autobackup {y|n}]
        [-a|--activate [a|e|l]{y|n}]      # 是否创建后可以立即被系统使用,默认ay激活,an不激活,快照只可以在激活的卷上创建。
        [--addtag Tag]
        [--alloc AllocationPolicy]
        [-C|--contiguous {y|n}]           # 是否连续分配
        [-d|--debug]
        [-h|-?|--help]
        [--ignoremonitoring]
        [--monitor {y|n}]
        [-i|--stripes Stripes [-I|--stripesize StripeSize]]
        {-l|--extents LogicalExtentsNumber[%{VG|PVS|FREE}] |                               #<span style="font-family: Arial, Helvetica, sans-serif;">条带大小</span>
         -L|--size LogicalVolumeSize[bBsSkKmMgGtTpPeE]}
        [-M|--persistent {y|n}] [--major major] [--minor minor]
        [-m|--mirrors Mirrors [--nosync] [{--mirrorlog {disk|core|mirrored}|--corelog}]]   #创建镜像数的逻辑卷,
        [-n|--name LogicalVolumeName]    #逻辑卷名称
        [--noudevsync]                   #禁用udev同步
        [-p|--permission {r|rw}]         #设置只读卷或者读写卷
        [-r|--readahead ReadAheadSectors|auto|none]     #设置逻辑卷
        [-R|--regionsize MirrorLogRegionSize]           #镜像区域的大小
        [-T|--thin  [-c|--chunksize  ChunkSize]
          [--discards {ignore|nopassdown|passdown}]
          [--poolmetadatasize MetadataSize[bBsSkKmMgG]]]     #薄池元数据大小,范围2MB-16GB。默认值<span style="font-family: arial, sans-serif; font-size: 13px;">(Pool_LV_size / Pool_LV_chunk_size * 64b),默认单位MB。</span>
        [--thinpool ThinPoolLogicalVolume{Name|Path}]
        [-t|--test]
        [--type VolumeType]          #创建指定段类型的逻辑卷,例如Raid5,镜像,快照,薄卷,薄池。-s是--type snapshot的别称。
        [-v|--verbose]
        [-Z|--zero {y|n}]            #控制是否调零逻辑卷的第一个KB的数据
        [--version]
        VolumeGroupName [PhysicalVolumePath...]

lvcreate 
        { {-s|--snapshot} OriginalLogicalVolume[Path] |      #创建逻辑卷的快照卷
          [-s|--snapshot] VolumeGroupName[Path] -V|--virtualsize VirtualSize}
          {-T|--thin} VolumeGroupName[Path][/PoolLogicalVolume]   #创建薄池卷
                      -V|--virtualsize VirtualSize}
        [-c|--chunksize]                #快照和拨池逻辑卷的块大小,快照的块大小必须是2的整数幂,4KB-512KB,默认4KB。薄池块值64KB-1GB。
        [-A|--autobackup {y|n}]
        [--addtag Tag]
        [--alloc AllocationPolicy]
        [-C|--contiguous {y|n}]
        [-d|--debug]
        [--discards {ignore|nopassdown|passdown}]   #薄池的丢弃行为,默认为passdown
        [-h|-?|--help]
        [--ignoremonitoring]
        [--monitor {y|n}]
        [-i|--stripes Stripes [-I|--stripesize StripeSize]]        #条带数
        {-l|--extents LogicalExtentsNumber[%{VG|FREE|ORIGIN}] |    #条带大小,<span style="font-family: Arial, Helvetica, sans-serif;">分配新逻辑卷的逻辑块大小,</span>
         -L|--size LogicalVolumeSize[bBsSkKmMgGtTpPeE]}            #指定新增逻辑卷的大小
        [--poolmetadatasize Size[bBsSkKmMgG]]
        [-M|--persistent {y|n}] [--major major] [--minor minor]
        [-n|--name LogicalVolumeName]
        [--noudevsync]
        [-p|--permission {r|rw}]
        [-r|--readahead ReadAheadSectors|auto|none]
        [-t|--test]
        [--thinpool ThinPoolLogicalVolume[Path]]
        [-v|--verbose]
        [--version]
        [PhysicalVolumePath...]
创建Raid5逻辑卷

root@king:~# lvcreate --type raid5 -L 1G -i 3 -n lv_1 vg_1
  Using default stripesize 64.00 KiB
  Rounding size (256 extents) up to stripe boundary size (258 extents)
  Logical volume "lv_1" created
root@king:~# pvs
  PV         VG   Fmt  Attr PSize    PFree  
  /dev/sdb1  vg_1 lvm2 a--  1020.00m 672.00m
  /dev/sdb2  vg_1 lvm2 a--     2.00g   1.66g
  /dev/sdb3  vg_1 lvm2 a--  1020.00m 672.00m
  /dev/sdb4  vg_1 lvm2 a--  1020.00m 672.00m
root@king:~# vgs
  VG   #PV #LV #SN Attr   VSize VFree
  vg_1   4   1   0 wz--n- 4.98g 3.62g
type不同,则所需要的条带数大小,需要指定。

2.删除逻辑卷

root@king:~# lvremove --help
  lvremove: Remove logical volume(s) from the system

lvremove
        [-A|--autobackup y|n]
        [-d|--debug]
        [-f|--force]
        [-h|--help]
        [--noudevsync]    #禁用udev同步
        [-t|--test]
        [-v|--verbose]
        [--version]
        LogicalVolume[Path] [LogicalVolume[Path]...]

3.修改逻辑卷

root@king:~# lvchange --help
  lvchange: Change the attributes of logical volume(s)

lvchange
        [-A|--autobackup y|n]
        [-a|--activate [a|e|l]{y|n}]
        [--addtag Tag]
        [--alloc AllocationPolicy]
        [-C|--contiguous y|n]
        [-d|--debug]
        [--deltag Tag]
        [-f|--force]
        [-h|--help]
        [--discards {ignore|nopassdown|passdown}]
        [--ignorelockingfailure]
        [--ignoremonitoring]
        [--monitor {y|n}]
        [--poll {y|n}]
        [--noudevsync]
        [-M|--persistent y|n] [--major major] [--minor minor]
        [-P|--partial] 
        [-p|--permission r|rw]
        [-r|--readahead ReadAheadSectors|auto|none]
        [--refresh]          #逻辑卷如果是激活的,刷新元数据。
        [--resync]           #强制镜像同步
        [--sysinit]
        [-t|--test]
        [-v|--verbose]
        [-y|--yes]
        [--version]
        [-Z|--zero {y|n}]
        LogicalVolume[Path] [LogicalVolume[Path]...]

4.逻辑卷转换

root@king:~# lvconvert --help
  lvconvert: Change logical volume layout

lvconvert [-m|--mirrors Mirrors [{--mirrorlog {disk|core|mirrored}|--corelog}]]
        [--type SegmentType]
        [--repair [--use-policies]]
        [--replace PhysicalVolume]
        [-R|--regionsize MirrorLogRegionSize]
        [--alloc AllocationPolicy]
        [-b|--background]
        [-d|--debug]
        [-f|--force]
        [-h|-?|--help]
        [-i|--interval seconds]
        [--stripes Stripes [-I|--stripesize StripeSize]]
        [--noudevsync]
        [-v|--verbose]
        [-y|--yes]
        [--version]
        LogicalVolume[Path] [PhysicalVolume[Path]...]

lvconvert [--splitmirrors Images --trackchanges]
[--splitmirrors Images --name SplitLogicalVolumeName]
        LogicalVolume[Path] [SplittablePhysicalVolume[Path]...]

lvconvert [-s|--snapshot]
        [-c|--chunksize]
        [-d|--debug]
        [-h|-?|--help]
        [--noudevsync]
        [-v|--verbose]
        [-Z|--zero {y|n}]
        [--version]
        OriginalLogicalVolume[Path] SnapshotLogicalVolume[Path]

lvconvert --merge
        [-b|--background]
        [-i|--interval seconds]
        [-d|--debug]
        [-h|-?|--help]
        [-v|--verbose]
        LogicalVolume[Path]

lvconvert --thinpool ThinPoolLogicalVolume[Path]
        [--chunksize size]
        [--discards {ignore|nopassdown|passdown}]
        [[--poolmetadatasize size] | --poolmetadata ThinMetadataLogicalVolume[Path]]
        [-Z|--zero {y|n}]
        [-d|--debug] [-h|-?|--help] [-v|--verbose]

5.扩展逻辑卷

root@king:~# lvextend --help
  lvextend: Add space to a logical volume

lvextend
        [-A|--autobackup y|n]
        [--alloc AllocationPolicy]
        [-d|--debug]
        [-f|--force]
        [-h|--help]
        [-i|--stripes Stripes [-I|--stripesize StripeSize]]      #扩展条带数
        {-l|--extents [+]LogicalExtentsNumber[%{VG|LV|PVS|FREE|ORIGIN}] |
         -L|--size [+]LogicalVolumeSize[bBsSkKmMgGtTpPeE]}       #扩展逻辑块大小
        [-m|--mirrors Mirrors]
        [--nosync]
        [--use-policies]
        [-n|--nofsck]
        [--noudevsync]
        [-r|--resizefs]
        [-t|--test]
        [--type VolumeType]
        [-v|--verbose]
        [--version]
        LogicalVolume[Path] [ PhysicalVolumePath... ]

6.缩减逻辑卷

root@king:~# lvreduce --help
  lvreduce: Reduce the size of a logical volume

lvreduce
        [-A|--autobackup y|n]
        [-d|--debug]
        [-f|--force]
        [-h|--help]
        {-l|--extents [-]LogicalExtentsNumber[%{VG|LV|FREE|ORIGIN}] |
         -L|--size [-]LogicalVolumeSize[bBsSkKmMgGtTpPeE]}
        [-n|--nofsck]
        [--noudevsync]
        [-r|--resizefs]         #和逻辑卷一起调整底层文件系统大小,使用fsadm
        [-t|--test]
        [-v|--verbose]
        [-y|--yes]
        [--version]
        LogicalVolume[Path]

7.重命名,修改大小

root@king:~# lvrename --help
  lvrename: Rename a logical volume

lvrename
        [-A|--autobackup {y|n}] 
        [-d|--debug] 
        [-h|-?|--help] 
        [--noudevsync]
        [-t|--test] 
        [-v|--verbose]
        [--version] 
        { OldLogicalVolumePath NewLogicalVolumePath |
          VolumeGroupName OldLogicalVolumeName NewLogicalVolumeName }

root@king:~# lvresize --help 
  lvresize: Resize a logical volume

lvresize
        [-A|--autobackup y|n]
        [--alloc AllocationPolicy]
        [-d|--debug]
        [-f|--force]
        [-h|--help]
        [-i|--stripes Stripes [-I|--stripesize StripeSize]]
        {-l|--extents [+|-]LogicalExtentsNumber[%{VG|LV|PVS|FREE|ORIGIN}] |
         -L|--size [+|-]LogicalVolumeSize[bBsSkKmMgGtTpPeE]}
        [-n|--nofsck]
        [--noudevsync]
        [-r|--resizefs]
        [-t|--test]
        [--type VolumeType]
        [-v|--verbose]
        [--version]
        LogicalVolume[Path] [ PhysicalVolumePath... ]

8.显示信息

root@king:~# lvdisplay --help
  lvdisplay: Display information about a logical volume

lvdisplay
        [-a|--all]
        [-c|--colon]
        [-d|--debug]
        [-h|--help]
        [--ignorelockingfailure]
        [-m|--maps]
        [--nosuffix]
        [-P|--partial] 
        [--units hHbBsSkKmMgGtTpPeE]
        [-v|--verbose]
        [--version]
        [LogicalVolume[Path] [LogicalVolume[Path]...]]

lvdisplay --columns|-C
        [--aligned]
        [-a|--all]
        [-d|--debug]
        [-h|--help]
        [--ignorelockingfailure]
        [--noheadings]
        [--nosuffix]
        [-o|--options [+]Field[,Field]]
        [-O|--sort [+|-]key1[,[+|-]key2[,...]]]
        [-P|--partial] 
        [--segments]
        [--separator Separator]
        [--unbuffered]
        [--units hHbBsSkKmMgGtTpPeE]
        [-v|--verbose]
        [--version]
        [LogicalVolume[Path] [LogicalVolume[Path]...]]

9.扫描卷组

root@king:~# lvscan --help
  lvscan: List all logical volumes in all volume groups

lvscan 
        [-a|--all]
        [-b|--blockdevice] 
        [-d|--debug] 
        [-h|-?|--help] 
        [--ignorelockingfailure]
        [-P|--partial] 
        [-v|--verbose] 
        [--version]
root@king:~# lvmdiskscan --help
  lvmdiskscan: List devices that may be used as physical volumes

lvmdiskscan
        [-d|--debug]
        [-h|--help]
        [-l|--lvmpartition]
        [--version]

10.显示所有类型

root@king:~# lvm segtypes
  striped
  zero
  error
  free
  snapshot
  mirror
  raid1
  raid10
  raid4
  raid5
  raid5_la
  raid5_ra
  raid5_ls
  raid5_rs
  raid6
  raid6_zr
  raid6_nr
  raid6_nc
  thin-pool
  thin


你可能感兴趣的:(LVM2 Logical Volume Manager 详解(八)--LVM逻辑卷Logical Volume命令实战)