1

I have installed a new ubuntu 22.04 WSL2 installation, and now have two active versions:

DESKTOP-16N83AG:/home/pjoot> wsl.exe --list --verbose
  NAME            STATE           VERSION
* Ubuntu-20.04    Running         2
  Ubuntu-22.04    Running         2

I can access the respective home directories from Windows using the paths:

\wsl.localhost\Ubuntu-22.04\home\pjoot \wsl.localhost\Ubuntu-20.04\home\pjoot

Is it possible to access the /home directory from my original ubuntu 20.04 installation from the new 22.04 installation (so that I can selectively mv or cp files/dirs), or will I be forced to do a tar/cp/untar sequence to migrate my content to the new distro version?

EDIT:

In https://superuser.com/a/1659355/101727 it is pointed out that it is possible to cross mount root directories from two different WSL distributions. I'm able to do that successfully using the first method in that answer, and see this after restarting the VM:

pjoot@DESKTOP-16N83AG:~/oldhome$ mount | grep home
pjoot@DESKTOP-16N83AG:~/oldhome$ df /mnt/wsl/instances/Ubuntu-20.04
Filesystem     1K-blocks    Used Available Use% Mounted on
/dev/sdc       263174212 1092172 248643884   1% /mnt/wsl/instances/Ubuntu-20.04
pjoot@DESKTOP-16N83AG:~/oldhome$ mount | grep sdc
/dev/sdc on / type ext4 (rw,relatime,discard,errors=remount-ro,data=ordered)
/dev/sdc on /mnt/wsl/instances/Ubuntu-20.04 type ext4 (rw,relatime,discard,errors=remount-ro,data=ordered)

As you can see, the mount worked. I can cd into my old /home directory and ls:

pjoot@DESKTOP-16N83AG:/mnt/wsl/instances/Ubuntu-20.04/home/pjoot$ ls -l
total 4
lrwxrwxrwx 1 pjoot pjoot   42 Dec 25 10:09 oldhome -> /mnt/wsl/instances/Ubuntu-20.04/home/pjoot
drwxr-xr-x 2 pjoot pjoot 4096 Dec 25 10:05 tmp
lrwxrwxrwx 1 pjoot pjoot   18 Dec 25 10:04 winhome -> /mnt/c/Users/peete

however, from the old Ubuntu-20.04 installation itself, I have a lot more:

DESKTOP-16N83AG:/home/pjoot> ls -l
total 36
lrwxrwxrwx  1 pjoot pjoot   29 Jan  6  2021 Downloads -> /home/pjoot/winhome/Downloads
lrwxrwxrwx  1 pjoot pjoot   15 Nov 22  2020 Dropbox -> winhome/Dropbox
drwxr-xr-x  8 pjoot pjoot 4096 Dec 23  2021 Gapauli.wl
lrwxrwxrwx  1 pjoot pjoot   56 Apr 24  2021 Scanned -> /mnt/c/Users/peete/OneDrive/Pictures/ControlCenter4/Scan
drwxr-xr-x  6 pjoot pjoot 4096 Feb  3  2021 freeware
drwxr-xr-x  4 pjoot pjoot 4096 Sep  9  2021 javatest
-rw-r--r--  1 pjoot pjoot  166 Nov  8  2020 notes
drwxr-xr-x 16 pjoot pjoot 4096 Nov  6  2020 physicsplay
drwxr-xr-x 45 pjoot pjoot 4096 Feb  7  2022 project
-rw-r--r--  1 pjoot pjoot  345 Jun  7  2021 reinstall.txt
drwxr-xr-x  2 pjoot pjoot 4096 Dec 25 10:20 tmp
lrwxrwxrwx  1 pjoot pjoot   18 Nov  6  2020 winhome -> /mnt/c/Users/peete
drwxr-xr-x  3 pjoot pjoot 4096 Apr 18  2022 wolfram

Notice that my 'tmp' and 'project' directories have the same permissions (and I am uid=1000, gid=1000 username=pjoot on both installations), but I tmp is visible from my Ubuntu-22.04 installation, whereas project is not?

7
  • 1
    Take a look at my answer to Is there a way to access files from one WSL 2 distro/image in another one?. I think the /etc/fstab approach is best here. Let me know if you have any questions, but if this does answer it for you, remember to click the button in the header to accept the duplicate suggestion. Thanks! Commented Dec 24, 2022 at 0:18
  • @NotTheDr01ds The mount itself that you suggest works, but only a strange seeming random subset of the files from the mount are visible, despite identical uid/gid. I've appended some notes to my question about that. Commented Dec 25, 2022 at 15:27
  • @PeeterJoot Okay - I'll take a look at that when I'm back from Christmas festivities and all. In the meantime, I've retracted my close vote. Commented Dec 25, 2022 at 15:40
  • Just trying to think ahead here. Looks like some other mount or link might be coming into play. What's mount | grep home show (if anything). Commented Dec 25, 2022 at 15:43
  • 1
    Right! As I mention in that post, I do recommend adding that line to "each distribution" ;-). Since it sounds like you've resolved it based on that post, please consider closing this one out by accepting the duplicate in the header. Your question might still serve as a useful "signpost", since some search terms might find your question before other. Thanks! Commented Dec 26, 2022 at 12:45

0

Browse other questions tagged .