I'm running Ubuntu 20.04, and I'm trying to create a hibernate command. I'm following these instructions.
Step 2 says
Then check whether the swap memory you allocated is more than or at least equal to the Physical memory(RAM).
I did that, and my /swapfile is 2 GB. I have 16 GB RAM, so I need to increase the size of that swap file. How do I do that in Ubuntu?
2 Answers
In sleep mode, the content of ram is kept as it is, and the computer works on a very low power mode, so as to keep the ram content intact (as ram will lose the data if power supply is cut to it). But in hibernation, the ram content is stored in the swap space, so power can be completely cut off. Hence it is recommended to have swap size as large as the ram size.
First disable the swap and delete it
sudo swapoff /swapfile sudo rm /swapfileCreate new swap space of size 16 GB (16 * 1024 = 16384).
bsis the block size. Basically bs * count = bytes to be allocated (in this case 16 GB). Here bs = 1M (M stands for mega, so we are assigning 1MB block size) and we are allocating 16384 * 1MB (=16GB) to swap.sudo dd if=/dev/zero of=/swapfile bs=1M count=16384Give it the read/write permission for root
sudo chmod 600 /swapfileFormat it to swap
sudo mkswap /swapfileTurn on swap again
sudo swapon /swapfileNow reboot the PC for the above changes to take place.
sudo su -
swapoff /swapfile
rm /swapfile
\# 32k -> 32GB swap size
dd if=/dev/zero of=/swapfile bs=1M count=32K
mkswap /swapfile
swapon /swapfile
Ctrl+D