ubuntu两台电脑之间硬盘远程挂载


主要参考这两篇博客
https://blog.csdn.net/ylxwk/article/details/129155931
https://www.shuzhiduo.com/A/kPzOEWN75x/

服务器电脑配置:

1. 安装nfs服务:sudo apt-get install nfs-kernel-server rpcbind

2. 查看nfs配置文件:sudo vi /etc/exports

# /etc/exports: the access control list for filesystems which may be exported
#               to NFS clients.  See exports(5).
#
# Example for NFSv2 and NFSv3:
# /srv/homes       hostname1(rw,sync,no_subtree_check) hostname2(ro,sync,no_subtree_check)
#
# Example for NFSv4:
# /srv/nfs4        gss/krb5i(rw,sync,fsid=0,crossmnt,no_subtree_check)
# /srv/nfs4/homes  gss/krb5i(rw,sync,no_subtree_check)
#

已经自动生成nfs配置文件了,只是里面内容全被注释了

3. 修改nfs配置文件:sudo vi /etc/exports

在最后一行添加:

# /etc/exports: the access control list for filesystems which may be exported
#               to NFS clients.  See exports(5).
#
# Example for NFSv2 and NFSv3:
# /srv/homes       hostname1(rw,sync,no_subtree_check) hostname2(ro,sync,no_subtree_check)
#
# Example for NFSv4:
# /srv/nfs4        gss/krb5i(rw,sync,fsid=0,crossmnt,no_subtree_check)
# /srv/nfs4/homes  gss/krb5i(rw,sync,no_subtree_check)
#

/mnt  *(insecure,rw,sync,no_root_squash,no_subtree_check)

4. 重启nfs服务器:sudo /etc/init.d/nfs-kernel-server restart

会显示:

algo@algo-NF512M5:/mnt$ sudo /etc/init.d/nfs-kernel-server restart
[ ok ] Restarting nfs-kernel-server (via systemctl): nfs-kernel-server.service.

5. 检查nfs服务器挂载目录:showmount -e

algo@algo-NF512M5:/mnt$ showmount -e
Export list for algo-NF5468M5:
/mnt *

服务器端配置结束

本地电脑配置:

1. 安装服务:sudo apt-get install nfs-common

2.挂载: sudo mount -t nfs 192.168.1.24:/mnt /media/algo/data_1/everyday/mount/8_gpu

其他

如果做了共享目录的window系统,ubuntu本地电脑需要挂载window命令

mount -t cifs //192.168.29.45/algo /media/algo/data_1/everyday/mount/45_algo -o noatime -o nodiratime -o username=yhl,password=123,rw,uid=0,gid=0,dir_mode=0777,file_mode=0777
posted @ 2023-03-30 13:32  无左无右  阅读(187)  评论(0编辑  收藏  举报