Score:0

Questions about swap configuration

ch flag

I'm trying to enable hibernation on Ubuntu 22.04 (following this tutorial) but I'm confused about what my system tells me about the current swap configuration so I'm hesitant to just change it without knowing what I do.

Before we start, some data about my system:

  • ThinkPad T14 Gen 1 AMD
  • Ubuntu 22.04.2 LTS
  • Kernel 5.19.0-41-generic
  • 48 GB of RAM
  • 1 TB of storage
  • full disk encryption (I enabled it in the Ubuntu installer)

My current swap settings are as they were configured on install. I haven't changed anything (hardware or swap config) since then.

System Monitor tells me that I have 976 MiB of Swap (which is ~96 % used all the time). This already is confusing as the swap FAQ on help.ubuntu.com says that the swap size should be "at least sqrt(ram size)", which sould be almost 7 GB in my case. My whole system actually feels laggy sometimes, which might be due to the small swap? But the RAM is also > 80 % full most of the time, which might add to that problem.

Anyways...

swapon tells me that the swap is a partition.

$ sudo swapon
NAME      TYPE      SIZE USED PRIO
/dev/dm-2 partition 976M 945M   -2
$ ls /dev | grep dm-2
brw-rw----   1 root     disk      253,     2 Mai  4 16:05 dm-2

Looking into GParted, I can't find this disk or partition

Screenshot of GParted

There's only /dev/nvme0n1 with 3 partitions p1...p3. Why does the swap partition not show up?

Reading about swap file vs. swap partition, I've seen a lot of opinions but I'm leaning towards a swap file, because it is more flexible to handle (and some people say that it is better with full disk encryption and SSD's, but nobody gives hard evidence for their opinion, so idk)

Now my questions are:

  • does the current setup (as it was created by the Ubuntu installer) make any sense? Because for me it feels a bit odd :-P
  • how can I move from this setup to a swapfile (that eventually supports hibernation) without destroying my system? And how can I fully remove the existing swap partition in the process?

Any hints, links, etc. appreciated!

Thanks in advance!

ec flag
If you plan on using hibernate (which appears to be the case), you'll need a swap file (or partition) at least as large as your RAM (from what you're showing, 48 GB).
Fred avatar
ch flag
I know. But that was not the question. I decided to ignore the confusing default configuration and just created a new swapfile additional to the existing drive. I use that for hibernation now and it all works well. I'm still confused about the current configuration and would like to understand it.
I sit in a Tesla and translated this thread with Ai:

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.