How to set permissions on boot for a Volume


I’ve managed to set up a volume and attached it to my droplet in the storage folder of my project. On boot this is done by fstab by the following line.

/dev/disk/by-id/scsi-0DO_Volume_volume-ams3-01 /path/to/mount-point ext4 defaults,nofail,discard 0 0

However after every reboot I need to set the permissions by performing:

sudo chown -R forge:forge /path/to/mount-point

Otherwise the forge user has no permissions on the volume. Can this be automated and is there a best practice for this?

Thanks in advance.

Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Accepted Answer

Hey There,

What I can suggest is the following:

  • Create a scriptfile with touch scriptfile
  • Add the following to it:
sudo chown -R forge:forge /path/to/mount-point
  • Execute the following commands:
chmod +x scriptfile
chmod 755 scriptfile
mv *scriptfile* /etc/init.d/
touch /etc/rc3.d/S01scriptfile
update-rc.d scriptfile defaults
  • You just added your script to your boot sequence and should be good to go!

Source -

As an alternate solution, you can use crontab and set a @reboot line in there -

Hope this helps and make sure to let me know if it did!

Best, Dennis

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

Featured on Community

Get our biweekly newsletter

Sign up for Infrastructure as a Newsletter.

Hollie's Hub for Good

Working on improving health and education, reducing inequality, and spurring economic growth? We'd like to help.

Become a contributor

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

Welcome to the developer cloud

DigitalOcean makes it simple to launch in the cloud and scale up as you grow — whether you're running one virtual machine or ten thousand.

Learn more
DigitalOcean Cloud Control Panel