Moutning remote filesystems locally, not as seemless as it could be...

James Gray james at gray.net.au
Sun May 13 12:52:55 UTC 2007


On 12/05/2007, at 11:26 PM, Gabriel Dragffy wrote:
> On Sun, 2007-05-13 at 20:02 +1000, James Gray wrote:
>> On 12/05/2007, at 7:36 PM, Gabriel Dragffy wrote:
>>
>>> A while back I was mounting an NFS share locally, by having an entry
>>> in /etc/fstab. More recently I have switched to samba, and using
>>> smbfs I
>>> can now do the same thing. It is extremely convenient having remote
>>> filesystems so tightly integrated, meaning any application can make
>>> use
>>> of them.
>>>
>>> However, one huge problem that has bugged me, and has been  
>>> exaggerated
>>> by the move towards networking-manage-gnome in a default desktop
>>> install, is that remote filesystems in /etc/fstab will fail to  
>>> mount.
>>> This is because a network connection is only established once the
>>> computer has loaded up and a user logged in.
>>>
>>> It is growing increasingly irritating for me to always open up the
>>> terminal, run the command "sudo mount -a" and then wait a while  
>>> as it
>>> mounts the filesystems that I would have liked already mounted.
>>>
>>> If any one has workarounds or suggestions I'd be glad to hear them!
>>
>> Investigate "autofs" (as in the system service, not the fstab option
>> that has a similar name :P).  It can be used to mount pretty much
>> anything but grew out of an NFS heritage.  I've used it to automount
>> NFS, SMB and and local file systems (like memory cards and CDROMs).
>>
>> The general idea is you set up a mount point (locally) that only
>> mounts a file system when something (or someone) tries to access the
>> mount point's content.  Thus it doesn't matter if the network isn't
>> available during the boot-up mount sequence, only when something
>> tries to actually USE the auto-mounted file system.  If you have
>> subsequent boot processes that rely on the remote file system, simply
>> move the network start before autofs in the boot sequence ("man
>> update-rc.d" for the proper way to do that).
>>
>> HTH,
>>
>> James
>
>
> Hi James
>
> I've been trying to get a bead on autofs. Installed it and read the  
> man
> of autofs, along with mount, fstab, and automount. Getting kind of  
> lost
> here.
>
> If one simply wishes to have a samba share automounted then what is  
> the
> simplest course of action, and what config files actually need  
> chaning?

Hi Gabriel,

Basically, autofs uses a "master" file that simply designates a  
directory to take control of, then delegates the actual work (mount  
points effectively) to other configuration files.  Something like:

auto.master:
/mnt/auto   /etc/auto.smb    --timeout=60 --ghost

This takes control of "/mnt/auto" and sets two options:
--timeout=60 means "unmount after 1 minute of inactivity".
--ghost means "create the mount points under /mnt/auto even if the  
filesystem referenced isn't mounted".

Then in /etc/auto.smb you have the real work:
smb   -fstype=smbfs,credentials=/etc/smb.auth   ://winSvr/Pth/To/Share

The first argumnet (smb) is the mount pont (ie, /mnt/auto/smb) the  
second is a standard set pf options you would pass to a normal  
"mount" command and the last argument is, in this case, the remote  
SMB/CIFS file system.

So with the above config, the autofs daemon will mount the SMB/CIFS  
share at //winSvr/Pth/To/Share using the credentials in /etc/smb.auth  
at /mnt/auto/smb whenever someone accesses /mnt/auto/smb (like  
running 'ls /mnt/auto/smb', or uses tab completion to look in /mnt/ 
auto/smb, etc).

See how it works?  Once the automounter (autofs) daemon is running,  
the rest is totally automagic :)

Here's a good how-to:
http://gentoo-wiki.com/HOWTO_Auto_mount_filesystems_(AUTOFS)
It's written for Gentoo, but is easily adapted to Ubuntu (basically,  
ignore all the installation fru-fru at the top, and leave the  
configuration files where they are on Ubuntu).

Here's another one (took forever to load - slow site but worth the  
wait):
http://www.linuxfocus.org/Castellano/January2001/article141.meta.html

I think that just about covers it.  Read through those how-tos and  
see if you can nut it out.  Once the light-bulb comes on, you'll  
wonder what all the fuss was about![1]

Cheers,

James
[1] Just finished with one of those involving CUPS on Mac OSX! Bah :(
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 2417 bytes
Desc: not available
URL: <https://lists.ubuntu.com/archives/ubuntu-users/attachments/20070513/bf5a3d4e/attachment.bin>


More information about the ubuntu-users mailing list