recettes/temp-repo/Homelab/Increase Linux Swap file size.md

59 lines
No EOL
1,009 B
Markdown
Executable file

---
type: ressource
date: 2025-03-06T10:13
maturity: graine
---
To increase the size of your swap file on Linux Mint, follow these steps:
### Look how much swap you currently have
```sh
free -h
```
### Turn off the current swap file
```bash
sudo swapoff /swapfile
```
### Resize the swap file
Replace `XG` with the desired new size (e.g., `4G` for 4 GB):
```bash
sudo fallocate -l XG /swapfile
```
If `fallocate` is not supported, use:
```bash
sudo dd if=/dev/zero of=/swapfile bs=1M count=4096
```
(for 4 GB, adjust `count` accordingly)
### Set the correct permissions
```bash
sudo chmod 600 /swapfile
```
### Format the swap file
```bash
sudo mkswap /swapfile
```
### Enable the new swap file
```bash
sudo swapon /swapfile
```
### Verify swap space
```bash
free -h
```
### Make it permanent
Ensure the swap file is reactivated on reboot by adding this line to `/etc/fstab`:
```bash
echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab
```
Your swap size is now increased.
# Sources
ChatGPT