0

I installed Ubuntu 22.04 in WSL2 and I want to transfer files from Ubuntu 20.04 that is installed in a same Windows.

At first I send files via mounted Windows files sysmtem.

Rsync in Ubuntu 20.04:

rsync ~/foo /mnt/c/tmp

Rsync in Ubuntu 22.04:

rsync /mnt/c/tmp ~/foo

But with this way permissions are collapsed.

Is there are recommended way to transfer files between two WSL systems?

Giacomo1968
  • 53,069
  • 19
  • 162
  • 212
ironsand
  • 2,179
  • 7
  • 30
  • 48
  • Have you tried the `-avz` parameters with Rsync? That is standard for many Rsync commands. The key is the `-a` parameter which is the [`--archive`](https://serverfault.com/q/141773/100013) mode that preserves ownership and permissions. The `-v` is verbose mode and `-z` compresses files during the transfer. You could try it with just `-a` like this `rsync -a ~/foo /mnt/c/tmp` or even `rsync -a /mnt/c/tmp ~/foo`. Let me know if this works for you and I can post it as an answer. – Giacomo1968 Oct 17 '22 at 02:03
  • 2
    Does this answer your question? [Is there a way to access files from one WSL 2 distro/image in another one?](https://superuser.com/questions/1659218/is-there-a-way-to-access-files-from-one-wsl-2-distro-image-in-another-one) -- Let me know if that helps. All of those options I mention in my answer there should keep permissions. But transferring files to the `/mnt/c` (which doesn't quite match up with your title) will have permission issues unless you add the `metadata` mount option as in [this answer](https://superuser.com/a/1628273/1210833). – NotTheDr01ds Oct 17 '22 at 02:17

0 Answers0