I believe you will need to use the newer systemd
service on Ubuntu 16.04 rather than the /etc/init.d
. Here you will create a service file to run your script after the local-fs.target
.
let me present you with a sample of how this would be done.
Create the needed service
file in the /etc/systemd/system
directory
The file would look like this:
[Unit]
Description=Script to run after fstab
After=local-fs.target
[Service]
Type=simple
ExecStart=/bin/bash -c "/script/to/run.sh"
[Install]
WantedBy=multi-user.target
And of course you will set up the service with:
sudo systemctl start <name_of_service>
sudo systemctl enable <name_of_service>
That would be how it could be done, please I haven't tested it myself, and here is link to documentation to help you further. Please look at other options available for the various fields in the service file.
https://access.redhat.com/articles/754933
https://www.freedesktop.org/software/systemd/man/bootup.html
https://www.freedesktop.org/software/systemd/man/systemd.html#
Note: that the noauto
fstab mount option matters here see
local-fs-pre.target
|
v
(various mounts and (various swap (various cryptsetup
fsck services...) devices...) devices...) (various low-level (various low-level
| | | services: udevd, API VFS mounts:
v v v tmpfiles, random mqueue, configfs,
local-fs.target swap.target cryptsetup.target seed, sysctl, ...) debugfs, ...)
| | | | |
\__________________|_________________ | ___________________|____________________/
\|/
v
sysinit.target
|
____________________________________/|\________________________________________
/ | | | \
| | | | |
v v | v v
(various (various | (various rescue.service
| | | v
v v v emergency.target
display- (various system (various system
manager.service services services)
| required for |
| graphical UIs) v
| | multi-user.target
| | |
\_________________ | _________________/
\|/
v
graphical.target
Looking at the diagram above your targets would be local-fs.target
or sysinit.target
not entirely sure as the latter covers all file systems. So you decide on the phase when your script would run to give you the desired effect.
You can also set a specific mountpoint as a target foobar.mount
. Find your complete list with systemctl list-units --type=mount
.