Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have an extra hard drive which I access regularly in Ubuntu, and I have a link from my home folder to a folder on this drive. However, this link doesn't work when I first log in because the hard drive hasn't been mounted (or something, I presume). If I browse to the hard drive by going to Computer and selecting the hard disk, then the link because usable for the rest of my session. However, it's annoying to have to do this manual step each time I log in. How I can reproduce this in a startup script?

share|improve this question
add comment

1 Answer

up vote 1 down vote accepted

If this is a fixed drive which is there when the machine is booted, then you can add an entry for the volume to the /etc/fstab file.

For example, on a Ubuntu VM here, I have a fstab entry like this:

/dev/sdb1 /personal ext4 defaults 0 0

The device /dev/sdb1 (first partition of /dev/sdb) is mounted at /personal. The filesystem type is ext4, all options are defaulted.

The first zero is a traditional parameter related to the dump backup utility, indicating dump frequency. I'm not using that so I have a zero there.

The second zero is the boot-time check order. Zero means that the volume is not checked for errors on boot. The root filesystem's entry will have a 1 here, and others that are checked usually 2. The values determines the check order. Volumes marked 1 are checked first, then those marked 2 and so on. If volumes with the same pass number are on separate drives, then they are checked in parallel.

If you omit these numbers, it isn't a syntax error. They default to zero.

Even if the drive is a removable one, you can still create a fstab entry, but with different options:

# substitute your device name and mount point
/dev/sdb1 /personal ext4 noauto,user 0 0

The noauto option means that the mount -a command will not mount the drive and thus it will not be mounted at boot time. The user option means that regular non-root users can mount this just by running mount /personal.

With this setup, you can then add a mount command to your ~/.bash_login file or whatever.

share|improve this answer
    
Thanks. A little more complicated than I had hoped (but that's not your fault). I appreciate the info. –  rmp251 Apr 19 '13 at 1:28
add comment

Your Answer

 
discard

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.