Difference between revisions of "Swap"

From Wasya Wiki
Jump to: navigation, search
Line 1: Line 1:
  
sudo fallocate -l 4G /swapfile
+
  swapoff /swapfile
sudo dd if=/dev/zero of=/swapfile bs=1024 count=4194304
+
  sudo fallocate -l 4G /swapfile
sudo chmod 600 /swapfile
+
  sudo dd if=/dev/zero of=/swapfile bs=1024 count=4194304
sudo mkswap /swapfile
+
  sudo chmod 600 /swapfile
sudo swapon /swapfile
+
  sudo mkswap /swapfile
 +
  sudo swapon /swapfile
  
# /etc/fstab
+
  # /etc/fstab
/swapfile swap swap defaults 0 0
+
  /swapfile swap swap defaults 0 0
  
sudo swapon --show
+
  sudo swapon --show
sudo free -h
+
  sudo free -h
  
cat /proc/sys/vm/swappiness
+
  cat /proc/sys/vm/swappiness
sudo sysctl vm.swappiness=10
+
  sudo sysctl vm.swappiness=10
  
sudo swapoff -v /swapfile
+
  sudo swapoff -v /swapfile
# and remove the entry from /etc/fstab
+
  # and remove the entry from /etc/fstab
sudo rm /swapfile
+
  sudo rm /swapfile

Revision as of 05:12, 1 February 2024

 swapoff /swapfile
 sudo fallocate -l 4G /swapfile
 sudo dd if=/dev/zero of=/swapfile bs=1024 count=4194304
 sudo chmod 600 /swapfile
 sudo mkswap /swapfile
 sudo swapon /swapfile
 # /etc/fstab
 /swapfile swap swap defaults 0 0
 sudo swapon --show
 sudo free -h
 cat /proc/sys/vm/swappiness
 sudo sysctl vm.swappiness=10
 sudo swapoff -v /swapfile
 # and remove the entry from /etc/fstab
 sudo rm /swapfile