20110609

Linux: Montar unidades de red en el inicio - Linux: Mount network shared folders on logon

Hoy en día es raro quién en el trabajo no tiene que acceder a varios recursos compartidos en red, como unidades departamentales o de usuario.
Para aquellos que usan Microsoft Windows como cliente y sobre todo si acceden a un dominio de Active Directory, lo tienen fácil con los scripts de inicio del recurso compartido de dominio netlogon. Basta con añadir una línea:
net use unidad: \\servidor\recurso

por cada uno de los recursos que queremos mapear en nuestro equipo, y ya está. Por ejemplo:
net use u: \\fileserver01\bdispatcher

Sin embargo si tu caso es como el mío y utilizas GNU/Linux como cliente, quizás todavía no sepas como hacerlo. En una entrada anterior, explicaba cómo crear scripts de login y logout en KDE, así que bastaría con crear un script para montar las unidades al inicio, y otro para desmontarlas al cerrar la sesión. Si las unidades que quieres montar pertenecen a recursos compartidos tipo SMB/CIFS, podemos usar el comando smbmount del siguente modo:
smbmount //servidor/recurso ruta_local -o opciones

como por ejemplo:
smbmount //fileserver01/bdispatcher ~/network/bdispatcher -o credentials=~/data.cred,iocharset=utf8

Con esta línea montamos el recurso bdispatcher del servidor fileserver01 en el directorio ~/network/bdispatcher usando las credenciales del fichero ~/data.cred y usando el UTF8 como juego de caracteres.
En el script de cierre de sesión podemos utilizar el comando smbumount para desmontar las unidades con la sintaxis:
smbumount ruta_local

por ejemplo:
smbumount ~/network/bdispatcher

Para más información sobre estos comandos, ya sabes man!

Nowadays it's weird to find someone who doesn't work with some shared network resources like departament or user units.
For those who use Microsoft Windows as desktop and Active Directory it's easy to map this resources using the netlogon scipts. Simply adding a line:
net use unidad: \\server\shared

for each shared resource and it's done. For example:
net use u: \\fileserver01\bdispatcher

But if you are one of those who use GNU/Linux as desktop, maybe you don't know how to do that. On a previous post I explained how to use login and logout scripts in KDE, so you only have to write a login script to mount and a logout script to umount the network shares. If the network shares are SMB/CIFS, you can use the command smbmount in this way:
smbmount //server/shared local_path -o options

for example:
smbmount //fileserver01/bdispatcher ~/network/bdispatcher -o credentials=~/data.cred,iocharset=utf8

With this line we can mount the bdispatcher resource from the server fileserver01 on the directory ~/network/bdispatcher using the credentials file ~/data.cred and UTF8 as the characters set.
In the logout script we can use smbumount to umount the shares with the syntax:
smbumount local_path

eg:
smbumount ~/network/bdispatcher

For more and better info about these commands, you know man!

PS. I know, I know. My English is not good enought but, the more you help me, the more I learn.

1 comentario:

Unknown dijo...

Por si a alguno se le atragantase, mi fichero de credenciales tiene esta pinta:

In case anyone is wondering how my file is, here it is:

bdispatcher@laptop:~$ cat data.cred
username=bdispatcher
password=secret