redimensionar_swap_en_lvm

This is an old revision of the document!


Obtener el nombre de los grupos de lvm con lvs

facundo@AMD-Ryzen:~$ sudo lvs
  LV     VG       Attr       LSize   Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
  root   vgubuntu -wi-ao---- 892,80g                                                    
  swap_1 vgubuntu -wi-ao---- 980,00m 

Apagar el swap actual

                                                     
facundo@AMD-Ryzen:~$ sudo swapoff /dev/vgubuntu/swap_1

Agregar el espacio

facundo@AMD-Ryzen:~$ sudo lvresize -L+7G /dev/vgubuntu/swap_1
  Insufficient free space: 1792 extents needed, but only 0 available

Si no hay espacio suficiente, hay que achicar el otro VG

THIS MAY DESTROY YOUR DATA

Probablemente esto simplemente cambie el valor del último cluster/sector/byte/loquesea y si había datos después de esa posición no le importa.

  
facundo@AMD-Ryzen:~$ sudo lvresize -L-15G /dev/vgubuntu/root --resizefs
  WARNING: Reducing active and open logical volume to 877,80 GiB.
  THIS MAY DESTROY YOUR DATA (filesystem etc.)
Do you really want to reduce vgubuntu/root? [y/n]: y

  Size of logical volume vgubuntu/root changed from 892,80 GiB (228557 extents) to 877,80 GiB (224717 extents).
  Logical volume vgubuntu/root successfully resized.

Ahora sí, agrego más espacio al swap, tenía 1 GB y quiero llevarlo a 8

  
facundo@AMD-Ryzen:~$ sudo lvresize -L+7G /dev/vgubuntu/swap_1 --resizefs
  Size of logical volume vgubuntu/swap_1 changed from 980,00 MiB (245 extents) to <7,96 GiB (2037 extents).
  Logical volume vgubuntu/swap_1 successfully resized.

Formatear en formato swap con mkswap

  
facundo@AMD-Ryzen:~$ sudo mkswap /dev/vgubuntu/swap_1
mkswap: /dev/vgubuntu/swap_1: warning: wiping old swap signature.
Setting up swapspace version 1, size = 8 GiB (8543793152 bytes)
no label, UUID=3d290871-9b31-4ece-a2e7-0fd1c655f01f

y encender el pagefile de vuelta…

facundo@AMD-Ryzen:~$ sudo swapon /dev/vgubuntu/swap_1

Verificar con free si anduvo todo bien

facundo@AMD-Ryzen:~$ free
               total        used        free      shared  buff/cache   available
Mem:        16303720    14139144      815404      153332     1349172     1674812
Swap:        8343548           0     8343548
redimensionar_swap_en_lvm.1678556715.txt.gz · Last modified: 2024/10/17 21:42 (external edit)