Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have a small home server running Ubuntu 12.04 with an external hard drive attached to it. The external hard drive is mounted with autofs. Autofs basically unmounts a hard drive if it isn't used for a specified amount of time and automatically mount them back if some one tries to read / write from the mount folder.

Autofs and Samba working correctly my only problem now is:

  • The samba shares are located within the external hard drive, I only want to share sub-folders. E.g.: the music folder on the hard drive.
  • Autofs mount the harddrive to /automnt/external. If you access the folder the drive will be mounted and you can access the music folder (/automnt/external/music)
  • If the drive is unmounted and some one tries to access it samba apparently just tries to access the music sub-folder which is not yet accessible.

My question: Is it possible to tell samba before allowing access one of the shares to run a little script (ls /automnt/extern would do) to make sure the drive is mounted?

share|improve this question
    
Doesn't make sense to me. It is impossible (for samba and anything else) to access /automnt/external/music without accessing /automnt/external first. I would look for the solution in the autofs area. What happens if you export /automnt/external and the external drive is not connected when Samba starts but connected later and then an access is tried? –  Hauke Laging Feb 22 '13 at 14:08
    
@HaukeLaging it works if I share the whole drive, so yes, autofs does not seem like the perfect solution anymore and could be replaced with something handling the job better. This question was out of curiosity and because it would be very simple to add a line in the smb.conf and write a bash one-liner. –  TheHippo Feb 22 '13 at 14:12

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.