NFS 服务器守护程序在启动时无法启动

NFS 服务器守护程序在启动时无法启动

我正在尝试导出外部磁盘,因此,我将 nfs-server 服务配置为等待 disk1 挂载,但失败了。

这是开机之后的情况:

$ systemctl status nfs-server.service
● nfs-server.service - NFS server and services
   Loaded: loaded (/etc/systemd/system/nfs-server.service; enabled; vendor preset: enabled)
   Active: failed (Result: exit-code) since Sun 2020-04-26 14:46:28 CEST; 3min 7s ago
  Process: 307 ExecStartPre=/usr/sbin/exportfs -r (code=exited, status=1/FAILURE)
  Process: 312 ExecStopPost=/usr/sbin/exportfs -au (code=exited, status=0/SUCCESS)
  Process: 314 ExecStopPost=/usr/sbin/exportfs -f (code=exited, status=0/SUCCESS)

abr 26 14:46:28 raspberrypi systemd[1]: Starting NFS server and services...
abr 26 14:46:28 raspberrypi exportfs[307]: exportfs: Failed to stat /media/pi/disk1: No such file or directory
abr 26 14:46:28 raspberrypi systemd[1]: nfs-server.service: Control process exited, code=exited, status=1/FAILURE
abr 26 14:46:28 raspberrypi systemd[1]: nfs-server.service: Failed with result 'exit-code'.
abr 26 14:46:28 raspberrypi systemd[1]: Failed to start NFS server and services.

如果我重新启动服务它就能顺利运行

$ sudo systemctl restart nfs-server.service
$ systemctl status nfs-server.service
● nfs-server.service - NFS server and services
   Loaded: loaded (/etc/systemd/system/nfs-server.service; enabled; vendor preset: enabled)
   Active: active (exited) since Sun 2020-04-26 14:59:51 CEST; 4s ago
  Process: 943 ExecStartPre=/usr/sbin/exportfs -r (code=exited, status=0/SUCCESS)
  Process: 944 ExecStart=/usr/sbin/rpc.nfsd $RPCNFSDARGS (code=exited, status=0/SUCCESS)
 Main PID: 944 (code=exited, status=0/SUCCESS)

abr 26 14:59:51 raspberrypi systemd[1]: Starting NFS server and services...
abr 26 14:59:51 raspberrypi systemd[1]: Started NFS server and services.

我将服务配置为“需要”和“之后” disk1 挂载,但它不起作用:

# /etc/systemd/system/nfs-server.service
[Unit]
Description=NFS server and services
DefaultDependencies=no
Requires=network.target proc-fs-nfsd.mount media-pi-disk1.mount
Requires=nfs-mountd.service
Wants=rpcbind.socket
Wants=nfs-idmapd.service

After=local-fs.target media-pi-disk1.mount
After=network.target proc-fs-nfsd.mount rpcbind.socket nfs-mountd.service
After=nfs-idmapd.service rpc-statd.service
Before=rpc-statd-notify.service

要求提供额外信息:


$ systemctl status media-pi-disk1.mount
● media-pi-disk1.mount - /media/pi/disk1
   Loaded: loaded
   Active: active (mounted) since Sun 2020-04-26 14:47:34 CEST; 3h 22min ago
    Where: /media/pi/disk1
     What: /dev/sda1



 $ egrep -v '^#|^$' /etc/fstab
proc            /proc           proc    defaults          0       0
/dev/mmcblk0p8  /boot           vfat    defaults          0       2
/dev/mmcblk0p9  /  


 $ lsblk
NAME        MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sda           8:0    0 931,5G  0 disk
└─sda1        8:1    0 931,5G  0 part /media/pi/disk1
mmcblk0     179:0    0  29,7G  0 disk
├─mmcblk0p1 179:1    0   2,4G  0 part
├─mmcblk0p2 179:2    0     1K  0 part
├─mmcblk0p5 179:5    0    32M  0 part
├─mmcblk0p6 179:6    0   512M  0 part /media/pi/System
├─mmcblk0p7 179:7    0  12,1G  0 part /media/pi/Storage
├─mmcblk0p8 179:8    0   256M  0 part /boot
└─mmcblk0p9 179:9    0  14,5G  0 part /



$ mount
/dev/mmcblk0p9 on / type ext4 (rw,noatime)
devtmpfs on /dev type devtmpfs (rw,relatime,size=217076k,nr_inodes=54269,mode=755)
sysfs on /sys type sysfs (rw,nosuid,nodev,noexec,relatime)
proc on /proc type proc (rw,relatime)
tmpfs on /dev/shm type tmpfs (rw,nosuid,nodev)
devpts on /dev/pts type devpts (rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000)
tmpfs on /run type tmpfs (rw,nosuid,nodev,mode=755)
tmpfs on /run/lock type tmpfs (rw,nosuid,nodev,noexec,relatime,size=5120k)
tmpfs on /sys/fs/cgroup type tmpfs (ro,nosuid,nodev,noexec,mode=755)
cgroup2 on /sys/fs/cgroup/unified type cgroup2 (rw,nosuid,nodev,noexec,relatime,nsdelegate)
cgroup on /sys/fs/cgroup/systemd type cgroup (rw,nosuid,nodev,noexec,relatime,xattr,name=systemd)
bpf on /sys/fs/bpf type bpf (rw,nosuid,nodev,noexec,relatime,mode=700)
cgroup on /sys/fs/cgroup/memory type cgroup (rw,nosuid,nodev,noexec,relatime,memory)
cgroup on /sys/fs/cgroup/cpu,cpuacct type cgroup (rw,nosuid,nodev,noexec,relatime,cpu,cpuacct)
cgroup on /sys/fs/cgroup/freezer type cgroup (rw,nosuid,nodev,noexec,relatime,freezer)
cgroup on /sys/fs/cgroup/devices type cgroup (rw,nosuid,nodev,noexec,relatime,devices)
cgroup on /sys/fs/cgroup/blkio type cgroup (rw,nosuid,nodev,noexec,relatime,blkio)
cgroup on /sys/fs/cgroup/net_cls type cgroup (rw,nosuid,nodev,noexec,relatime,net_cls)
systemd-1 on /proc/sys/fs/binfmt_misc type autofs (rw,relatime,fd=28,pgrp=1,timeout=0,minproto=5,maxproto=5,direct)
debugfs on /sys/kernel/debug type debugfs (rw,relatime)
mqueue on /dev/mqueue type mqueue (rw,relatime)
sunrpc on /run/rpc_pipefs type rpc_pipefs (rw,relatime)
nfsd on /proc/fs/nfsd type nfsd (rw,relatime)
configfs on /sys/kernel/config type configfs (rw,relatime)
/dev/mmcblk0p8 on /boot type vfat (rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=ascii,shortname=mixed,errors=remount-ro)
tmpfs on /run/user/1000 type tmpfs (rw,nosuid,nodev,relatime,size=44280k,mode=700,uid=1000,gid=1000)
gvfsd-fuse on /run/user/1000/gvfs type fuse.gvfsd-fuse (rw,nosuid,nodev,relatime,user_id=1000,group_id=1000)
fusectl on /sys/fs/fuse/connections type fusectl (rw,relatime)
/dev/sda1 on /media/pi/disk1 type ext4 (rw,nosuid,nodev,relatime,uhelper=udisks2)
/dev/mmcblk0p7 on /media/pi/Storage type ext4 (rw,nosuid,nodev,relatime,uhelper=udisks2)
/dev/mmcblk0p6 on /media/pi/System type vfat (rw,nosuid,nodev,relatime,uid=1000,gid=1000,fmask=0022,dmask=0022,codepage=437,iocharset=ascii,shortname=mixed,showexec,utf8,flush,errors=remount-ro,uhelper=udisks2)


答案1

我让系统自动安装磁盘。我刚刚按照 Gerald 的问题配置了磁盘安装/etc/fstab,它就正常工作了!非常感谢你们。

答案2

我遇到了 nfs 服务器守护进程在启动过程中失败的错误问题。我不知道具体原因,但问题出在 LVM 上。在重启之前,我删除了我的 LV、VG 和 PV。我通过将它们添加到 来使挂载永久化。从我的问题/etc/fstab中删除我的 PV 引用后,问题解决了。/etc/fstab

相关内容