How can virtual memory be configured on Debian?
To configure virtual memory (also known as swap space) on a Debian system, you can follow these steps:
- Check the current size and usage of the swap space.
sudo swapon --show
- Create a file of a specific size, such as 1GB.
sudo fallocate -l 1G /swapfile
- Set the permission of the file:
sudo chmod 600 /swapfile
- Format the file as swap space.
sudo mkswap /swapfile
- Enable file swapping
sudo swapon /swapfile
- To permanently enable file exchange, you need to add the following line to the /etc/fstab file.
/swapfile none swap sw 0 0
- Modify the size of the swapping space (if necessary):
- You can adjust the size of swap space by modifying the swap line in the /etc/fstab file.
- Alternatively, you can disable the swap space using the ‘swapoff’ command, then recreate and enable the swap space.
- Finally, you can use the command swapon –show to confirm that the new swap space has been successfully set up.