Skip to content

Instantly share code, notes, and snippets.

@namgivu
Last active March 5, 2025 11:37
Show Gist options
  • Save namgivu/1d07ea0484af3e9defd680cd215b34f8 to your computer and use it in GitHub Desktop.
Save namgivu/1d07ea0484af3e9defd680cd215b34f8 to your computer and use it in GitHub Desktop.
increase mymory by swap file
# ref. https://askubuntu.com/a/1075516/22308
sudo swapoff /swapfile # make all swap off
sudo rm -rf /swapfile # remove the current
# 8Gb=8*1024Mb=8192 Mb
# 4Gb=4*1024Mb=4096 Mb
sudo dd if=/dev/zero of=/swapfile bs=1M count=4096 # resize the swapfile to 4Gb
# =
sudo chmod 600 /swapfile
sudo mkswap /swapfile # format the file as swap
sudo swapon /swapfile # activate it
sudo swapon -s # view swap size
# ensure swapfile persist wh reboot - add to /etc/fstab ifnotalreadypresent ref https://x.com/i/grok/share/ctPttiuOtlGwhOndGj6lrKXLq
if ! grep -q '/swapfile' /etc/fstab; then
echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab
fi
@Medigato
Copy link

Medigato commented Aug 5, 2023

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment