How to Increase Linux Swap Memory by Resizing a Swap File
HardReset.InfoJanuary 2, 20265 min178 views
9 connectionsΒ·8 entities in this videoβChecking Current Swap
- π Check current swap status using
free -horswapon -sto see existing swap file size and location. - π‘ The video demonstrates resizing an existing 2GB swap file to 4GB, assuming one is already created.
Disabling and Removing Existing Swap
- β οΈ Turn off the swap file using
sudo swapoff /swapfileto disable it. - ποΈ Remove the existing swap file with
sudo rm /swapfile. - π Ensure you use the correct path for your swap file if it differs from
/swapfile.
Creating and Configuring a New Swap File
- π Create a new, larger swap file (e.g., 4GB) using
sudo fallocate -l 4G /swapfile. - π Set secure permissions for the swap file with
sudo chmod 600 /swapfile, ensuring only the administrator has read/write access. - π οΈ Format the new swap file as swap space using
sudo mkswap /swapfile. - β
Activate the new swap file immediately with
sudo swapon /swapfile.
Verifying and Making Swap Persistent
- π Verify the new swap size and status using
swapon -sorfree -hto confirm it's active and shows the correct size. - π Make the swap file persistent across reboots by editing
/etc/fstab. - π Add the line
/swapfile none swap sw 0 0to the end of/etc/fstabto ensure the swap file is mounted automatically after restarting the system.
Knowledge graph8 entities Β· 9 connections
How they connect
An interactive map of every person, idea, and reference from this conversation. Hover to trace connections, click to explore.
Hover Β· drag to explore
8 entities
Chapters2 moments
Key Moments
Transcript20 segments
Full Transcript
Topics11 themes
Whatβs Discussed
LinuxSwap MemorySwap FileResize Swap FileTerminal CommandsfstabchmodmkswapswaponfallocateLinux Tips
Smart Objects8 Β· 9 links
ProductsΒ· 7
ConceptΒ· 1