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 have two 2-TB hard drives (not the boot/system drives) with a single partition in each, that I share with Samba. Mountpoints are in /mnt/drive01 and /mnt/drive02.

These are also the path of two samba shares, named backup1 and backup2. As soon as these shares are up, they start getting filled with (lots of) data from other machines in the network (some machines write to backup1, others to backup2, but none writes on both).

Everything works as planned, no problem with Samba. This server (on remote location) is configured to auto-reboot in case of power loss etc. Also, I have two drives in RAID1 as system/boot drives, to make sure the server can (almost!) always at least boot.

The problem is in case the system boots fine, but for some reason cannot mount one (or both) of the 2 TB hard drives: samba would start sharing /mnt/drive01 and /mnt/drive02, the large capacity drive (s) is not mounted so all the data in fact ends up on the system drive, filling it up and making the system unusable or unable to be accessed remotely via ssh.

So I don't think is a good idea entering the partitions of the two 2 TB drives in /etc/fstab, since I noticed some problems in boot in case one of the data drives is for example disconnected. Again this is important as the server is in remote location and cannot rely on an operator intervention to fix on-screen messages such as "drive not ready, keep waiting, press S to skip mounting, M for manual..."

So I have a small script which tries mounting the data drives a minute after boot, and this fixes the fstab part. Now on to Samba.

What I would like is to have Samba start after some time (no problem) but also "dynamically" enable or disable the two shares. So, for example, if the 2nd data drive fails, my script will only be able to mount the 1st data disk and samba would only advertise the backup1 share (with data being written to the 2-TB disk drive); the other share (backup2, mapped to /mnt/drive02) would be not advertised/disabled, but at least I have one share running (and some of my machines can pour data into it).

Of course, the easy way is to have samba start only if both data drives are mounted, but this is an all-or-nothing solution

Any ideas?

share|improve this question

1 Answer 1

There are two options. If you don't have another shares with Samba, you can just start Samba when both are mounted and stop when both are unmounted, using upstart or systemd. With systemd you should need Requires= stanza and with upstart start on mounted /dev/something. The other way is removing samba from the startup scripts and starting up using your script. Those options depends on what you have done already.

share|improve this answer

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.