Métodos de Creacion de ‘lv’s’ en LVM2
–> Disponemos de un ‘VG’ con espacio suficiente como comprobamos:
[root@CentOS ~]# vgs
VG #PV #LV #SN Attr VSize VFree
vg_centos 1 2 0 wz–n- 14,51g 0
volumen01 3 2 0 wz–n- 14,98g 6,97g
–> Crearemos 2 ‘PV’ de 2 GB cada uno que denominaremos: ‘pv01‘, y ‘pv02‘ respectivamente por los dos métodos posibles: directamente especificando los GB. , o por cálculo de Pe’s (extensiones).
Método-1 (opción ‘-L‘) :
[root@CentOS ~]# lvcreate -L 2GB -n pv01 /dev/mapper/volumen01
Logical volume «pv01» created
[root@CentOS ~]# lvs
LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert
lv_root vg_centos -wi-ao—- 13,01g
lv_swap vg_centos -wi-ao—- 1,50g
lvol0 volumen01 -wi-ao—- 8,00g
lvol1 volumen01 -wi-ao—- 4,00m
pv01 volumen01 -wi-a—– 2,00g
Método-2 (opción ‘-l‘):
–> Extracto de página man para ‘lvcreate’:
………………………..
-l, –extents LogicalExtentsNumber[%{VG|PVS|FREE|ORIGIN}]
Gives the number of logical extents to allocate for the new logical volume. The total number of physical extents allocated
will be greater than this, for example, if the volume is mirrored. The number can also be expressed as a percentage of the
total space in the Volume Group with the suffix %VG, as a percentage of the remaining free space in the Volume Group with the
suffix %FREE, as a percentage of the remaining free space for the specified PhysicalVolume(s) with the suffix %PVS, or (for a
snapshot) as a percentage of the total space in the Origin Logical Volume with the suffix %ORIGIN (i.e. 100%ORIGIN provides
space for the whole origin). When expressed as a percentage, the number is treated as an approximate upper limit for the total
number of physical extents to be allocated (including extents used by any mirrors, for example).
………………………..
–> Mostramos información del Volúmen para comprobar espacio tamaño de la extensión por defecto:
[root@CentOS ~]# vgdisplay /dev/mapper/volumen01
— Volume group —
VG Name volumen01
System ID
Format lvm2
Metadata Areas 3
Metadata Sequence No 6
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 3
Open LV 2
Max PV 0
Cur PV 3
Act PV 3
VG Size 14,98 GiB
PE Size 4,00 MiB
Total PE 3834
Alloc PE / Size 2561 / 10,00 GiB
Free PE / Size 1273 / 4,97 GiB
VG UUID wJs6ee-1T57-vcLF-tiX6-rcAV-7qZy-sfsubJ
–> Realizamos los cálculos, teniendo en cuenta que:
PE Size 4,00 MiB
Total PE 3834
Free PE / Size 1273 / 4,97 GiB
2GB x 1024 = 2.048 ==>> 2.048/4= 512 -> Necesitamos por tanto 512 PE’s
–> Utilizamos la cálculadora ‘bc‘ de la ‘Free Software Foundation’ para hacer todo:
[root@CentOS ~]# bc
bc 1.06.95
Copyright 1991-1994, 1997, 1998, 2000, 2004, 2006 Free Software Foundation, Inc.
This is free software with ABSOLUTELY NO WARRANTY.
For details type `warranty’.
2*1024/4
512
–> Creamos el ‘LV’:
[root@CentOS ~]# lvcreate -l 512 -n pv02 /dev/mapper/volumen01
Logical volume «pv02» created
[root@CentOS ~]# lvs
LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert
lv_root vg_centos -wi-ao—- 13,01g
lv_swap vg_centos -wi-ao—- 1,50g
lvol0 volumen01 -wi-ao—- 8,00g
lvol1 volumen01 -wi-ao—- 4,00m
pv01 volumen01 -wi-a—– 2,00g
pv02 volumen01 -wi-a—– 2,00g
[root@CentOS ~]# vgdisplay /dev/mapper/volumen01
— Volume group —
VG Name volumen01
System ID
Format lvm2
Metadata Areas 3
Metadata Sequence No 7
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 4
Open LV 2
Max PV 0
Cur PV 3
Act PV 3
VG Size 14,98 GiB
PE Size 4,00 MiB
Total PE 3834
Alloc PE / Size 3073 / 12,00 GiB
Free PE / Size 761 / 2,97 GiB
VG UUID wJs6ee-1T57-vcLF-tiX6-rcAV-7qZy-sfsubJ
[root@CentOS ~]# vgs /dev/mapper/volumen01
VG #PV #LV #SN Attr VSize VFree
volumen01 3 4 0 wz–n- 14,98g 2,97g
Adjuntamos PDF: Metodos-Creacion-PV-en -LVM2 –>> El PDF contiene Errores.
Errata en documento PDF: donde dice -PV-, quiere decir -LV- al menos en 2 ocasiones. Disculpas, …
116