From a4b914376c9666aa56757258c1ae6d63cfccf920 Mon Sep 17 00:00:00 2001 From: Casual Date: Sun, 12 May 2024 02:04:43 +0300 Subject: [PATCH] new post --- content/tech/HowTo_make_swapfile.md | 34 +++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 content/tech/HowTo_make_swapfile.md diff --git a/content/tech/HowTo_make_swapfile.md b/content/tech/HowTo_make_swapfile.md new file mode 100644 index 0000000..01f9f10 --- /dev/null +++ b/content/tech/HowTo_make_swapfile.md @@ -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 >}}