2022-01-16 18:20:39 +00:00
|
|
|
---
|
|
|
|
title: "swap"
|
|
|
|
tags: [ "Documentation", "basics" ]
|
|
|
|
---
|
2020-01-02 00:04:35 +00:00
|
|
|
# Making a Swap File
|
|
|
|
|
2022-05-01 18:52:45 +00:00
|
|
|
> cd /var/cache/
|
2020-01-02 00:04:35 +00:00
|
|
|
|
|
|
|
> sudo dd if=/dev/zero of=swapfile bs=1K count=4M
|
|
|
|
|
|
|
|
This creates a swapfile of (1k x 4M) 4 Gigs.
|
|
|
|
Change 4M to XM for an XGig swap.
|
|
|
|
|
|
|
|
> sudo chmod 600 swapfile
|
|
|
|
|
|
|
|
> sudo mkswap swapfile
|
|
|
|
|
|
|
|
> sudo swapon swapfile
|
|
|
|
|
|
|
|
Test it's working with top
|
|
|
|
|
|
|
|
> top -bn1 | grep -i swap
|
|
|
|
|
|
|
|
or:
|
|
|
|
|
2022-05-01 18:52:45 +00:00
|
|
|
> echo "/var/cache/swapfile none swap sw 0 0" | sudo tee -a /etc/fstab
|
2020-01-02 00:04:35 +00:00
|
|
|
|
|
|
|
Test it'll work at boot with:
|
|
|
|
|
|
|
|
> sudo swapoff swapfile
|
|
|
|
|
|
|
|
> sudo swapon -va
|
|
|
|
|
|
|
|
# Partition Swaps
|
|
|
|
|
|
|
|
Put this in /etc/fstab:
|
|
|
|
|
|
|
|
`UUID=blah-blah none swap sw 0 0`
|
|
|
|
|
|
|
|
Then test it works with:
|
|
|
|
|
|
|
|
> sudo swapon -va
|
|
|
|
|
|
|
|
Test other partitions in fstab with:
|
|
|
|
|
|
|
|
> sudo mount -a
|
|
|
|
|