I have a folder /mnt/automounts which is used to automount usb drives in (which is working.). There is one scenario that still causes an issue. When a usb drive is plugged in, then the system is shut down and afterwards I unplug the usb drive. When i start up the system again the specific folder of the mount is still present in mnt/automounts.
For this reason I would like to start a script at shutdown (and reboot) that removes the automounts folder. to do this I've created a shell script called clearmnt.sh and put it in the /etc/init.d folder>
clearmnt.sh looks like this:
### BEGIN INIT INFO
# Provides: clearmnt
# Default-Start: 0 6
# Short-Description: removes directories of automounted folders in /mnt
### END INIT INFO
rm -rf /mnt/automounts
Then I've created soft links in rc0.d and rc6.d (shutdown and reboot):
sudo ln -s /etc/init.d/clearmnt.sh /etc/rc0.d/clear_mnt
sudo ln -s /etc/init.d/clearmnt.sh /etc/rc6.d/clear_mnt
And then I made clearmnt.sh executable:
sudo chmod +x /etc/init.d/clearmnt.sh
Then I did a reboot to see if it works. It did not, the /mnt/automounts folder is still there after reboot.
Any idea what I'm doing wrong, or what step I am missing? This is all done on a yocto build.