How to use a RAM drive in a domU qube?

Hi,

I work with big files (e.g. a gigabyte or more). While working on a particular file I save it many times in the process. At the end of the work on a particular file I save it back to HDD or SSD. The benefits of this are:

  1. Much higher read/write speed
  2. Great reduction of SSD writes

I have been doing all this on OS installed on bare metal (with enough physical RAM). On Linux I simply saved to a tmpfs mount and for Windows I used RAM drive created by particular software on Windows.

I understand Qubes OS has its specifics and guests (domU qubes) have no direct access to hardware, i.e. dom0 decides whether to swap the virtualized memory of a domU guest. So, even if I “write to tmpfs” in a domU qube, there is no guarantee that only actual physical RAM will be used (as I would like), even if such is available.

My question is: How can I use a RAM drive the way I have done it till now but in a domU qube? (assuming the qube may be either a Linux or a Windows guest)

If you assign enough memory to the domU you should be able to create a RAM drive using tmpfs or ramfs.

Dom0 doesn’t swap the domU memory to disk, not unless you configure it to do so, it just a memory controller making sure each domU is isolated.

I use RAM in a slightly different way - create a pool using tmpfs
drive and create new qubes using that pool.
These are fully functional qubes running entirely in RAM. You could
attach the storage or qvm-copy to a normal qube when you’ve finished
work.
There’s a sample script at GitHub - unman/stuff - ramqube.sh - simple
to edit to suit your needs.
I usually don’t use swap so it is not an issue for me. tmpfs can swap,
though not normally - if you were particularly concerned about this
you could change to ramfs, but then you cant limit the RAM used, and
risk OOM as you work.

rmram.sh does some cleanup when you are done.

1 Like

Thank you.

These two caught my attention:

Dom0 doesn’t swap the domU memory to disk, not unless you configure it to do so

kind of contradicts

tmpfs can swap, though not normally

Could someone please clarify how do I configure tmpfs not to swap (if that is possible)?

@unman your script is interesting. It made me ask myself - do all qubes (dom0 included) encrypt all RAM by default? I understand this is a whole separate topic. Perhaps we can talk about it in another thread.

I know nothing about Qubes OS pools, so I looked at this doc. Unfortunately, it is a heavy reading for a non-expert and I don’t quite understand everything. If you can point me to something easier for a start, that would be great.

Another thing: How do I measure the actual overall free/used physical RAM? I see this little widget on the XFCE panel which shows global storage usage on click but how about RAM? The well known free command ran in dom0 seems to show only the virtual RAM of dom0, not all the available RAM.

No contradiction

Not possible unless you disable swap altogether.

No they don’t (yet)

I don’t think there is anything easier.
The principle is simple - qube volumes are stored in storage pools. By default
there is one pool called vm-pool, which uses thin provisioned lvm. All
qube volumes (
You can create different pools - this page has details
for creating a new pool on a different storage device.
In 4.1 you can have lvm or file based pools, and you can set different
options for different pools.

You can set the storage pool to use when you create a new qube, or
change the default pool using qubes-prefs

I never presume to speak for the Qubes team.
When I comment in the Forum or in the mailing lists I speak for myself.

Not possible unless you disable swap altogether.

How do I do this?

Thank you for explaining about pools. I will look into it again.

Could you please tell about this too:

Another thing: How do I measure the actual overall free/used physical RAM? […]

Thanks.