一个启动作业正在运行,用于/etc/rc.local兼容性。如何修复?

我今天刚升级到Ubuntu Vivid(15.04),重启后我遇到了非常长的引导过程。我的笔记本通常在5秒钟或更短的时间内启动,而现在即使几分钟过去了仍未完成。
按下Esc键显示以下屏幕:

enter image description here

最后一行说“正在运行一个起始作业,用于 /etc/rc.local 的兼容性(7 分 24 秒 / 无限制)”。尽管有“无限制”的部分,但它在精确的10分钟后放弃了(或者完成了?),启动过程结束。
每次启动都会发生这种情况。
这可能与转换为systemd有关吗?我该如何修复这个问题?(现在,在关闭我的笔记本之前,我会三思)。我应该报告一个错误吗?如果是这样,应该向哪里报告?
我的 /etc/rc.local 文件:
#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.
fstrim -v /
fstrim -v /home
exit 0

文件是可执行的。
$ ls -l /etc/rc.local
-rwxr-xr-x 1 root root 333 aug 14  2013 /etc/rc.local

我大约两年前添加了这两行fstrim命令,当时我安装了SSD,并按照Easy Linux tips project的指示进行操作。
显然,这些命令是问题的原因(我删除它们并重新启动后,问题消失了),但我仍然认为系统不应该在10分钟内卡住。另外,现在我该如何在启动时运行fstrim命令呢?
3个回答

如果你把长时间运行的命令放在 rc.local 中,你的启动会被延迟。你应该将它们发送到后台:

( fstrim -v /; fstrim -v /home ) &

说实话,你可能不需要自己做这个。Ubuntu 14.10 添加了一个每周任务来执行 fstrim

奇怪的是,在Ubuntu 15.04中突然出现了这个问题,而在Ubuntu 14.04中一直运行良好。
您还可以在修剪之前添加一个延迟参数,以便两个修剪命令在设置的秒数后执行。这样应该能够完成引导过程,使修剪命令在后台运行。
像这样(延迟40秒):
#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.
sleep 40
fstrim /
fstrim /home
exit 0

-v(详细)参数对于trim在这种情况下没有用处,顺便说一句,因为它是在后台运行的。我也在我的Easylinuxtips教程中进行了更改。
注意:我只在Ubuntu 14.04和Linux Mint 17.x中测试过rc.local中的睡眠参数(与trim不同的目的),所以我不确定在Ubuntu 15.04中是否会有类似的效果。

我遇到了同样的问题,基本上这是因为rc.local中的某个命令没有正常终止,比如某种守护进程。 要找出rc.local中的哪个命令是罪魁祸首,只需执行killall -9命令或从/etc.local中执行它,一旦rc.local中的所有命令都终止,系统将重新启动。