How can I copy files from VM_1 to VM_2 in [Dom0] Terminal?

Which command can be used from

[Dom0] Terminal - qubesos@dom0

from this

VM_1

the folder, ‘Recovery’ into this

VM_2

Copy or move files over?

Run from a VM_1 terminal: qvm-copy /path/to/Recovery and select VM_2 in the pop-up. It will copy to /home/user/QubesIncoming/VM_1/Recovery on VM_2. You can do this from File Manager: right click Recovery and select “Copy to other qube”.

You don’t need to do this from dom0 (and therefore shouldn’t in most cases), but you could wrap the above in qvm-run.

EDIT: qvm-copy-to-vm appears to be deprecated outside dom0 - use qvm-copy instead.

qvm-run -p VM1 "qvm-copy VM2 /home/user/Recovery"

I like the idea but it fails.

Forgot the --pass-io flag. Apols

qvm-copy only accepts file arguments, while qvm-copy-to-vm takes a destination qube argument that is apparently completely ignored (you select the actual destination in the popup for both commands). And now that I look around it’s also deprecated, so I’ll edit my earlier answer.

1 Like

https://github.com/QubesOS/qubes-issues/issues/9615

If you want to copy /home/user/foobar to another qube

qvm-run --pass-io SourceQube "tar cf - /home/user/foobar/" | qvm-run --pass-io DestQube "tar xvf - -C /"

Be careful, if you want to copy /home/user/foobar into a different location, it’s a different command.

3 Likes

Awesome, I just needed this line :slight_smile: Thanks for sharing!

I did a quick check:

qvm-run --pass-io SourceQube "cat /home/user/file.txt" | qvm-run --pass-io DestQube "tee /home/user/file.txt" > /dev/null

works as well.

Now, I wondering what makes more sense for big files or folders (1-20 GB):
A. tar locally first and move the tar afterwards (my cat / tee example) or
B. move the files or folders with the tar operation itself (your tar example)

Where are the tar operations executed? Creation in the SourceQube, unpacking in the TargetQube or all in dom0 (memory)? Please share your thoughts.

you don’t need tee, just use cat

in the qubes where tar is running, dom0 just contains data in the pipe, usually it’s 32 kb of memory but could be changed in bash IIRC

1 Like

Depending on where the files are stored and to be put, if they are in the private.img files then this operation is super simple and takes a minute to set up and do…

mkdir /mnt/from
mkdir /mnt/to
mount /var/lib/qubes/appvm/vmfrom/private.img /mnt/from
mount /var/lib/qubes/appvm/vmto/private.img /mnt/to
cp /mnt/from/path/to/files /mnt/to/path/where/to/put/files
umount /mnt/from
umount /mnt/to

DONE…

[ADDN]
If you don’t want to mount the FROM image, then just mount the TO image, go the the location, install TESTDISK into Domain-0, run TESTDISK on the FROM image, and recover files to the TO location.
Simple!

Super simple, but you are parsing the FS in dom0, and copying those
files in dom0. This is (as you should well know) not recommended, and
you should state a health warning.

If you want to go this route then it would be better to attach the
private images to a disposable, (well documented), and copy the files
there.

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

2 Likes

Very true, you are right, it should be done inside a separate guest if you don’t trust the data and information there in and you have something that will execute if the filesystem is mounted.

Same methodology, just inside a temporary guest.

VM_1 can unfortunately no longer be opened!