Can I Use Virtual Memory/Page File For VM's RAM

Is it possible to use Virtual Memory/Page File For VM’s like in the Windows-OS?
instead of using actual RAM, make the VM’s use a SSD for RAM with a PAGE_FILE or something. I’m not very familiar with LINUX/QUBES memory settings/utilization, so are there any settings/options for such Virtual Memory configs at all?

Give qube less memory that it need and it will use swap.

can you explain in more detail how this works please?

When a Linux system is not having enough memory, programs that are running but not very active are moved to the swap (usually a partition / file on the storage) which is utterly slow and create hiccups and make things unresponsive.

This is more a “last chance to recover” feature than something you should actually look for in a regular situation. If a Linux system is really too tight on memory, the kernel will randomly kill programs until it can breath some fresh memory, this is called the “out of memory killer”.

1 Like

I noticed in Fedora VM Terminal with “lsblk” there is already a “swap partition”

xvdc 202:32 1 12G 0 disk
├─xvdc1 202:33 1 1G 0 part [SWAP]
└─xvdc3 202:35 1 11G 0 part

I tested making that whole “xvdc-disk” a “swap partition” on a “fedora template” with “GParted” and it worked, but only for that session.
once i turned off the “fedora template” the new “swap partition” was reset & lost.

is there a way to increase that “xvdc - disk” size + make the whole drive a “swap partition” on the “fedora template” and keep it there without it resetting once its shutdown so it can be used with other APP-VMs that use that “fedora template” ?

Every appVM have it’s own private swap partition equal to amount of ram created durin startup and destroyed during closing.

Dunno if setting swap in template was corrected but you could use startup script or make fstab to use different swap

This is now a forum community guide:

xvdc 202:32 1 12G 0 disk
├─xvdc1 202:33 1 1G 0 part [SWAP]
└─xvdc3 202:35 1 11G 0 part

so is there any other way to increase this “xvdc - disk” 12-G size & make the whole drive a permanent “swap partition” on a “fedora template” and keep it there without it resetting once its shutdown, so it can be used with other APP-VMs that use that “fedora template” ?

or are my only options what are listed at this link?

First of all using one central swap partition for multiple machines is risky.

Second, only one machine at a time could use said partition. In order to be used by another one you need to close first machine, run second, attach partition to it and make it swapping. And that for every machines that you want to use it.

1 Like

I think you are mistaking what I said for an actual separate physical partition drive that’s outside of the fedora vms.

i’m talking about the disk drives that are listed inside the fedora vms with “lsblk”

NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS
xvda 202:0 1 20G 0 disk
├─xvda1 202:1 1 200M 0 part
├─xvda2 202:2 1 2M 0 part
└─xvda3 202:3 1 19.8G 0 part /
xvdb 202:16 1 100G 0 disk /usr/local
/home
/rw
xvdc 202:32 1 12G 0 disk
└─xvdc1 202:33 1 12G 0 part [SWAP]
xvdd 202:48 1 705.8M 1 disk

I want to make the “xvdc/xvdc1” “12-G disk” inside the fedora vms a bigger permanent “SWAP” partition that persists after shutdowns/restarts of the vm.
when i use “GPART” inside the vm to make “xvdc/xvdc1” a bigger “SWAP” partition, it gets reset back to “1-G” every time I restart/shutdown the vm.

I really don’t understand what your are trying to achieve. The swap is supposed to be an “emergency” solution to me, especially in Qubes OS. If you really really want more swap, use a file and swap on it. This is a general Linux procedure that I don’t know precisely. Here is an example:

https://wiki.archlinux.org/title/Swap#Swap_file

This can be put inside a rc.local file

Bonus:

Every VM has 4 block devices connected:

  • […]
  • xvdc – volatile.img, discarded at each VM restart – here is placed swap and temporal “/” modifications (see below)

As @parulin wrote, xvdc is volatile, you can’t make it persistent.
I’ve linked you document from Qubes OS github how to make bigger SWAP in user space and that it’s the only way but you constantly want to make volatile persistent. If you have free drive lying in shelf and use it for SWAP then attach it permanently to one VM and use it as SWAP. Leave xvdc alone.

For what you need big persistent SWAP?