systemd 挂载脚本问题

systemd 挂载脚本问题

我正在尝试使用 systemd 运行挂载脚本。它确实运行了,但挂载点没有出现 ( /with)。如果我/usr/local/sbin/utils-start.bash手动执行,它就可以正常工作。

/etc/systemd/system/test2d.service

[Unit]
Description=test2d

[Service]
User=root
Type=oneshot
#Start script
ExecStart=/usr/local/sbin/utils-start.bash
RemainAfterExit=yes
[Install]
WantedBy=multi-user.target

/usr/local/sbin/utils-start.bash

/bin/mount -v --make-rshared /
/bin/mount -v --bind /with /with
/bin/mount -v --make-rprivate /with
/bin/mount -v -t tmpfs with-global /with

journalctl -xe结果:

May 05 16:26:48 dev3 systemd[1]: test2d.service: Trying to enqueue job test2d.service/start/replace
May 05 16:26:48 dev3 systemd[1]: test2d.service: Installed new job test2d.service/start as 15762
May 05 16:26:48 dev3 systemd[1]: test2d.service: Enqueued job test2d.service/start as 15762
May 05 16:26:48 dev3 systemd[1]: Sent message type=method_return sender=n/a destination=n/a object=n/a interface=n/a member=n/a cookie=1 reply_cookie=1 error=n/a
May 05 16:26:48 dev3 systemd[1]: Sent message type=signal sender=n/a destination=n/a object=/org/freedesktop/systemd1 interface=org.freedesktop.systemd1.Manager member=JobNew cookie=2 reply_cookie=0 error=
May 05 16:26:48 dev3 systemd[1]: Sent message type=signal sender=n/a destination=n/a object=/org/freedesktop/systemd1 interface=org.freedesktop.systemd1.Manager member=JobNew cookie=868731 reply_cookie=0 e
May 05 16:26:48 dev3 systemd[1]: test2d.service: Job test2d.service/start finished, result=done
May 05 16:26:48 dev3 systemd[1]: Started Initializes the file system namespaces for /usr/bin/with.
-- Subject: Unit test2d.service has finished start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- 
-- Unit test2d.service has finished starting up.
-- 
-- The start-up result is done.

答案1

我找到了问题所在。我不得不跑

systemctl enable test2d

否则它就不起作用。

相关内容