Answers:
该pvdisplay
命令具有-m
显示物理盘区到逻辑卷和逻辑盘区的映射的选项。
我在测试机上设置了以下情况:
pvdisplay -m
在此计算机上运行将产生以下输出:
[root@centos6 ~]# pvdisplay -m
--- Physical volume ---
PV Name /dev/sdb
VG Name vg_test
PV Size 1.00 GiB / not usable 4.00 MiB
Allocatable yes
PE Size 4.00 MiB
Total PE 255
Free PE 5
Allocated PE 250
PV UUID eR2ko2-aKRf-uCfq-O2L0-z6em-ZYT5-23YhKb
--- Physical Segments ---
Physical extent 0 to 74:
Logical volume /dev/vg_test/one
Logical extents 0 to 74
Physical extent 75 to 149:
Logical volume /dev/vg_test/two
Logical extents 0 to 74
Physical extent 150 to 249:
Logical volume /dev/vg_test/four
Logical extents 0 to 99
Physical extent 250 to 254:
FREE
--- Physical volume ---
PV Name /dev/sdc
VG Name vg_test
PV Size 1.00 GiB / not usable 4.00 MiB
Allocatable yes
PE Size 4.00 MiB
Total PE 255
Free PE 10
Allocated PE 245
PV UUID rByjXK-NA6D-ifnY-lKdF-eFWg-Ndou-psGJUq
--- Physical Segments ---
Physical extent 0 to 124:
Logical volume /dev/vg_test/three
Logical extents 0 to 124
Physical extent 125 to 224:
Logical volume /dev/vg_test/five
Logical extents 0 to 99
Physical extent 225 to 244:
Logical volume /dev/vg_test/six
Logical extents 255 to 274
Physical extent 245 to 254:
FREE
--- Physical volume ---
PV Name /dev/sdd
VG Name vg_test
PV Size 1.00 GiB / not usable 4.00 MiB
Allocatable yes (but full)
PE Size 4.00 MiB
Total PE 255
Free PE 0
Allocated PE 255
PV UUID TCJnZM-0ss9-o5gY-lgD3-7Kq6-18IH-sN04To
--- Physical Segments ---
Physical extent 0 to 254:
Logical volume /dev/vg_test/six
Logical extents 0 to 254
如您所见,您可以很好地了解6个逻辑卷中每个逻辑卷的范围。
-m
切换。谢谢!
dmsetup table <dev>
可以帮上忙。
我用:
lvs -o +devices
...我觉得更容易解释。
lvs --segments -o +devices
也建议/相反,如果您的LV跨越多个PV,则可以查看哪些段位于哪个PV上
LVM是从物理磁盘到文件系统(磁盘⇒分区⇒LVM的物理卷[PV]⇒LVM的卷组[VG]⇒LVM逻辑卷[LV]⇒文件系统)之间的灵活抽象层。
由于某些LVM功能(聚合,镜像,条纹,快照...),物理布局可能会变得复杂...因此需要注意以下几点:
--all
查看(镜像卷的)内部详细信息。为了快速浏览,我建议使用lsblk(这是标准工具,而不是LVM专用)。
$ lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 223,6G 0 disk
├─sda1 8:1 0 350M 0 part
├─sda2 8:2 0 29G 0 part
├─sda3 8:3 0 488M 0 part /boot
├─sda4 8:4 0 1K 0 part
└─sda5 8:5 0 193,8G 0 part
├─vg_ssd-lv_root_solid 254:0 0 13,3G 0 lvm /
├─vg_ssd-lv_srv_solid 254:2 0 46,6G 0 lvm /srv
└─vg_ssd-lv_home_solid 254:3 0 107G 0 lvm /home
sdb 8:16 0 74,5G 0 disk
└─sdb1 8:17 0 74,5G 0 part
├─vg_ssd-lv_swap_solid 254:1 0 3,7G 0 lvm [SWAP]
└─vg_ssd-lv_videos 254:4 0 28G 0 lvm /mnt/videos
要获取LVM的内部视图和详细信息,请使用LVM命令:
lvs
and pvs
命令与选项一起使用--segments
lvdisplay
and pvdisplay
命令与选项一起使用-m
列出逻辑卷使用的物理段:
$ lvs --segments /dev/vg_ssd/lv_videos
LV VG Attr #Str Type SSize
lv_videos vg_ssd -wi-ao---- 1 linear 20,95g
lv_videos vg_ssd -wi-ao---- 1 linear 7,05g
相同,但有更多详细信息:
$ lvs --segments /dev/vg_ssd/lv_videos -o +lv_size,devices
LV VG Attr #Str Type SSize LSize Devices
lv_videos vg_ssd -wi-ao---- 1 linear 20,95g 28,00g /dev/sdb1(12729)
lv_videos vg_ssd -wi-ao---- 1 linear 7,05g 28,00g /dev/sdb1(3534)
列出给定LV的物理范围。用来移动这些段(使用pvmove
)很有用:
$ lvs /dev/vg_ssd/lv_videos -o seg_pe_ranges
PE Ranges
/dev/sdb1:12729-18090
/dev/sdb1:3534-5339
相反,在给定的物理卷中列出逻辑卷(段):
$ pvs /dev/sdb1 --segments -o +lv_name,lv_size
PV VG Fmt Attr PSize PFree Start SSize LV LSize
/dev/sdb1 vg_ssd lvm2 a-- 74,53g 22,80g 0 3534 0
/dev/sdb1 vg_ssd lvm2 a-- 74,53g 22,80g 3534 1806 lv_videos 28,00g
/dev/sdb1 vg_ssd lvm2 a-- 74,53g 22,80g 5340 1316 0
/dev/sdb1 vg_ssd lvm2 a-- 74,53g 22,80g 11776 953 lv_swap_solid 3,72g
/dev/sdb1 vg_ssd lvm2 a-- 74,53g 22,80g 12729 5362 lv_videos 28,00g
/dev/sdb1 vg_ssd lvm2 a-- 74,53g 22,80g 18091 988 0
列出给定逻辑卷的物理段以及其他信息:
$ lvdisplay -m /dev/vg_ssd/lv_videos
[..]
--- Segments ---
Logical extents 0 to 5361:
Type linear
Physical volume /dev/sdb1
Physical extents 12729 to 18090
Logical extents 5362 to 7167:
Type linear
Physical volume /dev/sdb1
Physical extents 3534 to 5339
显示与给定物理卷关联的逻辑卷,以及其他信息:
$ pvdisplay -m /dev/sdb1
[..]
--- Physical Segments ---
Physical extent 0 to 3533:
FREE
Physical extent 0 to 5339:
Logical volume /dev/vg_ssd/lv_videos
Logical extents 5362 to 7167
Physical extent 5340 to 11775:
FREE
Physical extent 11776 to 12728:
Logical volume /dev/vg_ssd/lv_swap_solid
Logical extents 0 to 952
Physical extent 12729 to 18090:
Logical volume /dev/vg_ssd/lv_videos
Logical extents 0 to 5361
Physical extent 18091 to 19078:
FREE
复杂的命令,但完整列表:
$ pvs --segments -o pv_name,pv_size,seg_size,vg_name,lv_name,lv_size,seg_pe_ranges
PV PSize SSize VG LV LSize PE Ranges
/dev/sda5 193,79g 9,31g vg_ssd lv_root_solid 13,31g /dev/sda5:0-2383
/dev/sda5 193,79g 3,72g vg_ssd lv_home_solid 107,00g /dev/sda5:2384-3336
/dev/sda5 193,79g 46,56g vg_ssd lv_srv_solid 46,56g /dev/sda5:3337-15256
/dev/sda5 193,79g 60,00g vg_ssd lv_home_solid 107,00g /dev/sda5:15257-30616
/dev/sda5 193,79g 200,00m vg_ssd lv_home_solid 107,00g /dev/sda5:30617-30666
/dev/sda5 193,79g 1,05g vg_ssd 0
/dev/sda5 193,79g 8,00g vg_ssd lv_home_solid 107,00g /dev/sda5:30937-32984
/dev/sda5 193,79g 4,00g vg_ssd lv_root_solid 13,31g /dev/sda5:32985-34008
/dev/sda5 193,79g 20,00g vg_ssd lv_home_solid 107,00g /dev/sda5:34009-39128
/dev/sda5 193,79g 9,80g vg_ssd lv_home_solid 107,00g /dev/sda5:41689-44198
/dev/sda5 193,79g 1,28g vg_ssd lv_home_solid 107,00g /dev/sda5:44199-44525
/dev/sda5 193,79g 15,86g vg_ssd 0
/dev/sda5 193,79g 4,00g vg_ssd lv_home_solid 107,00g /dev/sda5:48587-49610
/dev/sdb1 74,53g 13,80g vg_ssd 0
/dev/sdb1 74,53g 7,05g vg_ssd lv_videos 28,00g /dev/sdb1:3534-5339
/dev/sdb1 74,53g 5,14g vg_ssd 0
/dev/sdb1 74,53g 3,72g vg_ssd lv_swap_solid 3,72g /dev/sdb1:11776-12728
/dev/sdb1 74,53g 20,95g vg_ssd lv_videos 28,00g /dev/sdb1:12729-18090
/dev/sdb1 74,53g 3,86g vg_ssd 0
lvdisplay -m
将列出其物理段:
# lvdisplay -m
--- Logical volume ---
LV Path /dev/vg/swap
LV Name swap
VG Name vg
LV UUID TlxZzz-11Z3-u3K3-0ULD-AZV6-c4ug-jp7YVP
LV Write Access read/write
LV Creation host, time edeltraud, 2015-03-12 12:43:09 +0100
LV Status available
# open 0
LV Size 2.00 GiB
Current LE 512
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 512
Block device 254:21
--- Segments ---
Logical extents 0 to 511:
Type striped
Stripes 2
Stripe size 64.00 KiB
Stripe 0:
Physical volume /dev/sdc1
Physical extents 2561 to 2816
Stripe 1:
Physical volume /dev/sda1
Physical extents 241027 to 241282
通过添加-a
选项,您还可以查看由raid1
-mirrored卷设置的卷:
# lvdisplay -am
--- Logical volume ---
Internal LV Name srv_rimage_0
VG Name vg
LV UUID IJTT9w-2aX5-aqR5-VY4Z-Lqtp-L3cP-jkzNnx
LV Write Access read/write
LV Creation host, time edeltraud, 2015-12-13 00:10:03 +0100
LV Status available
# open 1
LV Size 50.00 GiB
Current LE 12800
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 254:39
--- Segments ---
Logical extents 0 to 12799:
Type linear
Physical volume /dev/sdb4
Physical extents 7683 to 20482
--- Logical volume ---
Internal LV Name srv_rmeta_0
VG Name vg
LV UUID YyyVAa-dab7-8Jxg-JzpS-Yf3k-4SDH-654cqf
LV Write Access read/write
LV Creation host, time edeltraud, 2015-12-13 00:10:03 +0100
LV Status available
# open 1
LV Size 4.00 MiB
Current LE 1
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 254:38
--- Segments ---
Logical extents 0 to 0:
Type linear
Physical volume /dev/sdb4
Physical extents 7682 to 7682
对于每个镜像,您将看到两个卷{volume_name}_rmeta_{n}
(包含raid元数据)和{volume_name}_rimage_{n}
(包含实际数据),其中{volume_name}
逻辑卷的名称和{n}
镜像的编号(始于0
)。
dmsetup table /dev/vg/swap
sudo lvdisplay -am
它让我确定精确的专业:在cgroup中限制写镜像的备用镜像分支的次要对象,现在让我们对其进行测试吧!unix.stackexchange.com/q/306827/30352