Inicio > Administracion, Linux > LVM – Logical Volume Manager

LVM – Logical Volume Manager

martes, 17 de marzo de 2009 Dejar un comentario Ir a comentarios

LVM

Quien no ha tenido ese pequeño problema de quedarse sin espacio en disco. LVM nos va a permitir unir varios discos o particiones en un volumen lógico en caliente.

En mi caso disponía de una maquina con un volumen generado, pero con espacio en disco que no estaba utilizando (la historia es algo mas larga pero por simplificarlo).
.

Vamos a empezar a jugar con el fdisk una herramienta que desde consola nos va a permitir jugar con los discos. En nuestro caso generar una partición con el espacio libre de que disponemos en el disco y convertirla en LVM.

fdisk -l
/dev/sda1 * 1 13 104391 83 Linux
/dev/sda2 14 522 4088542+ 8e Linux LVM

El proceso seria el mismo si pinchamos un nuevo disco y extendemos nuestro volumen con el tamaño que nos interese del nuevo disco.

fdisk /dev/sda

The number of cylinders for this disk is set to 2610.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:

1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs

e.g., DOS FDISK, OS/2 FDISK)

Command (m for help): n
Command action
e extended
p primary partition (1-4)

p (primaria)
3 (numero particion)
w (grabamos los cambios)

Ahora debemos indicar que la partición se trata de una LVM (8e)

fdisk /dev/sda

The number of cylinders for this disk is set to 2610.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:

1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
(e.g., DOS FDISK, OS/2 FDISK)

Command (m for help): t
Partition number (1-4): 3
Hex code (type L to list codes): 8e
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
WARNING: Re-reading the partition table failed with error 16: Device or resource busy.
The kernel still uses the old table.
The new table will be used at the next reboot.

Syncing disks.

Vemos como queda ahora todo esto :

fdisk -l

/dev/sda1 * 1 13 104391 83 Linux
/dev/sda2 14 522 4088542+ 8e Linux LVM
/dev/sda3 523 2610 16771860 8e Linux LVM

Ahora generamos el volumen físico

pvcreate /dev/sda3

Physical volume «/dev/sda3» successfully created

Vemos los volúmenes físicos que tenemos ahora generados.

pvdisplay

— Physical volume —
PV Name /dev/sda2
VG Name VolGroup00
PV Size 3.88 GB / not usable 0
Allocatable yes
PE Size (KByte) 32768
Total PE 124
Free PE 1
Allocated PE 123
PV UUID CZwxhG-ebU2-3lts-XC7m-2zpC-JMEL-kUcuwb

— NEW Physical volume —

PV Name /dev/sda3
VG Name
PV Size 15.99 GB
Allocatable NO
PE Size (KByte) 0
Total PE 0
Free PE 0
Allocated PE 0
PV UUID aGTr8T-SsSw-OLcT-l4Z8-JUcz-Kb9v-zJs9Vx

Vemos que hemos generado un volumen físico nuevo pero aun no lo hemos asignado al volumen lógico que ya tenemos generado.

Vamos a ver los datos del volumen que tenemos generado.

vgdisplay

— Volume group —

VG Name VolGroup00
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 3
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 2
Open LV 2
Max PV 0
Cur PV 1
Act PV 1
VG Size 3.88 GB
PE Size 32.00 MB
Total PE 124
Alloc PE / Size 123 / 3.84 GB
Free PE / Size 1 / 32.00 MB
VG UUID kRm22l-4SYZ-5nWf-ulXT-j8wg-aEvs-yDLNF0

Ahora vamos a extender nuestro volumen con la nueva partición que hemos generado.

vgextend VolGroup00 /dev/sda3
Volume group «VolGroup00» successfully extended

Si volvemos a ver los datos de nuestro volumen físico.

vgdisplay

— Volume group —
VG Name VolGroup00
System ID
Format lvm2
Metadata Areas 2
Metadata Sequence No 4
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 2
Open LV 2
Max PV 0
Cur PV 2
Act PV 2
VG Size 19.84 GB
PE Size 32.00 MB
Total PE 635
Alloc PE / Size 123 / 3.84 GB
Free PE / Size 512 / 16.00 GB
VG UUID kRm22l-4SYZ-5nWf-ulXT-j8wg-aEvs-yDLNF0

Vemos que ahora nos ha ampliado el disco con el espacio de nuestra nueva partición.

Ahora le tenemos que decir que nos añada todo el espacio (o el que nos interese) a nuestro volumen.

lvextend -L19840M /dev/VolGroup00/LogVol00
Extending logical volume LogVol00 to 19.38 GB
Logical volume LogVol00 successfully resized

Y ahora solo nos queda redimensionar el volumen actual para que nos lo muestre el sistema

ext2online /dev/VolGroup00/LogVol00

Y vemos que la cosa ha funcionado:

df -h

Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/VolGroup00-LogVol00
19G  3.4G   15G  19% /
/dev/sda1              99M   15M   80M  16% /boot
tmpfs                1014M     0 1014M   0% /dev/shm

Veamos como queda nuestros fichero /etc/fstab

/dev/VolGroup00/LogVol00 /            ext3    defaults        1 1
LABEL=/boot             /boot                   ext3    defaults        1 2

Creo que las ventajas son claras.

En estos enlaces os lo van a explicar mucho mejor:

WikiPedia
Fedoranews

Bandaancha.st

Enviar a un amigo: Share this page via Email
  1. Sin comentarios aún.
  1. Sin trackbacks aún.

*