Swap ram

# Step 1: Check existing swap and disk space
sudo swapon --show
df -h

# Step 2: Create and configure a 1GB swap file
sudo dd if=/dev/zero of=/swapfile bs=1M count=2048
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile

# Step 3: Make the swap file permanent
echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab

# Step 4: Adjust swap settings (optional)
sudo sysctl vm.swappiness=10
echo 'vm.swappiness=10' | sudo tee -a /etc/sysctl.conf

# Step 5: Adjust cache pressure (optional)
sudo sysctl vm.vfs_cache_pressure=50
echo 'vm.vfs_cache_pressure=50' | sudo tee -a /etc/sysctl.conf

# Step 6: Verify swap usage
free -h
sudo swapon --show

Last updated