文章目录

  • 什么是NFS挂载目录?
  • 第一次尝试(失败)
  • 第二次尝试(成功)
  • - (ubuntu上安装NFS,Ubuntn上默认没有安装)
  • - (给ubuntu上需要被共享的文件夹赋予权限,保证使用者都能够读、写、执行)
  • - (修改NFS配置文件)/etc/exports
  • - (重启portmapper(端口映射)服务)service portmap restart
  • - (重启NFS服务)service nfs-kernel-server restart
  • - (测试Ubuntu nfs)showmount -e
  • - (本机挂载)略
  • - (开发板挂载,重新执行:`mount -t nfs -o nolock 192.168.1.123:/root/heop_devel_kit/volume /userdata`)
  • - (如何查看客户机所有挂载目录?)cat /proc/mounts 或者 df -h
  • - (如何取消挂载)umount
  • 如何在板子上使用挂载目录直接运行海康hikflow_demo?
  • config_yolov3_tiny_pytorch.txt 内容改成相对路径
  • 20220323 这边发现mount一个有文件的目录是会临时把东西干掉的,umount后又恢复了
  • 20220323 而且如果当前pwd是在mount目录下,是没法umount的,会提示:`Device or resource busy`,需要切换到目录外才行


什么是NFS挂载目录?

第一次尝试(失败)

nfs挂载用户nobody nfs挂载 connection refused_开发板


nfs挂载用户nobody nfs挂载 connection refused_ubuntu_02

如下,在海康摄像机里挂载ubuntu目录时报错:

# pwd
/
# mkdir userdata
# 
# ls
bin       dev       init      mnt       root      sys       usr
config    etc       lib       model     run       syslog    var
dav       heop      lib32     opt       runit     tmp
davinci   home      linuxrc   proc      sbin      userdata
#
# mount -t nfs -o nolock 192.168.1.123:/root/heop_devel_kit/volume /userdata/
mount: RPC: Remote system error - Connection refused
mount: mounting 192.168.1.123:/root/heop_devel_kit/volume on /userdata/ failed: Bad file descriptor

没解决。。。

我用另一台ubuntu虚拟机去挂载第一台虚拟机,也不行。。

第二次尝试(成功)

后来百度查,发现可能是ubuntu上需要安装nfs-kernel-server服务才行,试试:

- (ubuntu上安装NFS,Ubuntn上默认没有安装)

apt update
apt install nfs-kernel-server

- (给ubuntu上需要被共享的文件夹赋予权限,保证使用者都能够读、写、执行)

[root@ubuntu ~/heop_devel_kit]33# ls
volume
[root@ubuntu ~/heop_devel_kit]34# 
[root@ubuntu ~/heop_devel_kit]34# chmod 777 volume/ -R

重新执行mount -t nfs -o nolock 192.168.1.123:/root/heop_devel_kit/volume /userdata/,又报错了,这次是Permission denied

# mount -t nfs -o nolock 192.168.1.123:/root/heop_devel_kit/volume /userdata/
mount: 192.168.1.123:/root/heop_devel_kit/volume failed, reason given by server: Permission denied
mount: mounting 192.168.1.123:/root/heop_devel_kit/volume on /userdata/ failed: Bad file descriptor

- (修改NFS配置文件)/etc/exports

在ubuntu里,打开/etc/exports文件(先备份)

cp /etc/exports /etc/exports.bak
gedit /etc/exports

在最后加上:(其中前面的是要被挂载的路径,后面的是被允许挂载的ip主机)

/root/heop_devel_kit/volume 192.168.1.*(rw,sync,no_root_squash,no_subtree_check)

nfs挂载用户nobody nfs挂载 connection refused_nfs挂载用户nobody_03

/home/nfst_shared  ---要共享的目录
192.168.0.*---允许访问的网段,也可以是ip地址、主机名(能够被服务器解析)、
	*(所有人都能访问)

(rw,sync,no_root_squash,no_subtree_check)---
	rw:读/写权限
	sync:数据同步写入内存和硬盘
	no_root_squash:服务器允许远程系统以root特权存取该目录
	no_subtree_check:关闭子树检查

其他选项可以通过man exports查阅man文档

- (重启portmapper(端口映射)服务)service portmap restart

service portmap restart

- (重启NFS服务)service nfs-kernel-server restart

service nfs-kernel-server restart

- (测试Ubuntu nfs)showmount -e

showmount -e

结果:

[root@ubuntu ~/heop_devel_kit]45# showmount -e
Export list for ubuntu:
/root/heop_devel_kit/volume 192.168.1.*

- (本机挂载)略

# ls /home/nfst_shared/   #被挂载的文件夹下面的东西
cross-3.4.1.tar.bz2  linux-2.6.12        upload
download             msap                VMwareTools-8.1.3-203739.tar.gz
DSDT_2[1].8b.zip     ntp                 vmware-tools-distrib
DSDT_2.8b            protocol-converter  安装包


# mkdir /mnt/nfs_test
# ls /mnt/nfs_test/   #空白的
# sudo mount -t nfs -o nolock localhost:/home/nfs_shared  /mnt/nfs_test/
# ls /mnt/nfs_test/    #看到了和/home/nfst_shared/目录下的文件一样,说明挂载成功
cross-3.4.1.tar.bz2  linux-2.6.12        upload
download             msap                VMwareTools-8.1.3-203739.tar.gz
DSDT_2[1].8b.zip     ntp                 vmware-tools-distrib
DSDT_2.8b            protocol-converter  安装包

# sudo umount /mnt/nfs_test  #解除
# ls /mnt/nfs_test/   #空白的

- (开发板挂载,重新执行:mount -t nfs -o nolock 192.168.1.123:/root/heop_devel_kit/volume /userdata

mount -t nfs -o nolock 192.168.1.123:/root/heop_devel_kit/volume /userdata

成功了:

# mount -t nfs -o nolock 192.168.1.123:/root/heop_devel_kit/volume /userdata
# ls /userdata/
20220304_hikflow_yolov5         RTSP_DEMO_1.1.1_H7.app
HEOPEXTERNDEMOAPP_1.1.1_H7.app  arnold_test
HEOPTESTDEMOAPP_2.3.0_H7.app    hik2.3-ipc_h7_5.6.100
Model_P_H7_NPU0.bin             hikflow_arnold_20220302
#

但是这样路径太短,用起来不方便,建议:

mount -t nfs -o nolock 192.168.1.123:/root/heop_devel_kit/volume/20220304_hikflow_yolov5/hikflow/APP_2.3.0_pytorch_yolo /userdata

- (如何查看客户机所有挂载目录?)cat /proc/mounts 或者 df -h

cat /proc/mounts

结果:

# cat /proc/mounts
rootfs / rootfs rw,size=218032k,nr_inodes=54508 0 0
proc /proc proc rw,relatime 0 0
sysfs /sys sysfs rw,relatime 0 0
ramfs /home ramfs rw,relatime 0 0
udev /dev tmpfs rw,relatime 0 0
devpts /dev/pts devpts rw,relatime,mode=600,ptmxmode=000 0 0
/dev/part/app0blk /dav ext4 rw,relatime,data=ordered 0 0
/dev/part/cfg0blk /davinci ext4 rw,relatime,data=ordered 0 0
/dev/part/cfg1blk /config ext4 rw,relatime,data=ordered 0 0
/dev/part/model /model ext4 rw,relatime,data=ordered 0 0
/dev/part/syslog /syslog ext4 rw,relatime,data=ordered 0 0
none /proc/bus/usb usbfs rw,relatime 0 0
cgroup /sys/fs/cgroup cgroup rw,relatime,cpuset,cpu,memory,devices 0 0
tmpfs /run/lxcfs/controllers tmpfs rw,relatime,size=100k,mode=700 0 0
cpuset,cpu,memory,devices /run/lxcfs/controllers/cpuset,cpu,memory,devices cgroup rw,relatime,cpuset,cpu,memory,devices 0 0
lxcfs /var/lib/lxcfs fuse.lxcfs rw,nosuid,nodev,relatime,user_id=0,group_id=0,allow_other 0 0
/dev/part/model /heop ext4 rw,relatime,data=ordered 0 0
/dev/part/syslog /mnt/emmc_syslog ext4 rw,relatime,data=ordered 0 0
/dev/part/store /mnt/nfs0 ext4 rw,relatime,data=ordered 0 0
none /dev/mqueue mqueue rw,relatime 0 0
192.168.1.123:/root/heop_devel_kit/volume /userdata nfs rw,relatime,vers=3,rsize=1048576,wsize=1048576,namlen=255,hard,nolock,proto=tcp,port=2049,timeo=70,retrans=3,sec=sys,local_lock=all,addr=192.168.1.123 0 0
#

或者df -h

# df -h
Filesystem                Size      Used Available Use% Mounted on
rootfs                  212.9M     20.2M    192.7M   9% /
udev                    216.9M    228.0K    216.7M   0% /dev
/dev/part/app0blk       487.9M     51.7M    400.4M  11% /dav
/dev/part/cfg0blk        14.5M      1.4M     12.0M  10% /davinci
/dev/part/cfg1blk        14.5M      1.3M     12.0M  10% /config
/dev/part/model           1.4G     41.1M      1.3G   3% /model
/dev/part/syslog        120.0M      1.5M    109.5M   1% /syslog
tmpfs                   100.0K         0    100.0K   0% /run/lxcfs/controllers
/dev/part/model           1.4G     41.1M      1.3G   3% /heop
/dev/part/syslog        120.0M      1.5M    109.5M   1% /mnt/emmc_syslog
/dev/part/store           3.7G     15.3M      3.5G   0% /mnt/nfs0
192.168.1.123:/root/heop_devel_kit/volume
                        582.6G    343.1G    214.9G  61% /userdata
#

- (如何取消挂载)umount

umount [本机挂载路径]
# umount /userdata/
# 
# 
# ls /userdata/
#

如何在板子上使用挂载目录直接运行海康hikflow_demo?

# ls
2560
2571
2584
2607
2630
HEOPTESTDEMOAPP_2.3.0_H7.app
Model_P_H7_NPU0.bin
YOLOV3_P_G5_NPU0.bin
YOLOV3_P_H7_NPU0.bin
app
config_yolov3_tiny_pytorch - ??????.txt
config_yolov3_tiny_pytorch.txt
data
hikflow_demo_h7
html
mediaDrvDbg
opdevsdk_demo.sh
package.conf
packapp
#

config_yolov3_tiny_pytorch.txt 内容改成相对路径

# cat config_yolov3_tiny_pytorch.txt 
hikflow_model_path= ./Model_P_H7_NPU0.bin
test_image_list=./imagelist_yolov3_tiny_pytorch.txt
result_path=./yolo_pytorch_output.float#

然后在/userdata路径下运行:

./hikflow_demo_h7 ./config_yolov3_tiny_pytorch.txt YUV

即可测试

(注意编译可执行文件还得到ubuntu虚拟机上)

20220323 这边发现mount一个有文件的目录是会临时把东西干掉的,umount后又恢复了

nfs挂载用户nobody nfs挂载 connection refused_mount_04

20220323 而且如果当前pwd是在mount目录下,是没法umount的,会提示:Device or resource busy,需要切换到目录外才行

nfs挂载用户nobody nfs挂载 connection refused_重启_05