Debian Jessie 在引导时使用 systemd 启动 rpcbind 和 nfs-common

Che*_*Cat 4 boot debian nfs autofs systemd

在我的 Raspbian(基于 Debian Jessie)上,我需要在启动rpcbindnfs-common服务时启动,因为我需要它们在启动autofs时启动以进行 NFS 安装。

由于 Debian Jessie 现在已转移到systemd,我想知道以正确的顺序启动这 3 个服务(rpcbind、nfs-commond、autofs)以避免出现问题的最佳方法。

如果我手动挂载 NFS 共享,它就可以工作。它也适用于在 rpcbind 和 nfs-common 已经启动并运行的情况下使用 autofs 服务。

autofs 使用 systemd 单元脚本。关于其他 2 个服务,我应该制作 init.d 脚本还是必须创建 systemd 单元文件?我该怎么写?

Dio*_*lis 5

问题的原因是缺少systemd配置文件。基于马特格兰特关于debian-devel这些是你需要执行的步骤的帖子

1.创建 /etc/systemd/system/nfs-common.service

cat >/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)

2.创建 /etc/systemd/system/rpcbind.service

cat >/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)

3.创建 /etc/tmpfiles.d/rpcbind.conf

cat >/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)

4. 配置服务在启动时运行

systemctl enable rpcbind.service
systemctl enable nfs-common
Run Code Online (Sandbox Code Playgroud)