WSL2 Ubuntu 22.04无法挂载NFS共享的问题求助
WSL2 Ubuntu 22.04无法挂载NFS共享的问题求助
大家好,我最近碰到个棘手的问题:在WSL2运行的Ubuntu 22.04里尝试挂载NFS共享,这个操作在原生Ubuntu系统里完全正常,但在WSL2里就是行不通。
我先编辑了/etc/fstab,添加了以下配置:
172.16.0.113:/mnt/share/yocto-cache /home/tom/cache nfs auto,nofail,noatime,nolock,intr,tcp,actimeo=1800 0 0
接着执行挂载命令sudo mount -vvv /home/tom/cache,得到了一串报错信息:
mount.nfs: timeout set for Thu Mar 9 07:57:54 2023 mount.nfs: trying text-based options 'nolock,intr,tcp,actimeo=1800,vers=4.2,addr=172.16.0.113,clientaddr=172.23.196.48' mount.nfs: mount(2): Invalid argument mount.nfs: trying text-based options 'nolock,intr,tcp,actimeo=1800,vers=4,minorversion=1,addr=172.16.0.113,clientaddr=172.23.196.48' mount.nfs: mount(2): Operation not permitted mount.nfs: trying text-based options 'nolock,intr,tcp,actimeo=1800,addr=172.16.0.113' mount.nfs: prog 100003, trying vers=3, prot=6 mount.nfs: trying 172.16.0.113 prog 100003 vers 3 prot TCP port 2049 mount.nfs: prog 100005, trying vers=3, prot=6 mount.nfs: trying 172.16.0.113 prog 100005 vers 3 prot TCP port 56713 mount.nfs: mount(2): Permission denied mount.nfs: Operation not permitted
我之前试过一个针对WSL2网桥模式的解决方案(原本是用来解决NFS挂载权限拒绝问题的),修改了端口并添加了UDP支持,但还是没效果。下面是我使用的PowerShell脚本:
$remoteport = bash.exe -c "ifconfig eth0 | grep 'inet '" $found = $remoteport -match '\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}'; if( $found ){ $remoteport = $matches[0]; echo "IP address of WSL 2 = " $remoteport; } else{ echo "The Script exited, the IP address of WSL 2 cannot be found"; exit; } # [Ports] # All the ports you want to forward separated by comma $ports=@(111,2049); # [Static ip] # You can change the addr to your ip config to listen to a specific address $addr='0.0.0.0'; $ports_a = $ports -join ","; # Remove Firewall Exception Rules # iex "Remove-NetFireWallRule -DisplayName 'WSL 2 Firewall Unlock' "; iex "Remove-NetFireWallRule -DisplayName 'WSL 2 Firewall Unlock Outbound TCP' "; iex "Remove-NetFireWallRule -DisplayName 'WSL 2 Firewall Unlock Inbound TCP' "; iex "Remove-NetFireWallRule -DisplayName 'WSL 2 Firewall Unlock Outbound UDP' "; iex "Remove-NetFireWallRule -DisplayName 'WSL 2 Firewall Unlock Inbound UDP' "; # adding Exception Rules for inbound and outbound Rules iex "New-NetFireWallRule -DisplayName 'WSL 2 Firewall Unlock Outbound TCP' -Direction Outbound -LocalPort $ports_a -Action Allow -Protocol TCP"; iex "New-NetFireWallRule -DisplayName 'WSL 2 Firewall Unlock Inbound TCP' -Direction Inbound -LocalPort $ports_a -Action Allow -Protocol TCP"; iex "New-NetFireWallRule -DisplayName 'WSL 2 Firewall Unlock Outbound UDP' -Direction Outbound -LocalPort $ports_a -Action Allow -Protocol UDP"; iex "New-NetFireWallRule -DisplayName 'WSL 2 Firewall Unlock Inbound UDP' -Direction Inbound -LocalPort $ports_a -Action Allow -Protocol UDP"; for( $i = 0; $i -lt $ports.length; $i++ ){ $port = $ports[$i]; iex "netsh interface portproxy delete v4tov4 listenport=$port listenaddress=$addr"; iex "netsh interface portproxy add v4tov4 listenport=$port listenaddress=$addr connectport=$port connectaddress=$remoteport"; }
有没有大佬能帮忙分析下问题出在哪?或者有没有其他可行的解决思路?
备注:内容来源于stack exchange,提问作者parsley72
相关产品推荐
相关产品推荐

