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.
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.
nechuz@taringa:~$ fdisk -l
dijo: /dev/sda1 * 1 13 104391 83 Linux
/dev/sda2 14 522 4088542+ 8e Linux LVM [/quote]
El proceso seria el mismo si pinchamos un nuevo disco y extendemos nuestro volumen con el tamaño que nos interese del nuevo disco.
nechuz@taringa:~$ fdisk /dev/sda
dijo: 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) [/quote]
Ahora debemos indicar que la partición se trata de una LVM (8e)
nechuz@taringa:~$ fdisk /dev/sda
dijo: 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. [/quote]
Vemos como queda ahora todo esto :
nechuz@taringa:~$ fdisk -l
dijo: /dev/sda1 * 1 13 104391 83 Linux
/dev/sda2 14 522 4088542+ 8e Linux LVM
/dev/sda3 523 2610 16771860 8e Linux LVM [/quote]
Ahora generamos el volumen físico
nechuz@taringa:~$ pvcreate /dev/sda3
dijo: Physical volume “/dev/sda3″ successfully created [/quote]
Vemos los volúmenes físicos que tenemos ahora generados.
nechuz@taringa:~$ pvdisplay
dijo: — 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 [/quote]
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.
nechuz@taringa:~$ vgdisplay
dijo: — 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 [/quote]
Ahora vamos a extender nuestro volumen con la nueva partición que hemos generado.
nechuz@taringa:~$ vgextend VolGroup00 /dev/sda3
dijo: Volume group “VolGroup00″ successfully extended [/quote]
Si volvemos a ver los datos de nuestro volumen físico.
nechuz@taringa:~$ vgdisplay
dijo: — 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 [/quote]
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.
nechuz@taringa:~$ lvextend -L19840M /dev/VolGroup00/LogVol00
dijo: Extending logical volume LogVol00 to 19.38 GB
Logical volume LogVol00 successfully resized [/quote]
Y ahora solo nos queda redimensionar el volumen actual para que nos lo muestre el sistema
nechuz@taringa:~$ ext2online /dev/VolGroup00/LogVol00
Y vemos que la cosa ha funcionado:
nechuz@taringa:~$ df -h
dijo: 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 [/quote]
Veamos como queda nuestros fichero /etc/fstab
dijo: /dev/VolGroup00/LogVol00 / ext3 defaults 1 1
LABEL=/boot /boot ext3 defaults 1 2 [/quote]
Espero les sea de utilidad, Saludos!