2

I have a 240 GB SSD and 1 TB 5400 rpm HDD. Planning to install 18.04 on SSD and use HDD as /home. My concern is whether to put swap file on SSD or HDD. I have 8 GB RAM and will use 16 GB swap file. Do I have to locate swapfile on root or can I locate it on HDD, if yes how? Thanks.

3 Answers3

0

Usually you want a swap partition and not a swap file.

EDIT: looks like the above is no more valid.

That said, you can easily choose the location during the installation process, and you can certainly change it afterwards.

This official Ubuntu documentation on swap should get you started on deciding what to do and how to do it.

0

I don't think there's a problem installing Ubuntu on an SDD. Thus your swap file can be on the SSD with the root file system. If you want it on a hard disk (i.e., with /home, separate from the Ubuntu system), you probably can.

I haven't tried it myself but, for example, I have this in my /etc/fstab:

/swapfile                                 none            swap    sw              0       0

Thus, I don't see a reason why I couldn't replace /swapfile with /home/swapfile, if I really wanted to. You can try installing everything on the SSD, with /home on the hard disk. Then try running your system with the swapfile on either to see if you get any speed improvements.

In my opinion, one of the annoying things of earlier versions of Ubuntu was the swap partition... It made it hard to move it around after the system as installed. I don't have much experience with Ubuntu 18.04's use of a swapfile, but it seems to afford more flexibility, in this regard.

Does this answer your question? You used the phrase "have to" in your question and, in short, I don't think you have to put the swapfile in a particular place.

Ray
  • 2,200
0

Depends on the usage of either of the drives. If your memory is low but swappiness configuration is set high, what will happen is that system will write data to swap more often to free up actual RAM.

Frequent writes to SSD decrease it's expected life. Personally, I keep swap file on SSD, and haven't experienced any issues so far.

Frequent writes to HDD will prevent it from spinning down and saving power. My personal opinion is that it's perfectly OK to have it on HDD. It may be even more desirable to have it on HDD with high swappiness setting, thus avoiding extra wear on SSD. As for your home directory, just remember to have a backup.

On side note, 16GB of swap would be too much. It would only be useful if you have programs that have lots of temporary data and temporary files open, or lots of data that is loaded initially but rarely used. This is the main purpose of swap. For actually frequently used data you need RAM. So one thing to consider instead of large swap file is to add more RAM for actual performance.