Hi,
Post by Eben KingI have an NVME drive as well as a spinning-rust drive. I've got swap on the
spinning drive, but I'd like to put the hibernate area on the NVME. Is that
possible, to have swap on one and hibernate on another?
Kind of.
You can create multiple swap partitions or swap files, and you can
specify which one is used for resuming from hibernate:
https://wiki.debian.org/Hibernation/Hibernate_Without_Swap_Partition
So, you can create a swap partition or file on the NVMe and find out
its UUID, then put that UUID in the kernel command line for when it
resumes from hibernate.
I do not think, however, that you can influence where the kernel
hibernates *to* when it is running and is told to hibernate. I think
it might just use the first area that's big enough.
## Things to investigate
I'm not in front of a machine that uses hibernate right now.
Perhaps you could experiment with having a swap area on your HDD
that is too small for hibernate, and a big enough one on your
NVMe, with the correct kernel command line to resume from the
area on the NVMe? Point is, I am wondering if the kernel is
smart enough to pick a contiguous swap area that is big enough,
or if it will look at the first (or a random) area and bail out
when it sees it is not big enough.
There is also the concept of swap priority. If you look in "man
swapon" you'll see how to set that, and it can also go in fstab
like this:
# swap on your HDD
UUID=07d183ff-30a4-425b-9aa8-11d09adca34d none swap sw,pri=0
# swap on your NVMe
UUID=ead96714-efdf-4758-8124-a79aa98dd052 none swap sw,pri=10
The above would cause the swap area on your NVMe to be of higher
priority than the one on your HDD, so your kernel will choose to
swap to NVMe before HDD (undesirable for you). I do not know if
the hibernate procedure also chooses like that.
## Fiddly, but should definitely work
As a last resort, you could keep your NVMe swap area unused (not
have it in fstab) and override systemd's hibernate unit to do a
"swapon" for the NVMe area and a "swapoff" of the HDD area just
before it does the actual hibernate. Together with the kernel
command line settings, this will force hibernate to go to the
only swap area available at that time (NVMe) and then boot
resume from same.
Personally though all of this is a lot of hassle and I would
probably only put swap on the NVMe.
Thanks,
Andy
--
https://bitfolk.com/ -- No-nonsense VPS hosting