Skip to content

Instantly share code, notes, and snippets.

@0x7d7b
Last active November 28, 2021 10:18
Show Gist options
  • Save 0x7d7b/721bb9238558be1a2b70c1ddadb26702 to your computer and use it in GitHub Desktop.
Save 0x7d7b/721bb9238558be1a2b70c1ddadb26702 to your computer and use it in GitHub Desktop.
Raspberry Pi Swap File

This is a small howto about changing the swap file size on a Raspberry Pi which runs with a raspbian operating system.

Configuration

The swap file size is configured in the /etc/dphys-swapfile file. By default its size is 100 MB. To change that set the CONF_SWAPSIZE value to something else. Here I chanted it to 500 MB:

CONF_SWAPSIZE=500

Reload

Now the dphys-swapfile.service service needs to be reloaded:

sudo systemctl restart dphys-swapfile.service

Verify

To verify the new swap file size type in the free command:

$ free
              total        used        free      shared  buff/cache   available
Mem:         948296      462200       46824       32152      439272      441208
Swap:        511996      130048      381948

The new swap file size is shown correctly. So we're done.

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