Che*_*Cat 4 boot debian nfs autofs systemd
在我的 Raspbian(基于 Debian Jessie)上,我需要在启动rpcbind和nfs-common服务时启动,因为我需要它们在启动autofs时启动以进行 NFS 安装。
由于 Debian Jessie 现在已转移到systemd,我想知道以正确的顺序启动这 3 个服务(rpcbind、nfs-commond、autofs)以避免出现问题的最佳方法。
如果我手动挂载 NFS 共享,它就可以工作。它也适用于在 rpcbind 和 nfs-common 已经启动并运行的情况下使用 autofs 服务。
autofs 使用 systemd 单元脚本。关于其他 2 个服务,我应该制作 init.d 脚本还是必须创建 systemd 单元文件?我该怎么写?
问题的原因是缺少systemd配置文件。基于马特格兰特关于debian-devel这些是你需要执行的步骤的帖子。
/etc/systemd/system/nfs-common.servicecat >/etc/systemd/system/nfs-common.service <<\EOF
[Unit]
Description=NFS Common daemons
Wants=remote-fs-pre.target
DefaultDependencies=no
[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/etc/init.d/nfs-common start
ExecStop=/etc/init.d/nfs-common stop
[Install]
WantedBy=sysinit.target
EOF
Run Code Online (Sandbox Code Playgroud)
/etc/systemd/system/rpcbind.servicecat >/etc/systemd/system/rpcbind.service <<\EOF
[Unit]
Description=RPC bind portmap service
After=systemd-tmpfiles-setup.service
Wants=remote-fs-pre.target
Before=remote-fs-pre.target
DefaultDependencies=no
[Service]
ExecStart=/sbin/rpcbind -f -w
KillMode=process
Restart=on-failure
[Install]
WantedBy=sysinit.target
Alias=portmap
EOF
Run Code Online (Sandbox Code Playgroud)
/etc/tmpfiles.d/rpcbind.confcat >/etc/tmpfiles.d/rpcbind.conf <<\EOF
#Type Path Mode UID GID Age Argument
d /run/rpcbind 0755 root root - -
f /run/rpcbind/rpcbind.xdr 0600 root root - -
f /run/rpcbind/portmap.xdr 0600 root root - -
EOF
Run Code Online (Sandbox Code Playgroud)
systemctl enable rpcbind.service
systemctl enable nfs-common
Run Code Online (Sandbox Code Playgroud)