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