Using Windows pagefile as Encrypted Swap

Hello there!

I have migrated back to linux a couple of days ago but I intend to keep my windows 10 system for a while. My laptop has a small SSD drive, which is ideal for swap in my opinion. Problem is: I just have a few gigabytes available. I have, though, a huge pagefile.sys that windows uses for swap.

I don’t wanna waste 16 precious gigabytes by having a different swap for each system. I don’t plan to hybernate my W10 any longer, so that won’t be a problem. So I have formatted this file as swap with mkswap and activated with swapon.

Problem is: I would like this swap to be encrypted.

Any instructions on how to do that? I need some guidance for:

  • Encrypting it and mapping it
  • Understanding how cryptsetup would manage that, as W10, if booted, might overwrite the pagefile, therefore something possibly important for cryptsetup to work (??? I guess, I’m unsure)
  • I don’t mind activating it manually as needed, if I need to setup encryption again after booting W10, but if I could to this automatically that would be perfect.

Sincerely,
Daph

Windows WILL overwrite anything in the pagefile.sys file. Windows also creates and uses that file dynamically so it may change at times for you.

IMHO this is a very bad idea if you intend to continue to dual boot.

With fedora 33, 34, and now 35 a swap file/partition is not necessary unless you intend to hibernate fedora since by default fedora creates a virtual swap space using zram which can be seen using zramctl. Having a physical swap as well can in many instances be counterproductive.

I would recommend you NOT use a physical swap space since zram is in memory and thus is volatile. A simple power off will eliminate everything there (although suspend keeps it in memory and hibernate writes to a physical swap space)

2 Likes

Hello,

First of all, thank you for your reply.

I like the whole zram idea. However, I indeed intend to hibernate, that’s why I decided to setup a swap in the first place (that’s also why I’m worried about encryption).

And indeed, I think you’re right about the pagefile.sys idea, I better make some room for another file (as room for another partition would be really difficult). Anyway, I still don’t know how to do that and would appreciate any ideas.

Thanks!

– Daph

You could check if this How-To still works.

2 Likes