I need to mount a shared folder at a boot up automatically so I don't have to manually write this line to the xterm every time:

sudo mount -t vboxsf share ~/host

I have done this:

sudo crontab -e

And added at the end of the file:

@reboot /home/richard/mounthost

The file /home/richard/mounthost contains:

sudo mount -t vboxsf share ~/host

But it is not working. Any help?

I am using Ubuntu 10.10


For mounting on boot, you should add it to /etc/fstab. Take a look here:


The proper place to add filesystems to be mounted on boot is /etc/fstab. See the fstab(5) man page for details.


Add a line to /etc/fstab. This will mount the file system at startup, The header will show you which column to place the various option. Use man mount and man fstab for additional information.


The other answers here have already pointed out the proper way of specifying boot-time mounts.

So why does your script not work? Have you set execute permissions on it? e.g.

chmod +x /home/richard/mounthost

Perhaps the device is not yet ready to be mounted at the point in time when cron runs its @reboot jobs? Check the system logs for messages.

Finally, a note about system security: It is very bad policy to run scripts from the root crontab that are not owned by root! If the richard account is ever compromised, an intruder can gain root access by modifying /home/richard/mounthost. If you decide not to put your device into /etc/fstab, I would strongly recommend changing your crontab entry so that it runs the mount command directly, and does not run a non-root-owned script.

  • Very nice point on not running scripts from root, which are not owned by root. :) – Saurabh Barjatiya Nov 17 '10 at 3:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.