Red*_*dro 6 shutdown unmount google-drive systemd
我正在使用 登录时安装我的 Google Drive google-drive-ocamlfuse
。问题是现在关机或重启似乎多了 2 分钟的暂停。
现在,如果我在关闭之前卸载 Google Drive,一切都会按预期进行,不会有任何停顿。
我检查了一些systemd
服务并构建了一个新服务,但并不确切知道我在做什么(“有根据的猜测”)。
/etc/systemd/system/rs-shutdown.service
:
# Redsandro 2017-09-1
# Unmount GoogleDrive to prevent shutdown delay.
[Unit]
Description=Unmount GoogleDrive on shutdown
Before=umount.target shutdown.target reboot.target halt.target
[Service]
Type=oneshot
RemainAfterExit=true
ExecStart=/bin/true
ExecStop=/bin/sh -c "umount /home/redsandro/GoogleDrive"
[Install]
WantedBy=multi-user.target
Run Code Online (Sandbox Code Playgroud)
然后我跑了:
sudo systemctl enable rs-shutdown.service
sudo systemctl start rs-shutdown.service
Run Code Online (Sandbox Code Playgroud)
然而,关机仍然滞后了2分钟。如果我想快速关闭,我仍然需要手动卸载共享。
有没有解决方案,或者这只是尝试做我想做的事情的错误地方?
我正在运行 Linux Mint 17 和 Ubuntu 16.04.3。
下面是一个在关闭之前执行任务的简单服务的示例。请注意,默认依赖项已被该DefaultDependencies=no
选项禁用
[Unit]
Description=SleepBeforeShutdown Service
DefaultDependencies=no
Before=halt.target shutdown.target reboot.target
[Service]
Type=oneshot
ExecStart=/bin/sleep 30
RemainAfterExit=yes
[Install]
WantedBy=halt.target shutdown.target reboot.target
Run Code Online (Sandbox Code Playgroud)
创建/编辑服务单元文件后运行
systemctl enable yourservice.service
并重新启动。(不需要运行systemctl start yourservice.service
)。此后,任何时候您运行关闭、暂停或重新启动,type-oneshot 服务都会首先执行其操作,然后系统继续进行实际的关闭/重新启动。
编辑
我现在找到了以前的帖子,其中提供了相同的解决方案。我没有资格发表带有上述问题链接的评论,所以我将保留我的答案(尽管严格来说,它是重复的)版主,如果违反规则,请删除此帖子。
编辑 2
还有另一篇具有相同答案的旧帖子。确实没那么难找...
归档时间: |
|
查看次数: |
6527 次 |
最近记录: |