lk/system/swap.md

68 lines
713 B
Markdown
Raw Normal View History

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