Ampliar una Partición y un Filesystem en caliente NO LVM en Linux

Hosting SSD

Imaginemos que tenemos un servidor Linux que tiene un filesystem XFS que necesita ser ampliado en caliente pero no forma parte de ninguna infraestructura LVM. Lo haremos de la siguiente manera:

Primero de todo, tendremos que ampliar la partición. La que vamos a ampliar es esta:

[[email protected] ~]# fdisk -l |grep dev |grep -v mapper
Disk /dev/sda: 8589 MB, 8589934592 bytes, 16777216 sectors
/dev/sda1 * 2048 1435647 716800 83 Linux
/dev/sda2 1435648 16777215 7670784 8e Linux LVM
Disk /dev/sdb: 1073 MB, 1073741824 bytes, 2097152 sectors
/dev/sdb1 2048 2097151 1047552 83 Linux
[[email protected] ~]#

Este disco está siendo utilizado por el filesystem /test.

[[email protected] ~]# df -hP /test/
Filesystem Size Used Avail Use% Mounted on
/dev/sdb1 1020M 33M 988M 4% /test
[[email protected] ~]# ll /test
total 4
-rw-r–r–. 1 root root 31 Oct 6 09:36 test.txt
[[email protected] ~]#

Solicitamos al equipo de storage o de VMWare que aumente el tamaño del disco y volvemos a escanear la tabla de particiones.

[[email protected] ~]# partprobe
Warning: Unable to open /dev/sr0 read-write (Read-only file system). /dev/sr0 has been opened read-only.
[[email protected] ~]#

Observamos que el tamaño del disco ha crecido, pero no el de la partición todavía:


[[email protected] ~]# fdisk -l Disk /dev/sdb: 2147 MB, 2147483648 bytes, 4194304 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: 0xd830fd9b

Device Boot Start End Blocks Id System
/dev/sdb1 2048 2097151 1047552 83 Linux

Ahora vamos a expandir el tamaño de la partición:

[[email protected] ~]# growpart /dev/sdb 1
CHANGED: partition=1 start=2048 old: size=2095104 end=2097152 new: size=4192223,end=4194271
[[email protected] ~]#

Si no tienes instalado growpart, en mi Centos 7 lo he instalado con el comando yum install cloud-utils-growpart.

Comprobamos el nuevo tamaño:

  Centralización de logs con Logstash, Filebeat y ElasticSearch


[[email protected] ~]# fdisk -l

Disk /dev/sdb: 2147 MB, 2147483648 bytes, 4194304 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: 0xd830fd9b

Device Boot Start End Blocks Id System
/dev/sdb1 2048 4194270 2096111+ 83 Linux

Y ampliamos el filesystem:

[[email protected] ~]# df -hP /test
Filesystem Size Used Avail Use% Mounted on
/dev/sdb1 1020M 33M 988M 4% /test
[[email protected] ~]# xfs_growfs /dev/sdb1
meta-data=/dev/sdb1 isize=512 agcount=4, agsize=65472 blks
= sectsz=512 attr=2, projid32bit=1
= crc=1 finobt=0 spinodes=0
data = bsize=4096 blocks=261888, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=1
log =internal bsize=4096 blocks=855, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
data blocks changed from 261888 to 524027
[[email protected] ~]# df -hP /test
Filesystem Size Used Avail Use% Mounted on
/dev/sdb1 2.0G 33M 2.0G 2% /test
[[email protected] ~]#

COMPÁRTEME

Deja un comentario