Raspberry Pi 挂载

纵饮孤独 提交于 2019-12-05 18:53:17

参考


Configure NFS Server and NFS Client Raspberry Pi
http://www.htpcguides.com/configure-nfs-server-and-nfs-client-raspberry-pi/

How do I mount directories from other Linux/Unix/BSD servers? How do I mount an NFS share?
http://www.raspbian.org/RaspbianFAQ

mount.cifs — mount using the Common Internet File System (CIFS)
https://www.samba.org/samba/docs/man/manpages-3/mount.cifs.8.html

fstab
(https://wiki.archlinux.org/index.php/Fstab)

Raspberry Pi 配置 nfs server 和 nfs client (主要用于Linux不同系统之间相互挂载)


配置 NFS Server

安装 NFS server 组件

sudo apt-get install nfs-common nfs-server -y  

or

sudo apt-get install nfs-kernel-server  

    


Q:报错 守护进程没开启

pi@raspberrypi:/etc $ sudo service nfs-kernel-server status
● nfs-kernel-server.service - LSB: Kernel NFS server support
   Loaded: loaded (/etc/init.d/nfs-kernel-server)
   Active: active (exited) since 三 2016-12-07 15:52:01 HKT; 1h 2min ago

12月 07 15:52:01 raspberrypi nfs-kernel-server[2020]: Not starting NFS kernel daemon: no exports. ......g).
12月 07 15:52:01 raspberrypi systemd[1]: Started LSB: Kernel NFS server support.
12月 07 16:54:47 raspberrypi systemd[1]: Started LSB: Kernel NFS server support.
Hint: Some lines were ellipsized, use -l to show in full.

A: 开启守护进程

rpc.mountd

  


Q:守护进程已启动,查询挂载list是空

pi@raspberrypi:/etc $ sudo service nfs-kernel-server status
● nfs-kernel-server.service - LSB: Kernel NFS server support
   Loaded: loaded (/etc/init.d/nfs-kernel-server)
   Active: active (exited) since 三 2016-12-07 17:11:37 HKT; 7s ago
  Process: 2664 ExecStop=/etc/init.d/nfs-kernel-server stop (code=exited, status=0/SUCCESS)
  Process: 2675 ExecStart=/etc/init.d/nfs-kernel-server start (code=exited, status=0/SUCCESS)

12月 07 17:11:37 raspberrypi nfs-kernel-server[2675]: Exporting directories for NFS kernel daemon....
12月 07 17:11:37 raspberrypi nfs-kernel-server[2675]: Starting NFS kernel daemon: nfsd mountd.
12月 07 17:11:37 raspberrypi systemd[1]: Started LSB: Kernel NFS server support.
pi@raspberrypi:/etc $ showmount -a
All mount points on raspberrypi:
pi@raspberrypi:/etc $ showmount -e
Export list for raspberrypi:
pi@raspberrypi:/etc $ showmount -e localhost
Export list for localhost:

A:因为设置允许客户端所有主机:*

#/home/pi/nfs_ 192.168.0.*/24(rw,sync,no_subtree_check)
/home/pi/nfs_ *(rw,sync,no_subtree_check)


pi 通过 cifs 挂载到 Windows共享文件 (用于Windows和Linux之间)

临时挂载

sudo mount -t cifs -o username=win用户名,passwd=win用户密码  //192.168.0.101/share /home/pi/share

开机自动挂载

配置 /etc/fstab,参数详情见参考

//192.168.1.11/share /home/pi/share cifs defaults,username=win用户名,password=win用户密码,uid=pi,gid=pi 0 2

uid gid 可以在 /etc/passwd 中查询,也可以设置为默认 uid=0,uig=0

pi@raspberrypi:/etc $ vim passwd
pi:x:1000:1000:,,,:/home/pi:/bin/bash

实际试的时候,发现开机并没有自动挂载,添加auto也无效,后续再了解Linux开机启动的内容,现在先执行mount 挂载命令

sudo mount -a  (挂载fstab中内容)
sudo mount -s  (查询挂载状态)
//192.168.1.11/share on /home/pi/share type cifs (rw,relatime,vers=1.0,cache=strict,username=jr413,domain=ZEUS,uid=1000,forceuid,gid=1000,forcegid,addr=192.168.1.11,file_mode=0755,dir_mode=0755,nounix,serverino,mapposix,rsize=61440,wsize=65536,actimeo=1)  

sudo mount /home/pi/share(解除挂载点)

需要注意的是不要在挂载的当前目录,执行mount -a。否则挂载成功后,执行ls后,没有返回,需退出cd ..上一级目录,再次进入当前挂载目录,再次执行ls,才会显示当前挂载目录下的共享文件

pi@raspberrypi:~/share $ ls   (当前目录执行 mount -a)
无

pi@raspberrypi:~/share $ ls  (非当前目录执行 mount -a)
desktop.ini  hello.py

注:

如有错误,请指正和拍砖,妹子可前来撩!

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!