Ubuntu – “A start job is running for /etc/rc.local Compatibility”: how to fix

15.04bootinit.dsystemd

I just upgraded to Ubuntu Vivid (15.04) today, and after the restart I experienced a very long boot process. My laptop usually boots in 5 seconds or less, and now it hadn't finished even after a few minutes.

Pressing Esc showed the following screen:

enter image description here

The last line says "A start job is running for /etc/rc.local Compatibility (7 min 24s / no limit)".
Despite the "no limit" part, it gave up (or completed ?) after exactly 10 minutes, and the boot process finished.

This happens on every boot.

Could it be related to the transition to systemd? How can I fix this? (Right now, I think twice before shutting down my laptop). Should I report a bug? And if so, where?

My /etc/rc.local file:

#!/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

The file is executable:

$ ls -l /etc/rc.local
-rwxr-xr-x 1 root root 333 aug 14  2013 /etc/rc.local

I added the 2 fstrim lines almost 2 years ago, when I installed a SSD, following the instructions from Easy Linux tips project.

Apparently these are the cause of my problem (I removed them and rebooted – the problem was gone), but I still think the system shouldn't hang like that for 10 minutes. Also, how can I run fstrim at boot now?

Best Answer

If you put long-running commands in rc.local, your startup will be delayed. You should send these to the background:

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

That said, you probably don't have to do this yourself. Ubuntu 14.10 added a weekly job for fstrim.

Related Question