It is still possible to use Windows pagefile.sys as a swap file in Linux and not so complicated after all.
First you need to auto-mount your Windows partition at start-up. Add this line to
UUID=<MY_UUID> /mnt/Windows_C auto auto 0 0
Then create a script that will format the swap file if necessary and mount it. For example
type=$(blkid -s TYPE -o value $pagefile)
if [[ $type != swap && $type != swsuspend ]]; then
Make the script executable and create a service to launch it after the Windows partition has been mounted: create the file
Description=Use Windows swap file
Start the service to check it's working:
sudo systemctl start swap
If the script is working, the command
swapon should return something like:
NAME TYPE SIZE USED PRIO
/mnt/Windows_C/pagefile.sys file 8,5G 0B -2
If not, try to do
systemctl status swap.service to see what happened.
If everything went OK you can enable the service:
sudo systemctl enable swap
Now you're mostly done. If you want to avoid some insecure permissions warnings on pagefile.sys, you need to set up a permission mapping between Windows and Linux.
To do so, unmount the Windows partition then generate a user mapping file:
sudo ntfsusermap /dev/disk/by-uuid/<UUID>
Remount the partition and move the user mapping file to a new folder named
sudo mkdir /mnt/Windows_C/.NTFS-3G
sudo mv UserMapping /mnt/Windows_C/.NTFS-3G/
From what I saw, you do not need to do anything on the Windows side, the reformating of pagefile.sys is automatic at start-up.
Run script after fstab
How do I use 'chmod' on an NTFS (or FAT32) partition?