I run a rather plain Xubuntu bionic 18.04 install, with some extra user applications installed, but no extra systems software that I know of.
Now that I have extended my RAM to 16GB, I seem to have started using applications that use that much memory and more, much more. So I finally have regular use for swapping too. Instead of re-partitioning my disks, I added a swap file on the second disk that runs smoothly besides my swap partition on the first disk. The advantage is that work is spread over 2 disks, and I can feel the speed. In the /etc/fstab
it looks like this:
LABEL=TSWP none swap sw,pri=1,nofail
/media/sdata/.swapfile none swap sw,pri=1,nofail
This results in typical swapon reports like this :
NAME TYPE SIZE USED PRIO
/dev/sda2 partition 16G 4,8G 1
/media/sdata/.swapfile file 16G 4,7G 1
The application that causes so much swapping behaves very well with it (niced), and does not keep other applications from running smoothly. But it is one that often needs days or weeks to complete, and I would like to switch off my computer once in a while. Hibernation would be recommended.
Having ample swap space now, hibernating itself should be no problem. But where do I direct the kernel to, to resume from? There are loads of answers here (and on othe forums) that tell you how to do that for 1 swap location. But what if you have 2 locations?
I could replace the swap file by a second swap partition on that same 2nd disk, and keep the advantage of spreading swapping workload, but that does not solve a thing: I still would not know which partition the hibernate image is written to, so I wouldn't be able to tell the kernel which swap partition to resume from.
I could enlarge my original swap partition, and drop the swap file, but then I would loose the advantage of having 2 swapping locations. Also reorganising filled disks is risky business.
I could differentiate the swap priority. If I give the swap file higher priority, and swapoff/swapon the swap partition, after some time the swapon report looks like this:
NAME TYPE SIZE USED PRIO /dev/sda2 partition 16G 0B 1 /media/sdata/.swapfile file 16G 9,3G 2
The swap partition in theory remains free for hibernation, as long as the swap file is large enough to handle all swapping. But not only do I loose the advantage of workload spread with this, it also seems probable that hibernation would follow the same priorities as swapping, and go for the used swap location instead of for the free one.
I could add a
pm-utils
script to swapoff one of both swap locations as preparation for hibernate, leaving only the other location to choose from. But this would gravely diminish my chances of having enough unused swap space for the hibernation image, the opposite of what I obtained by adding a 2nd swap location.On the same level, I could mount/activate one swap location in
/etc/fstab
, and swapon the other in some startup script. Would that solve anything? Would the hibernation process look to/ect/fstab
instead of to actual active swap locations? I guess not.
So my question is this: be it either 2 swap partitions, or 2 swap files, or 1 of each, how do I configure, or reliably predict, to which location the hibernation image will be written to? So that I can instruct the kernel to resume from that location, instead of seeking in vain on the other and loose the state of my long-running job.
A secondary question is: how would I go about finding the solution for my apparently special case myself. Does, for instance, systemctl hibernate
call pm-hibernate
of the pm-utils
, is it the other way round, or is yet another agent finally responsible for the hibernation. Is any of these configurable with regards to swap location? Can I instead install another systems utility that is configurable in that way?
Thanks for your attention.