Really disposable (RAM based) qubes

Are there any existing GitHub issues related to (but opened before) this thread or should we probably open one?

I wonder how to approach this properly, so that it doesn’t get just quickly rejected.

1 Like

@qubist Thanks a lot! :slight_smile:
Like @whoami , everything works perfectly!

1 Like

Friends,

As it seems, we have all been fooling ourselves the whole time. Our “RAM based” qubes are not what we thought they were (i.e. they are not RAM based):

3 Likes

I admit that I’m not sure I understand everything (a bit too technical for me).

What I notice on my side is that when I restart, the /ram_pool folder is completely empty (which is normal) There are just traces of.log files and files in the /run and /etc directory. If I delete the.log files and the /etc/libvirt/libxl/ram_disp.xml file right after closing the ram_disp with a bash script:

#!/bin/bash

sudo rm -rf /etc/libvirt/libxl/ram_disp.xml
sudo rm -rf /var/log/libvirt/libxl/ram_disp.log
sudo rm -rf /var/log/xen/console/guest-ram_disp.log
sudo rm -rf /var/log/qubes/qrexec.ram_disp.log
sudo rm -rf /var/log/qubes/guid.ram_disp.log
sudo rm -rf /var/log/qubes/qubesdb.ram_disp.log

All files disappear (in the /run and /etc folders as well).
There are still files in.desktop, .menu, .directory in the /home/tezeria/ folder (normal because my ram_disp is not based on a template-disposable) and the /var/lib/qubes/appvms/debian-12-ram file (which doesn’t seem to be a problem because the file is empty).
Edit: volatile.img disappear after closing ram_disp as well.

Like i said, i don’t understand everything in your link, and you know i’m not a professional lol , but i don’t see where is the trouble if there is nothing after ram_disp is closing… :confused:

1 Like

Your approach is really close to @unman’s except that you place the pool directly in the RAM (right?). Which I think is a good thing…

1 Like

@Tezeria

What you don’t see is not what you don’t see (and what I did not see)! :slight_smile:

In short:

The actual data of the DispVM (/home) is not kept in RAM but on pool00 where the DVM template resides. It is the private volume (containing /home) which we need to have in RAM but that is currently not possible (without complex tricks) due to the way Qubes OS works.

Your approach is really close to @unman’s except that you place the pool directly in the RAM (right?). Which I think is a good thing…

His script does the same. The result is the same too.

2 Likes

unman’s script is different because it creates an AppVM in the tmpfs pool (not a DispVM), so writes to the ‘private’ volume do end up in the tmpfs.

For DispVMs, it’s necessary to at least clone their disposable template into the tmpfs pool to achieve the same. Then set the rw property of the clone’s ‘root’ volume to False - which will be inherited by the DispVMs based on it - redirecting writes to that volume (outside the tmpfs pool) to the ‘volatile’ volume (inside the tmpfs pool). Optionally, set the ephemeral property of the clone’s ‘volatile’ volume to True.

5 Likes

Thanks a lot for your dedication @qubist. I am not technical enough to guess how to use this unfortunately.

For me a few things are not clear, I will try to be the voice of less technical people:

  1. How would I use this script? Just execute it in dom0?

  2. How can I set the template we want to use for the dispVM?

  3. Can I create a shortcut to click on so I can execute this script?

These functionalities are awesome, it would be great to have them in Qubes 4.2 stable release. Meanwhile if we could add to the script the creation of a shortcut icon to use this functionality easily for anyone would be very good.

1 Like

@rustybird

unman’s script is different because it creates an AppVM

Ha! I have somehow missed that essential detail. I guess with that trick we can have AppVMs which will be disposable due to the RAM storage. Thanks!

I am testing this right now and another question arises:

What happens if the user tries to e.g. install some software (as root) in the RAM-based AppVM or otherwise adds data to / (non-/rw)? Which volume will be used for that? When I tried, I see no increase in the usage which qvm-volume reports in neither volume (private, volatile or root).

So, where does this data go?

Could you also help with this security question:

Suppose that instead of having separate tmpfs pools for each RAM based AppVM (with separate tmpfs mounts), we have a common large one containing all img files for all such qubes. Does that approach have any anti-security consequences? The idea is to possibly create RAM-based AppVMs replacing the current disk-based sys-* disposable qubes, so that they work entirely in RAM.

1 Like

@Bob3

  1. Yes.

  2. -p template=...

  3. Yes.

1 Like

Tanks for this explanation,
I’m going to bed less stupid tonight! :stuck_out_tongue:

1 Like

what i do for a bash script is

  • Rightclicking on Desktop
  • Selecting ‘Create a new launcher here’
  • in the ‘command’s line’ bash /folder_of_the_script/your_bash_script
  • then i cut the file in the folder i want
    After that, i could double-click on this file to execute the script.
1 Like

If you chmod +x <script-name>, then you can simply run it directly through /your-dir/<script-name> (no bash before it) or through <script-name> if you placed it in a dir from your PATH.

1 Like

@rustybird

Some more questions:

The first approach you suggested (AppVM on a tmpfs pool) works fine.

I am testing the second approach, however I am facing a strange issue after the qube is shut down in the new cleanup function, where I remove the qubes and pools:

qvm-kill "${qube_name}"
qvm-remove --force "${qube_name}" "${template_clone}"
qvm-pool remove "${pool_name}"
sudo umount "${pool_name}"

Strangely, unlike the first case, umount gives an error “target is busy”. The qubes are removed, the pool is removed, yet “target is busy”.

Trying lsof | grep <mountpoint> shows me nothing, so the only way to get out of this is to use umount --lazy (which I know may have unpredictable result and is unsafe).

I really can’t find the reason why this is happening.
Can you explain?

1 Like

Updated.

What’s new:

Now, the RAM based qubes are AppVMs. The script clones the DVM template into the RAM pool, sets its property template_for_dispvms to false, thus turning it into a regular AppVM, and runs the specified command. The result is that the private volume is in RAM now.

Also, the whole RAM pool is now encrypted with an ephemeral key.

Special thanks to @rustybird and @marmarek for all clarifications.

5 Likes

When running the cleanup script the /var/log files of the disposable vms do not disappear. I cannot understand why.

1 Like

Please provide the actual steps to reproduce.

1 Like

I just put the script in /home/user/ of dom0 and name it cleanup.sh. then I run ./cleanup.sh after making the script executable and nothing happens.

1 Like

Strange.
What if you run it with bash -x ~/cleanup.sh? Where does it stop?

1 Like

The ‘root’ volume.

The rw property of the AppVM’s ‘root’ volume should be set to False, so that writes to it are diverted to (the ‘volatile’ volume in) the pool.

You mean the pool’s ephemeral_volatile property? That’s just a default for the ephemeral property of ‘volatile’ volumes in the pool, nothing more.

2 Likes