【问题标题】:How to access a WSL instance from another?如何从另一个访问 WSL 实例?
【发布时间】:2020-07-06 17:34:56
【问题描述】:

我正在将我的 WSL2 实例从 Debian 10 升级到 Ubuntu 20.04 LTS,因为我需要一些更新的软件包。

如何将文件和目录从 Debian 复制到 Ubuntu,同时保留权限和所有者? (uid和gid在两个Linux下是一样的)

复制到windows首先会改变文件的权限和所有者。

explorer.exe 也会更改权限和所有者。

最好,我还希望避免创建一个可以从 Debian 和 Ubuntu 依次挂载的共享磁盘映像文件。

我想要一些更简单的东西,比如直接从第一个 WSL 实例访问第二个实例,例如,

    $ cp -a <Debian>/myfiles/ <Ubuntu>/myfiles

这可能吗?

【问题讨论】:

标签: windows-subsystem-for-linux


【解决方案1】:

使用焦油。它将保留所有文件元数据。

中,创建 myfiles.tar.gz:

tar zcvf myfiles.tar.gz myfiles

myfiles.tar.gz 复制到您的 Windows 驱动器,例如使用explorer.exe/mnt/c,然后将myfiles.tar.gz 复制到。在 中,解压它:

tar zxvf myfiles.tar.gz myfiles

【讨论】:

    【解决方案2】:

    另请参阅我的类似问题:How to access \wsl$\othercontainer\some\file from within a WSL container? 简短回答是:

    sudo mkdir /mnt/othercontainer
    sudo mount -t drvfs '\\wsl$\othercontainer' /mnt/othercontainer
    ls -l /mnt/othercontainer/some/file
    

    注意:似乎不支持符号链接。

    【讨论】:

      猜你喜欢
      • 2012-12-18
      • 2012-12-13
      • 2016-01-04
      • 1970-01-01
      • 2012-05-21
      • 2020-04-14
      • 2011-07-26
      • 1970-01-01
      相关资源
      最近更新 更多