Guest User

Untitled

a guest
Jan 17th, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.49 KB | None | 0 0
  1. #!/bin/sh
  2.  
  3. # size of swapfile in megabytes
  4. swapsize=2048
  5. # does the swap file already exist?
  6. grep -q "swapfile" /etc/fstab
  7.  
  8. # if not then create it
  9. if [ $? -ne 0 ]; then
  10. echo 'swapfile not found. Adding swapfile.'
  11. fallocate -l ${swapsize}M /swapfile
  12. chmod 600 /swapfile
  13. mkswap /swapfile
  14. swapon /swapfile
  15. echo '/swapfile none swap defaults 0 0' >> /etc/fstab
  16. else
  17. echo 'swapfile found. No changes made.'
  18. fi
  19.  
  20. # output results to terminal
  21. df -h
  22. cat /proc/swaps
  23. cat /proc/meminfo | grep Swap
Add Comment
Please, Sign In to add comment