Diferencia entre revisiones de «Extender disco virtual»

De jagfloriano.com
Ir a la navegaciónIr a la búsqueda
(Página creada con «== Procedimiento: Extender disco físico y LVM online == === Alcance === Este procedimiento aplica **únicamente a máquinas virtuales** ejecutándose sobre VMware con '''Red Hat Enterprise Linux 7 u 8''' y discos gestionados mediante '''LVM'''. El procedimiento se realiza '''online''' (sin apagar el sistema), siempre que el disco ya haya sido extendido previamente desde VMware. --- == Requisitos previos == * El disco ha sido extendido desde VMware * El sistema u…»)
 
 
(No se muestran 25 ediciones intermedias del mismo usuario)
Línea 1: Línea 1:
== Procedimiento: Extender disco físico y LVM online ==
== Extender disco físico y LVM online ==


=== Alcance ===
=== Alcance ===
Línea 8: Línea 8:
extendido previamente desde VMware.
extendido previamente desde VMware.


---
=== Requisitos previos ===  
 
== Requisitos previos ==


* El disco ha sido extendido desde VMware
* El disco ha sido extendido desde VMware
Línea 17: Línea 15:
* Copia de seguridad recomendada
* Copia de seguridad recomendada


---
=== Verificación inicial ===  
 
== Verificación inicial ==


Comprobar versión del sistema operativo:
Comprobar versión del sistema operativo:


<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
cat /etc/redhat-release
[root@serverA ~]# cat /etc/redhat-release
Red Hat Enterprise Linux Server release 7.9 (Maipo)
</syntaxhighlight>
</syntaxhighlight>
Ejemplo:
<pre>
Red Hat Enterprise Linux Server release 7.9 (Maipo)
</pre>


Ver particiones actuales:
Ver particiones actuales:


<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
cat /proc/partitions | grep sda
[root@serverA ~]# cat /proc/partitions |grep sda
  8        0  104857600 sda
  8        1    1048576 sda1
  8        2    262144 sda2
  8        3  103545856 sda3
</syntaxhighlight>
</syntaxhighlight>


Línea 41: Línea 37:


<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
pvs
[root@serverA ~]# pvs
  PV        VG  Fmt  Attr PSize  PFree
  /dev/sda3  vg00 lvm2 a--  <98.75g <27.92g
[root@serverA ~]#
</syntaxhighlight>
</syntaxhighlight>


---


== Reescaneo del disco ==
<syntaxhighlight lang="bash">
[root@serverA ~]# fdisk /dev/sda
Welcome to fdisk (util-linux 2.23.2).
 
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
 
 
Command (m for help): p
 
Disk /dev/sda: 107.4 GB, 107374182400 bytes, 209715200 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x000659b7
 
  Device Boot      Start        End      Blocks  Id  System
/dev/sda1  *        2048    2099199    1048576  83  Linux
/dev/sda2        2099200    2623487      262144    6  FAT16
/dev/sda3        2623488  209715199  103545856  8e  Linux LVM
</syntaxhighlight>
 
=== Reescaneo del disco ===


Forzar al kernel a detectar el nuevo tamaño del disco:
Forzar al kernel a detectar el nuevo tamaño del disco:


<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
echo 1 > /sys/block/sda/device/rescan
[root@serverA ~]# echo 1 > /sys/block/sda/device/rescan
</syntaxhighlight>
</syntaxhighlight>


Línea 57: Línea 78:


<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
fdisk /dev/sda
 
[root@serverA ~]# fdisk /dev/sda
Welcome to fdisk (util-linux 2.23.2).
 
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
 
 
Command (m for help): p
 
Disk /dev/sda: 429.5 GB, 429496729600 bytes, 838860800 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x000659b7
 
  Device Boot      Start        End      Blocks  Id  System
/dev/sda1  *        2048    2099199    1048576  83  Linux
/dev/sda2        2099200    2623487      262144    6  FAT16
/dev/sda3        2623488  209715199  103545856  8e  Linux LVM
 
</syntaxhighlight>
</syntaxhighlight>


---
=== Recrear la partición LVM (sin perder datos) ===  
 
== Recrear la partición LVM (sin perder datos) ==


⚠️ **Importante**   
⚠️ **Importante**   
Línea 83: Línea 123:
* <code>w</code> → Guardar cambios
* <code>w</code> → Guardar cambios


---
Pasos detallados:
<syntaxhighlight lang="bash">


== Recargar tabla de particiones ==
[root@serverA ~]# fdisk /dev/sda
Welcome to fdisk (util-linux 2.23.2).


Aplicar los cambios sin reiniciar:
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
</syntaxhighlight>


<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
partprobe
Command (m for help): p
partx -u /dev/sda
 
Disk /dev/sda: 429.5 GB, 429496729600 bytes, 838860800 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x000659b7
 
  Device Boot      Start        End      Blocks  Id  System
/dev/sda1  *        2048    2099199    1048576  83  Linux
/dev/sda2        2099200    2623487      262144    6  FAT16
/dev/sda3        2623488  209715199  103545856  8e  Linux LVM
</syntaxhighlight>
</syntaxhighlight>
Verificar:


<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
cat /proc/partitions | grep sda
Command (m for help): d
Partition number (1-3, default 3): 3
Partition 3 is deleted
</syntaxhighlight>
</syntaxhighlight>


---
<syntaxhighlight lang="bash">
Command (m for help): p


== Redimensionar el volumen físico ==
Disk /dev/sda: 429.5 GB, 429496729600 bytes, 838860800 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x000659b7


Extender el PV para que use todo el espacio disponible:
  Device Boot      Start        End      Blocks  Id  System
/dev/sda1  *        2048    2099199    1048576  83  Linux
/dev/sda2        2099200    2623487      262144    6  FAT16
</syntaxhighlight>


<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
pvresize /dev/sda3
Command (m for help): n
Partition type:
  p  primary (2 primary, 0 extended, 2 free)
  e  extended
Select (default p): p
Partition number (3,4, default 3):
First sector (2623488-838860799, default 2623488):
Using default value 2623488
Last sector, +sectors or +size{K,M,G} (2623488-838860799, default 838860799):
Using default value 838860799
Partition 3 of type Linux and of size 398.8 GiB is set
</syntaxhighlight>
</syntaxhighlight>


Comprobar espacio libre en el VG:
<syntaxhighlight lang="bash">
Command (m for help): p
 
Disk /dev/sda: 429.5 GB, 429496729600 bytes, 838860800 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x000659b7
 
  Device Boot      Start        End      Blocks  Id  System
/dev/sda1  *        2048    2099199    1048576  83  Linux
/dev/sda2        2099200    2623487      262144    6  FAT16
/dev/sda3        2623488  838860799  418118656  83  Linux
</syntaxhighlight>


<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
pvs
Command (m for help): t
vgs
Partition number (1-3, default 3):
Hex code (type L to list all codes): 8e
Changed type of partition 'Linux' to 'Linux LVM'
</syntaxhighlight>
</syntaxhighlight>


---
<syntaxhighlight lang="bash">
Command (m for help): p


== Extender el volumen lógico y el sistema de ficheros ==
Disk /dev/sda: 429.5 GB, 429496729600 bytes, 838860800 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x000659b7


Ver tamaño actual:
  Device Boot      Start        End      Blocks  Id  System
/dev/sda1  *        2048    2099199    1048576  83  Linux
/dev/sda2        2099200    2623487      262144    6  FAT16
/dev/sda3        2623488  838860799  418118656  8e  Linux LVM
</syntaxhighlight>


<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
df -h /
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 or after you run partprobe(8) or kpartx(8)
Syncing disks.
</syntaxhighlight>
</syntaxhighlight>


Extender el volumen lógico y el filesystem en un solo paso:
=== Recargar tabla de particiones ===
 
Aplicar los cambios sin reiniciar:


<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
lvextend -L +300G /dev/mapper/vg00-lv_root -r
[root@serverA ~]# partprobe
[root@serverA ~]# partx -u /dev/sda
</syntaxhighlight>
</syntaxhighlight>


Verificar resultado final:
Verificar:


<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
df -h /
[root@serverA ~]# cat /proc/partitions |grep -i sda
  8        0  419430400 sda
  8        1    1048576 sda1
  8        2    262144 sda2
  8        3  418118656 sda3
</syntaxhighlight>
</syntaxhighlight>


---
=== Redimensionar el volumen físico ===
 
Extender el PV para que use todo el espacio disponible:


== Resultado esperado ==
<syntaxhighlight lang="bash">
[root@serverA ~]# pvresize /dev/sda3
  Physical volume "/dev/sda3" changed
  1 physical volume(s) resized or updated / 0 physical volume(s) not resized
</syntaxhighlight>


* El disco físico refleja el nuevo tamaño
Comprobar espacio libre en el VG:
* El volumen físico (PV) usa todo el espacio
* El volumen lógico (LV) ha crecido
* El sistema de ficheros se ha extendido correctamente
* No se requiere reinicio


---
<syntaxhighlight lang="bash">
[root@serverA ~]# pvs
  PV        VG  Fmt  Attr PSize    PFree
  /dev/sda3  vg00 lvm2 a-- <398.75g <327.92g
[root@serverA ~]#
</syntaxhighlight>


== Caso especial: corrección de tabla GPT ==
=== Caso especial: corrección de tabla GPT ===  


En algunos casos, tras extender el disco, el sistema puede mostrar errores de GPT.
En algunos casos, tras extender el disco, el sistema puede mostrar errores de GPT.
Línea 174: Línea 296:


<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
[root@serverA~]# parted
GNU Parted 3.1
Using /dev/sda
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) print
(parted) print
Error: The backup GPT table is not at the end of the disk, as it should be.  This might mean that another operating system
believes the disk is smaller.  Fix, by moving the backup to the end (and removing the old backup)?
Fix/Ignore/Cancel? Fix
Warning: Not all of the space available to /dev/sda appears to be used, you can fix the GPT to use all of the space (an extra
838860800 blocks) or continue with the current setting?
Fix/Ignore? Fix
Model: VMware Virtual disk (scsi)
Disk /dev/sda: 537GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:
Number  Start  End    Size    File system  Name                  Flags
1      1049kB  269MB  268MB  fat16        EFI System Partition  boot
2      269MB  1343MB  1074MB  ext4
3      1343MB  107GB  106GB                                      lvm
(parted)
</syntaxhighlight>
</syntaxhighlight>


---
=== Notas importantes ===
 
== Notas importantes ==


* No cambiar nunca el sector inicial de la partición LVM
* No cambiar nunca el sector inicial de la partición LVM
Línea 186: Línea 331:
* Funciona en RHEL 7 y RHEL 8 sobre VMware
* Funciona en RHEL 7 y RHEL 8 sobre VMware


---
== Extender disco sin particiones (raw disk) ==
 
=== Escenario ===
Este procedimiento aplica cuando el disco extendido desde VMware **no contiene particiones**
y el sistema de ficheros está creado directamente sobre el dispositivo, por ejemplo <code>/dev/sdb</code>.
 
En este caso:
* No se utiliza <code>fdisk</code> ni <code>parted</code>
* No se modifica la tabla de particiones
* Solo se requiere reescanear el disco y extender el filesystem
 
=== Cuándo usar este procedimiento ===
 
Utilizar este método cuando:
* El disco es <code>/dev/sdb</code>, <code>/dev/sdc</code>, etc.
* No existe <code>/dev/sdb1</code>, <code>/dev/sdb2</code>, etc.
* El filesystem está directamente sobre el disco
 
=== Verificación inicial ===
 
Comprobar el punto de montaje y tamaño actual:
 
<syntaxhighlight lang="bash">
[root@serverB ~]# df -Ph /var/lib/gravity
Filesystem      Size  Used Avail Use% Mounted on
/dev/sdb      1000G  15G  986G  2% /var/lib/gravity
</syntaxhighlight>
 
 
Verificar que el sistema de ficheros está montado directamente sobre el disco:
 
<syntaxhighlight lang="bash">
[root@serverB ~]# lsblk | grep -i sdb
sdb                        8:16  0  1000G  0 disk /var/lib/gravity
</syntaxhighlight>
 
Esto confirma que:
* El disco **no está particionado**
* El filesystem reside directamente sobre <code>/dev/sdb</code>
 
 
=== Reescaneo del disco ===
 
Forzar al kernel a detectar el nuevo tamaño tras la ampliación en VMware:
 
<syntaxhighlight lang="bash">
[root@serverB ~]# echo 1 > /sys/block/sdb/device/rescan
</syntaxhighlight>
 
Verificar el nuevo tamaño detectado:
 
<syntaxhighlight lang="bash">
[root@serverB ~]# lsblk | grep -i sdb
sdb                        8:16  0  1.5T  0 disk /var/lib/gravity
</syntaxhighlight>
 
 
=== Extender el sistema de ficheros (XFS) ===
 
Al tratarse de XFS, el filesystem puede extenderse **en caliente**:
 
<syntaxhighlight lang="bash">
[root@serverB ~]# xfs_growfs /dev/sdb
meta-data=/dev/sdb              isize=512    agcount=4, agsize=65536000 blks
        =                      sectsz=512  attr=2, projid32bit=1
        =                      crc=1        finobt=0 spinodes=0
data    =                      bsize=4096  blocks=262144000, imaxpct=25
        =                      sunit=0      swidth=0 blks
naming  =version 2              bsize=4096  ascii-ci=0 ftype=1
log      =internal              bsize=4096  blocks=128000, version=2
        =                      sectsz=512  sunit=0 blks, lazy-count=1
realtime =none                  extsz=4096  blocks=0, rtextents=0
data blocks changed from 262144000 to 392953856
[root@serverB ~]#
</syntaxhighlight>
 
 
=== Verificación final ===
 
Confirmar que el sistema de ficheros refleja el nuevo tamaño:
 
<syntaxhighlight lang="bash">
[root@serverB ~]# df -Ph /var/lib/gravity
Filesystem      Size  Used Avail Use% Mounted on
/dev/sdb        1.5T  15G  1.5T  1% /var/lib/gravity
[root@serverB ~]#
</syntaxhighlight>
 
 
=== Resultado ===
 
* El kernel detecta el nuevo tamaño del disco
* El filesystem XFS se extiende correctamente
* No se requieren cambios en particiones
* No es necesario reiniciar el sistema
 
 
=== Notas importantes ===
 
* Este método solo aplica a discos **sin particiones**
* El filesystem debe ser XFS
* En ext4 sería necesario usar <code>resize2fs</code>
* Siempre verificar con <code>lsblk</code> antes de actuar


== Referencias ==
== Referencias ==
* Documentación oficial Red Hat LVM
* Documentación oficial Red Hat LVM
* VMware Guest OS Disk Rescan
* VMware Guest OS Disk Rescan

Revisión actual - 16:48 2 ene 2026

Extender disco físico y LVM online[editar]

Alcance[editar]

Este procedimiento aplica **únicamente a máquinas virtuales** ejecutándose sobre VMware con Red Hat Enterprise Linux 7 u 8 y discos gestionados mediante LVM.

El procedimiento se realiza online (sin apagar el sistema), siempre que el disco ya haya sido extendido previamente desde VMware.

Requisitos previos[editar]

  • El disco ha sido extendido desde VMware
  • El sistema utiliza LVM
  • Acceso como root
  • Copia de seguridad recomendada

Verificación inicial[editar]

Comprobar versión del sistema operativo:

[root@serverA ~]# cat /etc/redhat-release
Red Hat Enterprise Linux Server release 7.9 (Maipo)

Ver particiones actuales:

[root@serverA ~]# cat /proc/partitions |grep sda
   8        0  104857600 sda
   8        1    1048576 sda1
   8        2     262144 sda2
   8        3  103545856 sda3

Comprobar el volumen físico:

[root@serverA ~]# pvs
  PV         VG   Fmt  Attr PSize   PFree
  /dev/sda3  vg00 lvm2 a--  <98.75g <27.92g
[root@serverA ~]#


[root@serverA ~]# fdisk /dev/sda
Welcome to fdisk (util-linux 2.23.2).

Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.


Command (m for help): p

Disk /dev/sda: 107.4 GB, 107374182400 bytes, 209715200 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x000659b7

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048     2099199     1048576   83  Linux
/dev/sda2         2099200     2623487      262144    6  FAT16
/dev/sda3         2623488   209715199   103545856   8e  Linux LVM

Reescaneo del disco[editar]

Forzar al kernel a detectar el nuevo tamaño del disco:

[root@serverA ~]# echo 1 > /sys/block/sda/device/rescan

Verificar nuevo tamaño:

[root@serverA ~]# fdisk /dev/sda
Welcome to fdisk (util-linux 2.23.2).

Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.


Command (m for help): p

Disk /dev/sda: 429.5 GB, 429496729600 bytes, 838860800 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x000659b7

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048     2099199     1048576   83  Linux
/dev/sda2         2099200     2623487      262144    6  FAT16
/dev/sda3         2623488   209715199   103545856   8e  Linux LVM

Recrear la partición LVM (sin perder datos)[editar]

⚠️ **Importante** Solo eliminar y recrear la partición **siempre usando el mismo sector inicial**.

Entrar en fdisk:

fdisk /dev/sda

Pasos dentro de fdisk:

  • p → Mostrar particiones
  • d → Eliminar partición LVM (ej. sda3)
  • n → Crear nueva partición primaria
  • Usar el **mismo sector inicial**
  • Usar todo el espacio disponible
  • t → Cambiar tipo a 8e (Linux LVM)
  • w → Guardar cambios

Pasos detallados:

[root@serverA ~]# fdisk /dev/sda
Welcome to fdisk (util-linux 2.23.2).

Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
Command (m for help): p

Disk /dev/sda: 429.5 GB, 429496729600 bytes, 838860800 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x000659b7

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048     2099199     1048576   83  Linux
/dev/sda2         2099200     2623487      262144    6  FAT16
/dev/sda3         2623488   209715199   103545856   8e  Linux LVM
Command (m for help): d
Partition number (1-3, default 3): 3
Partition 3 is deleted
Command (m for help): p

Disk /dev/sda: 429.5 GB, 429496729600 bytes, 838860800 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x000659b7

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048     2099199     1048576   83  Linux
/dev/sda2         2099200     2623487      262144    6  FAT16
Command (m for help): n
Partition type:
   p   primary (2 primary, 0 extended, 2 free)
   e   extended
Select (default p): p
Partition number (3,4, default 3):
First sector (2623488-838860799, default 2623488):
Using default value 2623488
Last sector, +sectors or +size{K,M,G} (2623488-838860799, default 838860799):
Using default value 838860799
Partition 3 of type Linux and of size 398.8 GiB is set
Command (m for help): p

Disk /dev/sda: 429.5 GB, 429496729600 bytes, 838860800 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x000659b7

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048     2099199     1048576   83  Linux
/dev/sda2         2099200     2623487      262144    6  FAT16
/dev/sda3         2623488   838860799   418118656   83  Linux
Command (m for help): t
Partition number (1-3, default 3):
Hex code (type L to list all codes): 8e
Changed type of partition 'Linux' to 'Linux LVM'
Command (m for help): p

Disk /dev/sda: 429.5 GB, 429496729600 bytes, 838860800 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x000659b7

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048     2099199     1048576   83  Linux
/dev/sda2         2099200     2623487      262144    6  FAT16
/dev/sda3         2623488   838860799   418118656   8e  Linux LVM
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 or after you run partprobe(8) or kpartx(8)
Syncing disks.

Recargar tabla de particiones[editar]

Aplicar los cambios sin reiniciar:

[root@serverA ~]# partprobe
[root@serverA ~]# partx -u /dev/sda

Verificar:

[root@serverA ~]# cat /proc/partitions |grep -i sda
   8        0  419430400 sda
   8        1    1048576 sda1
   8        2     262144 sda2
   8        3  418118656 sda3

Redimensionar el volumen físico[editar]

Extender el PV para que use todo el espacio disponible:

[root@serverA ~]# pvresize /dev/sda3
  Physical volume "/dev/sda3" changed
  1 physical volume(s) resized or updated / 0 physical volume(s) not resized

Comprobar espacio libre en el VG:

[root@serverA ~]# pvs
  PV         VG   Fmt  Attr PSize    PFree
  /dev/sda3  vg00 lvm2 a--  <398.75g <327.92g
[root@serverA ~]#

Caso especial: corrección de tabla GPT[editar]

En algunos casos, tras extender el disco, el sistema puede mostrar errores de GPT.

Ejemplo de error detectado por parted:

The backup GPT table is not at the end of the disk

Solución:

parted /dev/sda

Aceptar las opciones:

  • Fix para mover la GPT backup
  • Fix para usar todo el espacio disponible

Verificar tabla corregida:

[root@serverA~]# parted
GNU Parted 3.1
Using /dev/sda
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) print

Error: The backup GPT table is not at the end of the disk, as it should be.  This might mean that another operating system
believes the disk is smaller.  Fix, by moving the backup to the end (and removing the old backup)?
Fix/Ignore/Cancel? Fix
Warning: Not all of the space available to /dev/sda appears to be used, you can fix the GPT to use all of the space (an extra
838860800 blocks) or continue with the current setting?
Fix/Ignore? Fix
Model: VMware Virtual disk (scsi)
Disk /dev/sda: 537GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:

Number  Start   End     Size    File system  Name                  Flags
 1      1049kB  269MB   268MB   fat16        EFI System Partition  boot
 2      269MB   1343MB  1074MB  ext4
 3      1343MB  107GB   106GB                                      lvm

(parted)

Notas importantes[editar]

  • No cambiar nunca el sector inicial de la partición LVM
  • Este procedimiento es seguro si se sigue correctamente
  • Recomendado ejecutar en ventanas de mantenimiento
  • Funciona en RHEL 7 y RHEL 8 sobre VMware

Extender disco sin particiones (raw disk)[editar]

Escenario[editar]

Este procedimiento aplica cuando el disco extendido desde VMware **no contiene particiones** y el sistema de ficheros está creado directamente sobre el dispositivo, por ejemplo /dev/sdb.

En este caso:

  • No se utiliza fdisk ni parted
  • No se modifica la tabla de particiones
  • Solo se requiere reescanear el disco y extender el filesystem

Cuándo usar este procedimiento[editar]

Utilizar este método cuando:

  • El disco es /dev/sdb, /dev/sdc, etc.
  • No existe /dev/sdb1, /dev/sdb2, etc.
  • El filesystem está directamente sobre el disco

Verificación inicial[editar]

Comprobar el punto de montaje y tamaño actual:

[root@serverB ~]# df -Ph /var/lib/gravity
Filesystem      Size  Used Avail Use% Mounted on
/dev/sdb       1000G   15G  986G   2% /var/lib/gravity


Verificar que el sistema de ficheros está montado directamente sobre el disco:

[root@serverB ~]# lsblk | grep -i sdb
sdb                        8:16   0  1000G  0 disk /var/lib/gravity

Esto confirma que:

  • El disco **no está particionado**
  • El filesystem reside directamente sobre /dev/sdb


Reescaneo del disco[editar]

Forzar al kernel a detectar el nuevo tamaño tras la ampliación en VMware:

[root@serverB ~]# echo 1 > /sys/block/sdb/device/rescan

Verificar el nuevo tamaño detectado:

[root@serverB ~]# lsblk | grep -i sdb
sdb                        8:16   0   1.5T  0 disk /var/lib/gravity


Extender el sistema de ficheros (XFS)[editar]

Al tratarse de XFS, el filesystem puede extenderse **en caliente**:

[root@serverB ~]# xfs_growfs /dev/sdb
meta-data=/dev/sdb               isize=512    agcount=4, agsize=65536000 blks
         =                       sectsz=512   attr=2, projid32bit=1
         =                       crc=1        finobt=0 spinodes=0
data     =                       bsize=4096   blocks=262144000, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0 ftype=1
log      =internal               bsize=4096   blocks=128000, version=2
         =                       sectsz=512   sunit=0 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0
data blocks changed from 262144000 to 392953856
[root@serverB ~]#


Verificación final[editar]

Confirmar que el sistema de ficheros refleja el nuevo tamaño:

[root@serverB ~]# df -Ph /var/lib/gravity
Filesystem      Size  Used Avail Use% Mounted on
/dev/sdb        1.5T   15G  1.5T   1% /var/lib/gravity
[root@serverB ~]#


Resultado[editar]

  • El kernel detecta el nuevo tamaño del disco
  • El filesystem XFS se extiende correctamente
  • No se requieren cambios en particiones
  • No es necesario reiniciar el sistema


Notas importantes[editar]

  • Este método solo aplica a discos **sin particiones**
  • El filesystem debe ser XFS
  • En ext4 sería necesario usar resize2fs
  • Siempre verificar con lsblk antes de actuar

Referencias[editar]

  • Documentación oficial Red Hat LVM
  • VMware Guest OS Disk Rescan