如何从另一个访问 WSL 实例?
How to access a WSL instance from another?
我正在将我的 WSL2 实例从 Debian 10 升级到 Ubuntu 20.04 LTS,因为我需要一些更新的软件包。
如何将文件和目录从 Debian 复制到 Ubuntu,同时保留权限和所有者? (uid和gid在两个linux下是一样的。)
复制到 windows 首先更改文件的权限和所有者。
explorer.exe
也更改权限和所有者。
最好,我还想避免创建共享磁盘映像文件,我可以依次从 Debian 和 Ubuntu 挂载该文件。
我想要更简单的东西,比如直接从第一个 WSL 实例访问第二个 WSL 实例,例如,
$ cp -a <Debian>/myfiles/ <Ubuntu>/myfiles
这可能吗?
使用tar。它将保留所有文件元数据。
在 中,创建 myfiles.tar.gz
:
tar zcvf myfiles.tar.gz myfiles
将 myfiles.tar.gz
复制到您的 windows 驱动器,例如使用 explorer.exe
或 /mnt/c
,然后将 myfiles.tar.gz
复制到 。在 中,untar 它:
tar zxvf myfiles.tar.gz myfiles
另见我的类似问题: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
注意:似乎不支持符号链接。
我正在将我的 WSL2 实例从 Debian 10 升级到 Ubuntu 20.04 LTS,因为我需要一些更新的软件包。
如何将文件和目录从 Debian 复制到 Ubuntu,同时保留权限和所有者? (uid和gid在两个linux下是一样的。)
复制到 windows 首先更改文件的权限和所有者。
explorer.exe
也更改权限和所有者。
最好,我还想避免创建共享磁盘映像文件,我可以依次从 Debian 和 Ubuntu 挂载该文件。
我想要更简单的东西,比如直接从第一个 WSL 实例访问第二个 WSL 实例,例如,
$ cp -a <Debian>/myfiles/ <Ubuntu>/myfiles
这可能吗?
使用tar。它将保留所有文件元数据。
在 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
另见我的类似问题: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
注意:似乎不支持符号链接。