How to Create, Resize, or Extend a Linux Swap File | (Ubuntu)
Why Ask Ubuntu recommends it
Ask Ubuntu users link it when someone needs to enlarge or add a swap file, for example to fix freezing or to prepare for hibernation.
Recommended by 2 people across 2 different months, 2020 to 2025.
What it is
A roughly ten-minute terminal tutorial by SavvyNik on creating, resizing and extending a swap file on Ubuntu 20.04 LTS. It is aimed at systems without a swap partition and notes the steps apply to most Linux distributions.
What people said
Recommends Yehor · 2022-06 · Ask Ubuntu · on “How to enable the hibernate option in Ubuntu 20.04?”
Thanks, works unexpectedly well! Also would like to share a perfect video how to resize your swap file, which helped me a lot [this video]
Recommends Pittuga · 2025-02 · Ask Ubuntu · on “Lubuntu keeps freezing”
You guys are geniuses. Considering that my Mac froze constantly and now I've been using it for a couple of hours, it looks like adding swap resolved the problem. If anyone has a similar problem I recommend watching this video: " [this video] ". I read the disclosure above, but fail to add the bytes correctly. This video helped me a lot. Thank you all.
Cites PatrykP · 2020-12 · Ask Ubuntu · on “Ubuntu 20.04 - system cannot hibernate despite dealing with swapfile”
General description I want to switch from Windows to Linux, but there is one issue which doesn't allow me to use my Ubuntu 20.04 fully. I don't know how to make my computer hibernate. As I already learned, the problem is common and many answers can be found, but any of them helped me. To summarise my hardware: HP 250 G7 laptop with windows 10 on it and Ubuntu 20.04 (dual boot) 256 GB SSD, where about 150 GB is for Windows partition and about 90 GB for Linux (56 GB unused), 16 GB RAM What I get as a result of sudo hibernate and sudo pm-hibernate It depends. Before I could hibernate but only if I had small usage of RAM (not anymore). Sometimes the screen is black for a while and then comes bac