I am setting up quota on my Linode server running Ubuntu 16.10, and I get the following error
Cannot stat() mounted device /dev/root: No such file or directory
So to fix this, I reached this thread for the fix which is done by adding
ln -s /dev/xvda /dev/root
/etc/init.d/quota restart
to the /etc/rc.local
. But Ubuntu 16.10 doesn't uses rc.local
anymore instead uses systemd. What is the alternative for rc.local
, How can I run the above commands on startup?
Also I enabled the service using systemctl enable rc-local.service
but it didn't work for me. Any lead would be appreciated.
Intro
I think you should not create a new service as suggested in the link by George. The
rc-local.service
already exists in systemd and the service file suggests that therc.local
, if it exists and is executable, gets pulled automatically intomulti-user.target
. So no need to recreate or force something that is just done in another way by thesystemd-rc-local-generator
.One solution
A quick solution (I don't know if that's the canonical way):
In a terminal do:
After that the
rc.local
will be called upon system startup. Insert what you like.Background
If you do in a terminal:
You can see that the head comment contains lines such as:
This indicates, that in this system, if there is a file called
/etc/rc.local
which is executable, then it will be pulled into multi-user.target automatically. So you just create the according file (sudo touch...
) and make it executable (sudo chmod +x ...
).I saw this solution suggested which involves use of
systemd
here:Create a service:
Add your code there:
Create and make sure
/etc/rc.local
is executable and add this code inside it:Enable the service:
Start service and check status:
If all goes well you can add your
code
to the/etc/rc.local
file then restart it.Note: Tested on Lubuntu 16.10.
Source:
https://www.linuxbabe.com/linux-server/how-to-enable-etcrc-local-with-systemd
To add to Jan's answer that, unlike the usual
rc.local
file,rc-local service
is executed not after all services have been started, but after the network goes online.In some cases you may want to run commands from
rc.local
later. For example, I wanted it to be executed afterlxd
start.In this case you can edit
rc-local service
startup dependencies by creating a drop-in conf file:/etc/systemd/system/rc-local.service.d/override.conf
with contents:Where you can add a needed unit name (like I added
lxd.service
)Do not forget to
systemctl daemon-reload
after that.