Ubuntu20.04 搭建nfs 运行代码

开发板通过网线与路由器连接,电脑端连接同意路由器WiFi,确保在同一局域网。

1 Ubuntu终端

1.1 安装nfs-kernel-server

sudo apt install nfs-kernel-server

1.2 创建mount文件夹,xxx:用户名,nfs_server:共享文件夹

mkdir /home/xxx/nfs_server

1.3 修改etc文件夹下的exports文件,在etc文件夹进入终端

sudo gedit exports

在exports文件中添加

/home/xxx/nfs_server *(rw,sync,no_subtree_check,no_root_squash)

1.4 重启nfs服务

/etc/init.d/rpcbind restart 
/etc/init.d/nfs-kernel-server restart

2 开发板端

2.1 通过xshell连接开发板

2.2 进入开发板后,在/mnt/建立挂载点mount point

mkdir /mnt/nfs

2.3 挂载nfs,网址为Ubuntu服务器网址(Ubuntu终端输入ifconfig查询)

mount -t nfs -o nolock -o tcp 192.168.0.119:/home/xxx/nfs_server  /mnt/nfs

3 helloword验证

3.1 Ubuntu:在nfs_server文件夹进入终端创建hello.c

sudo touch hello.c

3.2 Ubuntu:编辑hello.c

sudo gedit hello.c

 在hello.c中添加以下代码

#include <stdio.h>
void main(void)
{
printf("HELLO WORLD!");
}

3.3 Ubuntu:在nfs_server文件夹进入终端运行hello.c

 aarch64-linux-gnu-gcc hello.c -o helloword

3.4 开发板:进入/mnt/nfs,输入

ls -l

可以看见hellword文件

3.5 开发板:运行hellword文件

./helloword

4 Ubuntu关闭防火墙

 停止防火墙服务

sudo systemctl stop ufw.service

 禁用防火墙服务

sudo systemctl disable ufw.service

确认防火墙服务已关闭

sudo ufw status

  • 2
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值