I read from various sources that creating swap partitions on SSDs is not recommended. I have an SSD and an HDD, and 4 GB RAM. Is it possible to create the root and home partitions on the SSD, but have the swap partition on the HDD? If is it possible, should I do this?
On new installations of Ubuntu 17.04 and later a swap file is created by default instead of a swap partition. Among other things this saves valuable disk space on the SSD for users who have SSDs. So we don't put a swap partition on an SSD or on a HDD anymore. The swap file is located in the same partition where the root filesystem is located. On my computer which has 32GB RAM the swap file is the default size, only 1.5GB.
Since the advantage of a swapfile is that it is easy to resize, you may want to use SwapSpace to manage the size of your swapfile. SwapSpace is a small, stable system add-on that continuously and automatically adapts available virtual memory space to your actual memory needs. It claims disk space for use as swap space when needed, and frees it up for use by the filesystem when it is not needed. SwapSpace can be installed with
sudo apt install swapspace
in all currently supported versions of Ubuntu.What Swap
Ubuntu can have both a swap file and multiple swap partitions running at the same time. They can be on different disks. you can confirm this using
free
andswapon -s
The Swap partitions can be on SSD, HDD, SD and USB. Ubuntu will use them all.
Whether or not to do this is beyond the scope of this answer. Generally the faster the media, the faster the swap operation.
Recovery from hibernation will be faster if swap is on SSD rather than HDD.
For more information on hibernation using swapfiles see: How to Handle Full Install USB and Swap Space