Editando
Extender disco virtual
(sección)
De jagfloriano.com
Ir a la navegación
Ir a la búsqueda
Advertencia:
no has iniciado sesión. Tu dirección IP se hará pública si haces cualquier edición. Si
inicias sesión
o
creas una cuenta
, tus ediciones se atribuirán a tu nombre de usuario, además de otros beneficios.
Comprobación antispam. ¡
No
rellenes esto!
== 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 utiliza LVM * Acceso como <code>root</code> * Copia de seguridad recomendada === Verificación inicial === Comprobar versión del sistema operativo: <syntaxhighlight lang="bash"> [root@serverA ~]# cat /etc/redhat-release Red Hat Enterprise Linux Server release 7.9 (Maipo) </syntaxhighlight> Ver particiones actuales: <syntaxhighlight lang="bash"> [root@serverA ~]# cat /proc/partitions |grep sda 8 0 104857600 sda 8 1 1048576 sda1 8 2 262144 sda2 8 3 103545856 sda3 </syntaxhighlight> Comprobar el volumen físico: <syntaxhighlight lang="bash"> [root@serverA ~]# pvs PV VG Fmt Attr PSize PFree /dev/sda3 vg00 lvm2 a-- <98.75g <27.92g [root@serverA ~]# </syntaxhighlight> <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: <syntaxhighlight lang="bash"> [root@serverA ~]# echo 1 > /sys/block/sda/device/rescan </syntaxhighlight> Verificar nuevo tamaño: <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: 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> === Recrear la partición LVM (sin perder datos) === ⚠️ **Importante** Solo eliminar y recrear la partición **siempre usando el mismo sector inicial**. Entrar en <code>fdisk</code>: <syntaxhighlight lang="bash"> fdisk /dev/sda </syntaxhighlight> Pasos dentro de <code>fdisk</code>: * <code>p</code> → Mostrar particiones * <code>d</code> → Eliminar partición LVM (ej. <code>sda3</code>) * <code>n</code> → Crear nueva partición primaria * Usar el **mismo sector inicial** * Usar todo el espacio disponible * <code>t</code> → Cambiar tipo a <code>8e (Linux LVM)</code> * <code>w</code> → Guardar cambios Pasos detallados: <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. </syntaxhighlight> <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 209715199 103545856 8e Linux LVM </syntaxhighlight> <syntaxhighlight lang="bash"> Command (m for help): d Partition number (1-3, default 3): 3 Partition 3 is deleted </syntaxhighlight> <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 </syntaxhighlight> <syntaxhighlight lang="bash"> 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 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"> 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' </syntaxhighlight> <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 8e Linux LVM </syntaxhighlight> <syntaxhighlight lang="bash"> 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> === Recargar tabla de particiones === Aplicar los cambios sin reiniciar: <syntaxhighlight lang="bash"> [root@serverA ~]# partprobe [root@serverA ~]# partx -u /dev/sda </syntaxhighlight> Verificar: <syntaxhighlight lang="bash"> [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> === Redimensionar el volumen físico === Extender el PV para que use todo el espacio disponible: <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> Comprobar espacio libre en el VG: <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 === En algunos casos, tras extender el disco, el sistema puede mostrar errores de GPT. Ejemplo de error detectado por <code>parted</code>: <pre> The backup GPT table is not at the end of the disk </pre> Solución: <syntaxhighlight lang="bash"> parted /dev/sda </syntaxhighlight> Aceptar las opciones: * <code>Fix</code> para mover la GPT backup * <code>Fix</code> para usar todo el espacio disponible Verificar tabla corregida: <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 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> === Notas importantes === * 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
Resumen:
Ten en cuenta que todas las contribuciones a jagfloriano.com pueden ser editadas, modificadas o eliminadas por otros colaboradores. Si no deseas que las modifiquen sin limitaciones, no las publiques aquí.
Al mismo tiempo, asumimos que eres el autor de lo que escribiste, o lo copiaste de una fuente en el dominio público o con licencia libre (véase
Jagfloriano.com:Derechos de autor
para más detalles).
¡No uses textos con copyright sin permiso!
Cancelar
Ayuda de edición
(se abre en una ventana nueva)
Menú de navegación
Acciones de página
Página
Discusión
Leer
Editar
Historial
Page actions
Página
Discusión
Más
Herramientas
Herramientas personales
No has accedido
Discusión
Contribuciones
Crear una cuenta
Acceder
Navegación
Página principal
Linux
Ansible
Labs
Buscar
Herramientas
Lo que enlaza aquí
Cambios relacionados
Páginas especiales
Información de la página