Skip to content

Instantly share code, notes, and snippets.

@nurmdrafi
Created April 9, 2024 06:19
Show Gist options
  • Save nurmdrafi/1ba0d06c8065ad6a610ed37f9f2a7f76 to your computer and use it in GitHub Desktop.
Save nurmdrafi/1ba0d06c8065ad6a610ed37f9f2a7f76 to your computer and use it in GitHub Desktop.
Create, Resize, or Extend a Linux Swap File
# check memory
$ free

# check swap file location, (default location - '/')
$ swapon

# turn off swap using swapfile location
$ sudo swapoff /swapfile

# remove swapfile
$ sudo rm swapfile

# create swapfile (zero, location, block size, count, status)
$ sudo dd if=/dev/zero of=/swapfile bs=1M count=4096 status=progress

# permission
$ sudo chmod 600 /swapfile

# formating
sudo mkswap /swapfile

# enable swapfile
$ sudo swapon /swapfile
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment