3

I've tried run some scripts after boot via /etc/rc.local.

/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.
/home/startup.sh

exit 0

/home/startup.sh

mount -t vboxsf test /home/test

Here is the result on boot

enter image description here

Here is the output of systemctl status rc-local.service

rc-local.service - /etc/rc.local Compatibility
   Loaded: loaded (/lib/systemd/system/rc-local.service; static)
   Active: failed (Result: exit-code) since Sun 2016-02-07 22:48:23 ICT; 18min ago
  Process: 432 ExecStart=/etc/rc.local start (code=exited, status=1/FAILURE)

Feb 07 22:48:23 debian rc.local[432]: /sbin/mount.vboxsf: mounting failed with the error: No such device
Feb 07 22:48:23 debian systemd[1]: rc-local.service: control process exited, code=exited status=1
Feb 07 22:48:23 debian systemd[1]: Failed to start /etc/rc.local Compatibility.
Feb 07 22:48:23 debian systemd[1]: Unit rc-local.service entered failed state.

I've tried manually running sudo bash /home/startup.sh and it works fine. I've also applied this method on Ubuntu 14.04 and no errors occurr.

What is the reason behind this failure? How can I fix it?

4
  • 1
    Did you try following the suggestion printed after FAILED? Namely, what does systemctl status rc-local.service report when run as root? Commented Feb 7, 2016 at 10:57
  • Concur with @FerencWágner -- please update this answer with the error output. We need those details if we're to be any help. Commented Feb 7, 2016 at 11:54
  • @FerencWágner I've updated my question with your required information.
    – Lewis
    Commented Feb 7, 2016 at 16:10
  • @Shadur I've updated my question.
    – Lewis
    Commented Feb 7, 2016 at 16:11

2 Answers 2

4

Your problem seems to be that your rc-local.service is started before vboxadd-service.service, but it should run after it. Now, rc.local is a SysV thing (where it runs at the very end of the boot process), the compatibility provided by systemd is not perfect (as you can see in your screenshot). You'd probably better off with a custom home-test.mount unit like this:

[Unit]
Requires=vboxadd-service.service
After=vboxadd-service.service

[Mount]
What=test
Where=/home/test
Type=vboxsf

[Install]
WantedBy = multi-user.target

Then systemctl enable home-test.mount, remove the /home/startup.sh call from /etc/rc.local and test the new setup with a reboot.

Warning: I've got zero experience with VirtualBox and very litte with mount units. But you get the idea.

1
  • Big thanks for your answer! I've tested your method and it works perfectly.
    – Lewis
    Commented Feb 7, 2016 at 20:09
0

You need to put your file in:

/etc/init.d/

And then you have to change it to an executable file by:

chmod +x /etc/init.d/myscript

if this does not run you have to create a symlink to:

/etc/rc.d/

ln -s /etc/init.d/myscript /etc/rc.d/

Please note that on latest Debian, this will not work as your script have to be LSB compliant (provide, at least, the following actions: start, stop, restart, force-reload, and status): https://wiki.debian.org/LSBInitScripts

1
  • It doesn't work. A similar error occurred on boot, [FAILED] Failed to start LSB: Start daemon at boot time.
    – Lewis
    Commented Feb 7, 2016 at 4:41

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .