在linux设备(IPC)上搭建nfs服务器

需要把IPC上的目录挂载给别的设备使用,因此就选择了在IPC上搭建nfs服务器
目前存在两种组合方式去构建nfs server

方案一:libcap、libtirpc、rpcbind、nfs-utils

目前此方案编译成功,环境还没搭成功。

libcap
参考:https://www.cnblogs.com/AaronD-Chain/p/6179505.html
需要在稍微修改下

libtirpc-1.2.6

./configure --disable-gssapi CC=arm-linux-gnueabihf-gcc --host=arm-linux --prefix=/home/crb/nfs/prefix
make
make install

rpcbind-1.2.5

./configure CC=arm-linux-gnueabihf-gcc TIRPC_CFLAGS="-I/home/crb/nfs/prefix/include/tirpc" TIRPC_LIBS="-L/home/crb/nfs/prefix/lib -ltirpc" --without-systemdsystemunitdir --host=arm-linux --prefix=/home/crb/nfs/prefix
make
make install

nfs-utils-2.5.1

./configure  CC=arm-linux-gnueabihf-gcc TIRPC_CFLAGS="-I/home/crb/nfs/prefix/include/tirpc" TIRPC_LIBS="-L/home/crb/nfs/prefix/lib -ltirpc" LDFLAGS="-L/home/crb/nfs/222/libcap-2.46/libcap" LIBCAP=-lcap --disable-nfsv4 --disable-nfsv41 --disable-gss --disable-uuid  --disable-ipv6 --with-tirpcinclude=/home/crb/nfs/prefix/include/tirpc --host=arm-linux --prefix=/home/crb/nfs/prefix
make
make install

方案二:libcap、portmap、nfs-utils

目前此方案挂载成功了。
libcap交叉编译和上面一样。

portmap

make CC=arm-linux-gnueabihf-gcc clean
make CC=arm-linux-gnueabihf-gcc

nfs-utils

./configure --prefix=$(pwd)/../output/v500 CC=arm-linux-gnueabihf-gcc LDFLAGS="-L/home/crb/nfs/222/libcap-2.46/libcap" LIBCAP=-lcap --disable-nfsv4 --disable-ipv6 --disable-gss --disable-uuid --disable-mount --without-tcp-wrappers --disable-tirpc --host=arm-linux
make
make install

环境配置:
1、把编译完生成的文件放到设备
/sbin/portmap
/usr/lib/libcap.so
/usr/sbin/exportfs rpc.mountd rpc.nfsd rpc.statd

2、 /etc/exports文件写入(要挂载到该设备的"/" 根目录)

/  *(rw,fsid=0,no_subtree_check)

3、/etc/services
增加

nfs 2049/tcp nfsd
nfs 2049/udp nfsd

运行
启动命令:

portmap
rpc.statd
mkdir /var/lock/subsys
touch /var/lock/subsys/nfslock
mkdir /var/lib/nfs/
exportfs -r
rpc.statd
rpc.nfsd 2
rpc.mountd
touch /var/lock/subsys/nfs

退出命令:

killall -q rpc.mountd
kill -9 'pidof nfsd' 2>/dev/null
exportfs -au
rm -f /var/lock/subsys/nfs
killall -q rpc.statd
rm -f /var/lock/subsys/nfslock
killall -q portmap

挂载(在别的机子上,对该设备进行挂载)

mount -t nfs -o nolock 192.168.8.xxx:/ /home/nfs

在这里插入图片描述

注意:
目前测试ext4格式的文件系统可以挂载

需要用到的相关库:
https://download.csdn.net/download/CSDN369369/89006234?spm=1001.2014.3001.5501

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值