Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

share|improve this question
up vote 5 down vote accepted

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

share|improve this answer

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

share|improve this answer

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.

share|improve this answer

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.

share|improve this answer
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 posting your answer, you agree to the privacy policy and terms of service.

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