Expandir el sistema de archivos raíz (/) para usar el espacio libre del grupo de volúmenes (VG) en Ubuntu 24

Verificamos el espacio asignado en el sistema de archivos.

root@vm:/home/administrador# df -h
Filesystem                         Size  Used Avail Use% Mounted on
tmpfs                              795M  1,2M  793M   1% /run
/dev/mapper/ubuntu--vg-ubuntu--lv   39G  6,4G   30G  18% /
tmpfs                              3,9G     0  3,9G   0% /dev/shm
tmpfs                              5,0M     0  5,0M   0% /run/lock
/dev/sda2                          2,0G  100M  1,7G   6% /boot
tmpfs                              795M   12K  795M   1% /run/user/1000

root@vm:/home/administrador# fdisk -l
Disk /dev/sda: 80 GiB, 85899345920 bytes, 167772160 sectors
Disk model: Virtual disk
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: 2EE0E790-DD34-XXXX-8814-0E9321DA9E19

Device       Start       End   Sectors Size Type
/dev/sda1     2048      4095      2048   1M BIOS boot
/dev/sda2     4096   4198399   4194304   2G Linux filesystem
/dev/sda3  4198400 167770111 163571712  78G Linux filesystem

Disk /dev/mapper/ubuntu--vg-ubuntu--lv: 39 GiB, 41871736832 bytes, 81780736 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

Extender el volumen lógico (LV) raíz:
-l +100%FREE: Usa todo el espacio libre restante en el VG.
Verifica con sudo vgs para confirmar que el espacio libre ahora es 0.

root@vm:/home/administrador# sudo lvextend -l +100%FREE /dev/mapper/ubuntu--vg-ubuntu--lv
  Size of logical volume ubuntu-vg/ubuntu-lv changed from <39,00 GiB (9983 extents) to <78,00 GiB (19967 extents).
  Logical volume ubuntu-vg/ubuntu-lv successfully resized.

Redimensionar el sistema de archivos en caliente (ext4):

root@vm:/home/administrador# sudo resize2fs /dev/mapper/ubuntu--vg-ubuntu--lv
resize2fs 1.47.0 (5-Feb-2023)
Filesystem at /dev/mapper/ubuntu--vg-ubuntu--lv is mounted on /; on-line resizing required
old_desc_blocks = 5, new_desc_blocks = 10
The filesystem on /dev/mapper/ubuntu--vg-ubuntu--lv is now 20446208 (4k) blocks long.

Verificamos:

root@vm:/home/administrador# df -h
Filesystem                         Size  Used Avail Use% Mounted on
tmpfs                              795M  1,2M  793M   1% /run
/dev/mapper/ubuntu--vg-ubuntu--lv   77G  6,4G   67G   9% /
tmpfs                              3,9G     0  3,9G   0% /dev/shm
tmpfs                              5,0M     0  5,0M   0% /run/lock
/dev/sda2                          2,0G  100M  1,7G   6% /boot
tmpfs                              795M   12K  795M   1% /run/user/1000

Deja un comentario

Tu dirección de correo electrónico no será publicada. Los campos obligatorios están marcados con *