First published at 02:58 UTC on February 20th, 2024.
In this video, I show you how to create a swapfile.
In the good ol days, we used to create a partition and mount that partition on boot as swap,, but timesachanging ;)))))))))))
Modern ssds are also super fast so swap is more welcomed now ;))))))
…
MORE
In this video, I show you how to create a swapfile.
In the good ol days, we used to create a partition and mount that partition on boot as swap,, but timesachanging ;)))))))))))
Modern ssds are also super fast so swap is more welcomed now ;))))))
Step 1:
(Potentially Optional)
If you don't know the binary value of the MB you need, go here and use the calculator for the bin value: https://www.gbmb.org/gb-to-mb
Step 2:
Use dd to create a swapfile. I just wrote this on the top of the root directory. it's up to you, you can create sub directories on ROOT,name the file differently etc...
sudo dd if=/dev/zero of=[/path/to/swap] bs=1M count=[swap size] status=progress
Ex 8GB, on ROOT
sudo dd if=/dev/zero of=/swapfile bs=1M count=8192 status=progress
Step 3:
Set the permissions:
sudo chmod 0600 /swapfile
Step 4:
Set some swap file properties:
sudo mkswap -U clear /swapfile
Step 5:
Activate swap:
sudo swapon /swapfile
Step 6:
Confirm it is running you should see something like this after....:
free -m
total used free shared buff/cache available
Mem: 31247 7021 8282 644 17038 24226
Swap: 32767 0 32767
Step 7:
Add to fstab to automatically load on boot:
sudo nano /etc/fstab
[/path/to/swapfile] none swap defaults 0 0
Ex:
/swapfile none swap defaults 0 0
Pls like + sub ;))
Source originally here: averagelinuxuser.com
LESS