Soluzione 1:
Lo pvdisplay
comando ha un -m
opzione per mostrare la mappatura delle estensioni fisiche ai volumi logici e alle estensioni logiche.
Ho impostato la seguente situazione su una macchina di prova:
- 3 dischi da 1 GB ciascuno aggiunti al sistema e utilizzati come volumi fisici per vg_test
- 6 volumi logici realizzati con varie dimensioni (da 300 M a 1,1 G) in modo che siano distribuiti sui volumi fisici
Esecuzione di pvdisplay -m
su questa macchina produce il seguente output:
[[email protected] ~]# 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
Come puoi vedere, ottieni una bella panoramica di dove si trovano le estensioni per ciascuno dei 6 volumi logici.
Soluzione 2:
Uso:
lvs -o +devices
...che trovo un po' più facile da interpretare.
Soluzione 3:
LVM è un livello di astrazione flessibile tra il disco fisico e il filesystem (disco ⇒ partizione ⇒ volume fisico di LVM [PV] ⇒ gruppo di volumi di LVM [VG] ⇒ volume logico di LVM [LV] ⇒ filesystem).
A causa di alcune funzionalità di LVM (aggregazione, mirror, stripe, snapshot...), il layout fisico può diventare complesso... quindi alcuni avvertimenti:
- Usa la manpage lvs su
--all
per visualizzare i dettagli interni (dei volumi speculari), se lo si desidera. - Ovviamente, quando esegui un comando per un dato oggetto, vengono mostrati solo i genitori e i figli di quell'oggetto (il che potrebbe essere incompleto, ad esempio se LV si estende su più PV)
Per una rapida panoramica, consiglio lsblk (che è uno strumento standard, non specifico per 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
Strumenti specifici per LVM
Per ottenere la vista e i dettagli interni di LVM, usa i comandi LVM:
- Liste:usa il
lvs
epvs
comandi con l'opzione--segments
- Vista dettagliata:usa il
lvdisplay
epvdisplay
comandi con l'opzione-m
Esempi di strumenti LVM
Elenca i segmenti fisici utilizzati da un volume logico :
$ 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
lo stesso con maggiori dettagli:
$ 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)
Elencare le estensioni fisiche di un dato LV. Utile per spostare quei segmenti (usando pvmove
):
$ lvs /dev/vg_ssd/lv_videos -o seg_pe_ranges
PE Ranges
/dev/sdb1:12729-18090
/dev/sdb1:3534-5339
Al contrario, elenca il volume logico (segmenti) all'interno di un dato volume fisico:
$ 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
Elenca i segmenti fisici di un dato volume logico, tra le altre informazioni:
$ 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
Visualizza il volume logico associato a un dato volume fisico, tra le altre informazioni:
$ 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
Comando complesso, ma elenco completo :
$ 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
Soluzione 4:
lvdisplay -m
elencherà i suoi segmenti fisici:
# 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
Aggiungendo il -a
opzione, puoi anche vedere i volumi impostati da raid1
-volumi con mirroring:
# 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
Per ogni mirror, vedrai due volumi, {volume_name}_rmeta_{n}
(contenente i metadati del raid) e {volume_name}_rimage_{n}
(contenente i dati effettivi), dove {volume_name}
è il nome del volume logico e {n}
è il numero del mirror (a partire da 0
).