Score:0

"Insufficient free space" when trying to increase swap space on LVM?

mx flag

I installed Ubuntu 21.10 with LVM to use full encryption on my disk. It works great, the only problem is that it chose a 1gb swap partition size, while I have 16gb or ram...

me@me:~$ sudo vgs
  VG       #PV #LV #SN Attr   VSize    VFree
  vgubuntu   1   2   0 wz--n- <475,71g    0 

me@me:~$ sudo lvdisplay
  --- Logical volume ---
  LV Path                /dev/vgubuntu/root
  LV Name                root
  VG Name                vgubuntu
  LV UUID                ky0PoX-T89V-D2IG-zmfk-gofT-dD0o-A4gC4g
  LV Write Access        read/write
  LV Creation host, time ubuntu, 2021-11-07 22:06:47 +0100
  LV Status              available
  # open                 1
  LV Size                474,75 GiB
  Current LE             121536
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:1
   
  --- Logical volume ---
  LV Path                /dev/vgubuntu/swap_1
  LV Name                swap_1
  VG Name                vgubuntu
  LV UUID                cLXRIh-3Tjp-fzUn-mKwe-akK0-4hPr-9I7l3c
  LV Write Access        read/write
  LV Creation host, time ubuntu, 2021-11-07 22:06:47 +0100
  LV Status              available
  # open                 2
  LV Size                980,00 MiB
  Current LE             245
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:2

But when I try to extend I get this

me@me:~$ sudo lvextend -L+16GB /dev/vgubuntu/swap_1
  Insufficient free space: 4096 extents needed, but only 0 available

What is the safest way to increase the swap?

in flag
What are you extending into? Logical volumes can only be extended into available space
Soren A avatar
mx flag
You have already used used all available space - root is 474.75 GB, so you will have to reduce root lv with 16GB before expanding swap with the same amount.
Lele83x avatar
mx flag
@SorenA yes that makes sense, I can gladly reduce the root, I have more than 100gb free there, how would I do that? I never used LVM
Soren A avatar
mx flag
@Lele83x it should be something like `sudo lvreduce --resizefs -L -16GB /dev/vgubuntu/root` to reduce root by 16 GB. I don't have a LVM system to verify it on, but according to the manual it is right. Remember that you also have to run 'mkswap' on the expanded swap lv.
Lele83x avatar
mx flag
@SorenA thanks I will test it out, need to spin a liveusb first
Soren A avatar
mx flag
@Lele83x I think that you should be able to work on LVM with system running an filesystems mounted.
Sadaharu Wakisaka avatar
pl flag
Welcome to AskUbuntu, why don't you use a swapfile? https://askubuntu.com/questions/839033/what-is-swapfile-and-swapspace
Lele83x avatar
mx flag
@SadaharuWakisaka won't it interfere with the swap partition as a separate LV?
Lele83x avatar
mx flag
@SorenA it sounds very risky... are you sure it's a good idea to resize the root while mounted and in use?
Soren A avatar
mx flag
@Lele83x As long as you don't reduce below available space it should be ok ... but it is up to you. But always have a fresh backup !!
Sadaharu Wakisaka avatar
pl flag
@Lele83x, no it doesn't. swap partition and file can both work at the same time. Swap file/partition could be in anywhere.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.