How to Change Swap Size in Ubuntu

Share:
Change Swap Size in Ubuntu - Deactivate the swap ```sh sudo swapon /swapfile ``` - create a file which will be used as a swap space. bs is the size of one block. count is num of blocks. it will get 1024K * 1M = 1G space. ```sh sudo dd if=/dev/zero of=/swapfile bs=1024 count=1048576 ``` 20G: sudo dd if=/dev/zero of=/swapfile bs=64M count=320 - Ensure that only the root user can read and write the swap file: ```sh sudo chmod 600 /swapfile ``` - set up a Linux swap area on the file ```sh sudo mkswap /swapfile ``` - activate the swap ```sh sudo swapon /swapfile ``` - "sudo swapon --show" or "sudo free -h" you will see the swap space. cover

No comments