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 volumeslvmdiskscan        [-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



注意!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系我们删除。



 
粤ICP备14056181号  © 2014-2021 ITdaan.com