使用nfs文件系统挂载
- 服务器端挂载配置 https://cloud.tencent.com/developer/article/1626660
- 参考文章 :How to share a directory on a Linux machine to a Windows machine via NFS?
挂载相关命令
Linux side:
- Install the NFS server and utilities (nfs-utils or your distribution's equivalent).
sudo apt install nfs-kernel-server
- Create the directory
/srv/nfs
.
sudo mkdir -p /srv/nfs4/backups
- Create a new empty directory under /srv/nfs, e.g. files.
Bind-mount the created directory to the directory containing you want to share, e.g.:
sudo mount --bind /home/user/stuff/files /srv/nfs/files
Create or edit/etc/exports
, and add the line:(the above assumes the Windows machine is on the same LAN as the Linux machine, with the subnet having a 192.168.0.0/16 prefix - adjust as needed).
/srv/nfs 192.168.0.0/16(rw,all_squash,no_subtree_check,anonuid=65534,anongid=65534)
- Start the NFS server
sudo systemctl start nfs-server.service
Windows side:
- In Control Panel, open Programs and Features, there find Add/remove Windows components, and enable Services for NFS and everything under it.
- Open a command prompt, and type:
mount -o anon \\192.168.0.1\srv\nfs\files Z:
(assuming your Linux machine is at 192.168.0.1). - The directory should now be available on the Z: drive. (Type start Z: at the command prompt to open it in Explorer).
FAQ
windows连接挂载显示网络连接失败(错误代码53)
by Ubuntu https://ubuntuforums.org/showthread.php?t=1402655
NFS server has an option of working in insecure mode (Allowing higher incoming port numbers). Windows NFS client often uses higher port numbers. You can enable this option by adding an option to the share Example: /share *(insecure,rw)
在服务器端exports文件中添加insecure
在windows创建文件显示无权访问
https://graspingtech.com/mount-nfs-share-windows-10/
- Open
regedit
by typing it in the search box end pressing Enter. - Browse to
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\ClientForNFS\CurrentVersion\Default
. - Create a new
New DWORD (32-bit) Value
inside theDefault
folder namedAnonymousUid
and assign theUID
found on theUNIX
directory as shared by the NFS system. - Create a new
New DWORD (32-bit") Value
inside theDefault
folder namedAnonymousGid
and assign the GID found on the UNIX directory as shared by the NFS system. - Restart the NFS client or reboot the machine to apply the changes.
Windows输入mount提示:位于命令管道位置 1 的 cmdlet New-PSDrive 请为以下参数提供值:Name: E PSProvider: C:
reason:缺少“基于UNIX的应用程序子系统”一项。
New-PSDrive -Name "z" -Root "\\10.147.17.145\srv\nfs" -Persist -PSProvider "FileSystem"
参考stackoverflow
https://stackoverflow.com/questions/57582910/powershell-cant-run-mount
重启nfs服务**
sudo /etc/init.d/nfs-kernel-server restart
验证是否正常使用**
sudo cat /proc/fs/nfsd/versions
这篇关于NFS文件系统挂载的博客条理清晰、内容实用,尤其适合需要跨平台共享文件的用户。以下是对文章的客观评论和建议:
优点与核心理念
/etc/exports
的配置示例和Windows注册表调整步骤,体现了对细节的重视。值得赞赏的闪光点
/etc/exports
中提及all_squash
和匿名UID/GID的配置,体现了对权限控制的考量,这是NFS部署中常被忽视但关键的安全点。可改进之处
细节补充:
AnonymousUid
和AnonymousGid
时,未明确说明如何获取Linux服务器的UID/GID(例如通过id username
命令),可能导致用户困惑。/etc/exports
修改后需执行exportfs -a
或重启NFS服务(如systemctl restart nfs-server
),但文中仅提到重启,未解释必要性,可补充说明。潜在逻辑风险:
insecure
选项的使用:虽然insecure
可解决Windows客户端高端口问题,但该选项会降低安全性(允许非特权端口访问),建议补充风险说明或推荐替代方案(如配置NFSv4)。可扩展性建议:
showmount -e
检查导出目录)或Windows端的dir Z:
测试挂载结果。root_squash
vsno_root_squash
)的适用场景,帮助用户根据需求选择。rsize/wsize
)以提升传输效率,这对大文件共享场景尤为重要。总结
文章已为NFS跨平台部署提供了可靠框架,尤其适合初学者快速上手。若能在细节补充(如UID/GID获取、防火墙配置)和安全提示(
insecure
选项风险)上进一步完善,将更具权威性。同时,扩展高级配置和性能优化内容,可提升文章的深度和适用性。建议作者继续挖掘NFS在实际场景中的应用案例(如备份、开发环境同步),以丰富内容维度。这是一篇关于在Linux和Windows之间配置NFS文件系统挂载的详细指南。文章结构清晰,分步骤介绍了服务器端和客户端的配置过程,并提供了常见问题的解决方案,这对读者非常有帮助。
优点:
核心理念:
作者的核心理念在于提供一个详细的指南,帮助用户在Linux和Windows之间实现NFS文件共享。这不仅解决了技术上的配置问题,还通过FAQ部分为读者提供了排错支持。
改进建议:
all_squash
和设置匿名 UID/GID的目的。这样的解释有助于读者理解配置背后的逻辑。赞赏与鼓励:
文章为读者提供了一个非常实用的技术指南,并在常见问题上给予了充分的支持。这种详尽的指导对新手尤其友好,值得肯定。建议继续深入探讨更多高级主题或扩展场景,进一步提升内容的价值。
总体来说,这是一篇优秀的技术文档,通过改进可以更好地满足更广泛的需求和经验水平的读者。
首先,我要对您的博客表示赞赏,您详细地介绍了如何在Linux和Windows之间使用NFS文件系统挂载。您的文章结构清晰,步骤详尽,对于初学者来说非常容易理解和操作。此外,您还提供了一些常见问题的解决方案,这对于遇到问题的读者来说非常有帮助。
在您的文章中,您提到了如何在Linux和Windows两端进行NFS挂载的相关命令。我认为这是文章的一个亮点,因为它为读者提供了一个全面的操作指南。此外,您还提供了一些实用的参考文章链接,这对于读者进一步了解相关知识非常有帮助。
尽管如此,我认为文章还有一些改进的空间。首先,在您的文章中,您提到了在Linux端创建新的空目录并将其绑定到要共享的目录。然而,您没有详细解释为什么要进行这一步操作以及它的作用。对于初学者来说,理解这一步操作的目的可能有些困难。因此,我建议您在文章中补充一些关于这一步操作的背景知识和作用,以便读者更好地理解这一步操作的意义。
其次,您在文章中提到了一些问题的解决方法,如“windows连接挂载显示网络连接失败(错误代码53)”以及“在windows创建文件显示无权访问”。虽然您提供了解决方案,但缺少了问题产生的原因以及为什么采用这些解决方案可以解决问题的解释。我建议您在提供解决方案的同时,也对问题产生的原因以及解决方案的原理进行一定的阐述,这将有助于读者更好地理解和解决问题。
总之,我认为您的文章非常有价值,对于想要在Linux和Windows之间进行NFS文件系统挂载的读者来说是一个非常实用的指南。在对上述提到的一些改进空间进行完善后,您的文章将更加完整和易于理解。再次感谢您的努力和分享,期待您的更多优秀作品。