Com alguns de vosaltres ja haureu experimentat amb gnome, accedir a un recurs Samba amb Nautilus es molt i molt lent, això sense contar la de vegades que has de indicar-li quina es la contrasenya a no ser que la guardis a l’anell de claus.
Es per això que avui us porto, una de les mil i una formes de configurar el autofs per tal de accedir de forma ràpida al nostre espai SAMBA.
Abans de començar, que cal tenir instalat per utilitzar aquest sistema?
- El client de samba: samba(gentoo), smbclient i smbfs (ubuntu), etc…
- El mount de cifs: mount-cifs(gentoo), amb ubuntu està inclòs al smbclient.
- El autofs propiament dit: autofs (gentoo i ubuntu).
Un cop instalat haurem de configurar al sistema.
La manera mes sencilla que hi ha, tot i que a alguns els pot semblar mica manual es la següent:
Editem el fitxer de configuració del autofs
- /etc/auto.master (ubuntu)
- /etc/autofs/auto.master (gentoo)
Dins aquest fitxer afegirem la següent linia:
/mnt/auto /etc/autofs/auto.auto --timeout=60
A continuació afegirem a l’arxiu /etc/hosts una linia que contingui la ip del servidor i el seu nom associat, per exemple:
192.168.0.24 fileserver
Un cop afegit, editarem l’arxiu /etc/autofs/auto.auto (el que no tingueu creada la carpeta /etc/autofs podeu crearla amb ‘mkdir /etc/autofs‘). En aquest arxiu i afegirem el següent:
nom_carpeta --fstype=cifs,credentials=/etc/auto.smb.nom_server ://nom_server/path_server/
on nom_carpeta serà el nom de la carpeta que es mapejarà a /mnt/auto/nom_carpeta, nom_server el nom que li hem associat abans al servidor, i el path_server la carpeta dins del servidor que volem mapejar. En el meu cas m’ha quedat de la següent forma:
#directori Opcions Path del servidor
fileserver --fstype=cifs,credentials=/etc/auto.smb.fileserver ://fileserver/akas84/
Un cop fet això, ens falta indicarli el usuari i contrasenya per la conexió al servidor. Per fer-ho, editem l’arxiu /etc/auto.smb.nom_server i li afegim el següent contingut:
username=nom_usuari
password=password_usuari
on nom_usuari en el meu cas seria akas84 i password_usuari el password del usuari akas84 dins el server. Us recomano que aquest arxiu només el pogueu llegir vosaltres, per fer-ho executeu el següent comandament:
chmod 400 /etc/auto.smb.nom_server
Un cop fet això, i si tot ho hem fet bé, només hem de reiniciar el daemon executant:
/etc/init.d/autofs restart
Si tot ho hem fet bé, si llistem el contingut del directori mapejat i hauriem de tenir el contingut del server.
As some of you will know, access to a Samba drive with some program like Nautilus can be a horrible expirience about how slow it is. To solve this, you can use Autofs.
HOWTO Autofs:
What do you need?
- The samba client: samba(gentoo), smbclient i smbfs (ubuntu), etc…
- Cifs mount program: mount-cifs(gentoo), Ubuntu includes this in the smbclient package.
- The autofs software: autofs (gentoo i ubuntu).
Edit the autofs config file:
- /etc/auto.master (ubuntu)
- /etc/autofs/auto.master (gentoo)
Add the following line inside the file:
/mnt/auto /etc/autofs/auto.auto --timeout=60
Add a hostname to the server adding a line like the following to /etc/hosts file:
192.168.0.24 fileserver
Now edit the file /etc/autofs/auto.auto (the people who doesn’t have the directory /etc/autofs can create it with ‘mkdir /etc/autofs‘). In this file add this line:
folder_name --fstype=cifs,credentials=/etc/auto.smb.hostname ://hostname/server_path/
where folder_name is the name of the folder that will be mapped in /mnt/auto/folder_name, hostname is the hostname we have assigned in /etc/hosts, and path_server is the folder inside the server that we want to map. In my case the line is like this:
#directory Options Server_Path
fileserver --fstype=cifs,credentials=/etc/auto.smb.fileserver ://fileserver/akas84/
Now it’s missing the credentials file where we will put our username and our password. To do this edit the file /etc/auto.smb.hostname and add this lines:
username=our_username
password=our_password
where out_username in my case is akas84 and our_password is the password of akas84 inside the server. I advise you to edit the permissions’ file to make it read-only by you. You could make this with the following sentence:
chmod 400 /etc/auto.smb.nom_server
If you have done it good now you can restart the daemon and try the new system:
/etc/init.d/autofs restart
Enjoy It!
Arxivat a Uncategorized
Etiquetes: autofs, cifs, gnu/linux, smbs