Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I'm currently mounting my external harddrive using the following entry in /etc/fstab:

UUID=12C23AD8C23AC031    /media/MyBook ntfs-3g auto,users,exec,rw,nobootwait,iocharset=utf8,uid=1000,gid=1000 0 0

In addition to that, I also need to run mount as follows (which I currently only do before starting Steam, but it's getting annoying to constantly do so; I would prefer it was automated):

sudo mount --rbind /media/MyBook/Games/SteamData /home/andreas/.local/share/Steam/

Is there any way to automatically mount the SteamData folder whenever the drive "My Book" is mounted? There are answers on how to run a shell script when a drive is mounted, but is it better/possible to do this directly from fstab?

Note that my external harddrive may not be available at boot, and may be plugged in at a later time.

share|improve this question

1 Answer 1

the fstab entry would be:

/source/dir            /destination/dir    none  bind            0 0

or

/media/MyBook/Games/SteamData     /home/andreas/.local/share/Steam/   none  bind     0   0

be certain you have full perms to this folder, unless you want a r/o mount.

share|improve this answer
    
Would this work even if MyBook isn't mounted at boot? (the path /media/MyBook/Games/SteamData would not exist) Would it still work if MyBook were plugged in later on? –  IQAndreas Aug 9 '13 at 21:24
    
no.. for hot plugging you would need to use udev rules, and thats over my head as of this moment, but since you have the MyBook in fstab the kernel would throw an error at boot if the device didn't exist at boot time, so it might be wise to just use udev rules to make this work, unless you never remove the device the fstab is the fastest solution –  Spilt_Blood Aug 10 '13 at 10:48
    
"since you have the MyBook in fstab the kernel would throw an error at boot if the device didn't exist at boot time" - That's why I used the nobootwait flag in the fstab entry. Before I learned about it, I used to just press s to skip if it wasn't connected at boot. –  IQAndreas Aug 10 '13 at 13:56

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.