diff --git a/qubes/tests/storage_zfs.py b/qubes/tests/storage_zfs.py
index 6ab948ae3..28e601faa 100644
--- a/qubes/tests/storage_zfs.py
+++ b/qubes/tests/storage_zfs.py
@@ -105,7 +105,8 @@ def freebytes(directory: str, without: str) -> int:
         return free
 
     if os.path.ismount("/rw") and freebytes("/rw", f"/rw/{name}.img") > want:
-        data_file = f"/rw/{name}.img"
+        os.makedirs(os.path.expanduser("~/.cache"), exist_ok=True)
+        data_file = os.path.expanduser(f"~/.cache/{name}.img")
     elif freebytes("/var/tmp", f"/var/tmp/{name}.img") > want:
         data_file = f"/var/tmp/{name}.img"
     else: