715 B
715 B
+++ 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)
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:
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 >}}