new post
This commit is contained in:
parent
0a0f5a3dc7
commit
a4b914376c
34
content/tech/HowTo_make_swapfile.md
Normal file
34
content/tech/HowTo_make_swapfile.md
Normal file
@ -0,0 +1,34 @@
|
||||
+++
|
||||
title = "HowTo make swapfile"
|
||||
date = 2024-05-12
|
||||
+++
|
||||
|
||||
Script creates swapfile in current dir with size of physical RAM
|
||||
(you can just CopyPaste to terminal)
|
||||
|
||||
```bash
|
||||
ram=$(($(cat /proc/meminfo | grep -i 'memtotal' | grep -o '[[:digit:]]*')/1024/1024+1))
|
||||
|
||||
touch ./swapfile
|
||||
chattr +C ./swapfile #btrfs fix
|
||||
sudo fallocate -l ${ram}G ./swapfile
|
||||
sudo chmod 600 ./swapfile
|
||||
sudo mkswap ./swapfile
|
||||
sudo swapon ./swapfile
|
||||
|
||||
swapon --show
|
||||
```
|
||||
|
||||
|
||||
|
||||
Swap is not permanent, to make it permanent:
|
||||
```bash
|
||||
sudo cp /etc/fstab /etc/fstab.bak
|
||||
|
||||
echo "$PWD/swapfile none swap sw 0 0" | sudo tee -a /etc/fstab
|
||||
```
|
||||
|
||||
{{< source >}}
|
||||
https://itsfoss.com/create-swap-file-linux/
|
||||
https://wiki.archlinux.org/title/Btrfs
|
||||
{{< /source >}}
|
Loading…
Reference in New Issue
Block a user