解决升级ubuntu
之后nfs
挂载失败问题
现象
ubunut
升级到18.04
,挂载nfs
出现如下错误
[ 99.683346] VFS: Unable to mount root fs via NFS, trying floppy.
[ 99.689905] VFS: Cannot open root device "nfs" or unknown-block(2,0): error -6
[ 99.697189] Please append a correct "root=" boot option; here are the available partitions:
检查 NFS 状态
$ sudo service nfs-kernel-server status
● nfs-server.service - NFS server and services
Loaded: loaded (/lib/systemd/system/nfs-server.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Sun 2019-05-05 13:30:40 CST; 26s ago
Process: 12103 ExecStopPost=/usr/sbin/exportfs -f (code=exited, status=0/SUCCESS)
Process: 12102 ExecStopPost=/usr/sbin/exportfs -au (code=exited, status=0/SUCCESS)
Process: 12091 ExecStop=/usr/sbin/rpc.nfsd 0 (code=exited, status=0/SUCCESS)
Process: 11366 ExecStart=/usr/sbin/rpc.nfsd $RPCNFSDARGS (code=exited, status=0/SUCCESS)
Process: 12101 ExecStartPre=/usr/sbin/exportfs -r (code=exited, status=1/FAILURE)
Main PID: 11366 (code=exited, status=0/SUCCESS)
5 月 05 13:30:40 host-ThinkPad-T440 systemd[1]: Starting NFS server and services...
5 月 05 13:30:40 host-ThinkPad-T440 exportfs[12101]: exportfs: Failed to stat /home/host/workspace/debug/git/output: No such file or directory
5 月 05 13:30:40 host-ThinkPad-T440 systemd[1]: nfs-server.service: Control process exited, code=exited status=1
5 月 05 13:30:40 host-ThinkPad-T440 systemd[1]: Stopped NFS server and services.
5 月 05 13:30:40 host-ThinkPad-T440 systemd[1]: nfs-server.service: Unit entered failed state.
5 月 05 13:30:40 host-ThinkPad-T440 systemd[1]: nfs-server.service: Failed with result 'exit-code'.
修改 NFS 配置文件 exports
$ cat /etc/exports
# /etc/exports: the access control list for filesystems which may be exported
# to NFS clients. See exports(5).
#
# Example for NFSv2 and NFSv3:
# /srv/homes hostname1(rw,sync,no_subtree_check) hostname2(ro,sync,no_subtree_check)
#
# Example for NFSv4:
# /srv/nfs4 gss/krb5i(rw,sync,fsid=0,crossmnt,no_subtree_check)
# /srv/nfs4/homes gss/krb5i(rw,sync,no_subtree_check)
#
/opt *(rw,no_root_squash,no_subtree_check)
可以看到参数发生变化,修改为(rw,sync,no_subtree_check,no_root_squash)
,然后重启NFS
重启 NFS
$ sudo service nfs-kernel-server restart
$ sudo service nfs-kernel-server status
● nfs-server.service - NFS server and services
Loaded: loaded (/lib/systemd/system/nfs-server.service; enabled; vendor preset: enabled)
Active: active (exited) since Sun 2019-05-05 13:36:47 CST; 5s ago
Process: 12103 ExecStopPost=/usr/sbin/exportfs -f (code=exited, status=0/SUCCESS)
Process: 12102 ExecStopPost=/usr/sbin/exportfs -au (code=exited, status=0/SUCCESS)
Process: 12091 ExecStop=/usr/sbin/rpc.nfsd 0 (code=exited, status=0/SUCCESS)
Process: 13155 ExecStart=/usr/sbin/rpc.nfsd $RPCNFSDARGS (code=exited, status=0/SUCCESS)
Process: 13154 ExecStartPre=/usr/sbin/exportfs -r (code=exited, status=0/SUCCESS)
Main PID: 13155 (code=exited, status=0/SUCCESS)
5 月 05 13:36:47 host-ThinkPad-T440 systemd[1]: Starting NFS server and services...
5 月 05 13:36:48 host-ThinkPad-T440 systemd[1]: Started NFS server and services.
解决问题