viernes, 16 de julio de 2010

Ubuntu server 10.04 LTS en castellano bajo OpenVZ

La forma más fácil de crear una máquina virtual bajo Linux es usando el sistema de virtualización proporcionada por OpenVZ.

El único problema que plantea esta manera de instalar máquinas virtuales es que las plantillas están configuradas por defecto con zonas horarias, idiomas, etc que no nos interesan.

En este documento instalaremos una plantilla de Ubuntu server 10.04 LTS y la configuraremos para que use tanto la configuración local española como su zona horaria. Presupondremos instalado y funcionando OpenVZ en el sistema anfitrión.

El primer paso será descargar la plantilla de http://download.openvz.org/template/precreated/ y colocarla en la ruta adecuada:

root@anibal:~# wget -O "/var/lib/vz/template/cache/ubuntu-10.04-x86.tar.gz" "http://download.openvz.org/template/precreated/ubuntu-10.04-x86.tar.gz"
--09:01:21-- http://download.openvz.org/template/precreated/ubuntu-10.04-x86.tar.gz
=> '/var/lib/vz/template/cache/ubuntu-10.04-x86.tar.gz'
Resolviendo download.openvz.org... 64.131.90.11
Conectando a download.openvz.org|64.131.90.11|:80... conectado.
Petición HTTP enviada, esperando respuesta... 200 OK
Longitud: 137,211,613 (131M) [application/x-gzip]

100%[==============================================>] 137,211,613 1.88M/s ETA 00:00

09:02:15 (2.41 MB/s) - `/var/lib/vz/template/cache/ubuntu-10.04-x86.tar.gz' guardado [137211613/137211613]

El segundo paso es crear la máquina virtual usando la plantilla que acabamos de descargar. Hay que fijarse que en el parámetro --ostemplate se omite la extensión ".tar.gz" de la plantilla:

root@anibal:~# vzctl create 100 --ostemplate ubuntu-10.04-x86 --ipadd 10.0.0.100 --hostname equipo100
Creating VE private area (ubuntu-10.04-x86)
Performing postcreate actions
VE private area was created

Ahora deberemos configurar algunos aspectos de la máquina virtual, iniciarla y cambiarle la clave de root:

root@anibal:~# vzctl set 100 --nameserver 10.0.0.1 --save
Saved parameters for VE 100
root@anibal:~# vzctl set 100 --onboot yes --save
Saved parameters for VE 100
root@anibal:~# vzctl start 100
Starting VE ...
VE is mounted
Adding IP address(es): 10.0.0.100
Setting CPU units: 1000
Configure meminfo: 65536
Set hostname: equipo100
File resolv.conf was modified
VE start in progress...
root@anibal:~# vzctl exec 100 passwd
Enter new UNIX password: nuevaclave
Retype new UNIX password: nuevaclave
passwd: password updated successfully

Tras esto DEBEREMOS loguearnos usando ssh en la máquina remota para continuar nuestro trabajo: instalar los paquetes necesarios para poder trabajar en castellano. Recomiendo ENCARECIDAMENTE que el resto de trabajo se realice bajo una conexión SSH y no con el comando "vzctl enter 100" para que se aplique correctamente la configuración local al usuario.

root@anibal:~# ssh 10.0.0.100
The authenticity of host '10.0.0.100 (10.0.0.100)' can't be established.
RSA key fingerprint is xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '10.0.0.100' (RSA) to the list of known hosts.
root@10.0.0.100's password:
Linux equipo100 2.6.24-28-openvz #1 SMP Thu May 27 04:04:37 UTC 2010 i686 GNU/Linux
Ubuntu 10.04 LTS

Welcome to Ubuntu!
* Documentation: https://help.ubuntu.com/

The programs included with the Ubuntu system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.*/

Ubuntu comes with ABSOLUTELY NO WARRANTY, to the extent permitted by
applicable law.

root@equipo100:~# apt-get update
Get:1 http://archive.ubuntu.com lucid Release.gpg [189B]
Get:2 http://archive.ubuntu.com lucid-updates Release.gpg [189B]
Get:3 http://archive.ubuntu.com lucid-security Release.gpg [189B]
Get:4 http://archive.ubuntu.com lucid Release [57.2kB]
Get:5 http://archive.ubuntu.com lucid-updates Release [44.7kB]
Get:6 http://archive.ubuntu.com lucid-security Release [38.5kB]
Get:7 http://archive.ubuntu.com lucid/main Packages [1386kB]
Get:8 http://archive.ubuntu.com lucid/restricted Packages [6208B]
Get:9 http://archive.ubuntu.com lucid/universe Packages [5448kB]
Get:10 http://archive.ubuntu.com lucid-updates/main Packages [259kB]
Get:11 http://archive.ubuntu.com lucid-updates/restricted Packages [3252B]
Get:12 http://archive.ubuntu.com lucid-updates/universe Packages [74.9kB]
Get:13 http://archive.ubuntu.com lucid-security/main Packages [48.9kB]
Get:14 http://archive.ubuntu.com lucid-security/restricted Packages [14B]
Get:15 http://archive.ubuntu.com lucid-security/universe Packages [24.5kB]
Fetched 7392kB in 15s (478kB/s)
Reading package lists... Done
root@equipo100:~# apt-cache search language | grep \\-es
kde-l10n-es - Spanish (es) localization for KDE
language-support-es - metapackage for Spanish; Castilian language support
language-support-writing-es - Writing aids metapackage for Spanish; Castilian
openoffice.org-l10n-es - office productivity suite -- Spanish language package
thunderbird-locale-es-ar - Thunderbird Spanish; Castilian language/region package
thunderbird-locale-es-es - Thunderbird Spanish; Castilian language/region package
apertium-es-ca - Apertium linguistic data to translate between Spanish and Catalan
apertium-es-gl - Apertium linguistic data to translate between Spanish and Galician
apertium-es-pt - Apertium linguistic data to translate between Spanish and Portuguese
apertium-es-ro - Apertium linguistic data to translate between Spanish and Romanian
apertium-eu-es - Apertium linguistic data to translate between Basque and Spanish
enigmail-locale-es-es - Spanish (ES) language package for Enigmail
erlang-esdl - Erlang bindings to the Simple Direct Media Library
maint-guide-es - Spanish translation of Debian New Maintainers Guide
python-espeak - Python bindings for eSpeak
sword-language-pack-es - Sword modules for the Spanish language
language-pack-es - translation updates for language Spanish; Castilian
language-pack-es-base - translations for language Spanish; Castilian
language-pack-gnome-es - GNOME translation updates for language Spanish; Castilian
language-pack-gnome-es-base - GNOME translations for language Spanish; Castilian
language-pack-kde-es - KDE translation updates for language Spanish; Castilian
language-pack-kde-es-base - KDE translations for language Spanish; Castilian
root@equipo100:~# apt-cache search manpages | grep \\-es
manpages-es - Spanish man pages
manpages-es-extra - Spanish extra manpages

A continuación instalamos los paquetes que nos proporcionarán la traducción al castellano del sistema:

root@equipo100:~# apt-get install language-pack-es manpages-es manpages-es-extra
Reading package lists... Done
Building dependency tree... Done
The following extra packages will be installed:
language-pack-es-base
Suggested packages:
language-support-es
The following NEW packages will be installed:
language-pack-es language-pack-es-base manpages-es manpages-es-extra
0 upgraded, 4 newly installed, 0 to remove and 3 not upgraded.
Need to get 6483kB of archives.
After this operation, 21.8MB of additional disk space will be used.
Do you want to continue [Y/n]? y
Get:1 http://archive.ubuntu.com/ubuntu/ lucid-updates/main language-pack-es-base 1:10.04+20100422 [4263kB]
Get:2 http://archive.ubuntu.com/ubuntu/ lucid-updates/main language-pack-es 1:10.04+20100422 [2040B]
Get:3 http://archive.ubuntu.com/ubuntu/ lucid/universe manpages-es 1.55-9 [1542kB]
Get:4 http://archive.ubuntu.com/ubuntu/ lucid/universe manpages-es-extra 0.8a-16 [676kB]
Fetched 6483kB in 13s (475kB/s)
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
LANGUAGE = (unset),
LC_ALL = (unset),
LANG = "es_ES.UTF-8"
are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
locale: Cannot set LC_CTYPE to default locale: No such file or directory
locale: Cannot set LC_MESSAGES to default locale: No such file or directory
locale: Cannot set LC_ALL to default locale: No such file or directory
Preconfiguring packages ...
Selecting previously deselected package language-pack-es-base.
(Reading database ... 21602 files and directories currently installed.)
Unpacking language-pack-es-base (from .../language-pack-es-base_1%3a10.04+20100422_all.deb) ...
Selecting previously deselected package language-pack-es.
Unpacking language-pack-es (from .../language-pack-es_1%3a10.04+20100422_all.deb) ...
Selecting previously deselected package manpages-es.
Unpacking manpages-es (from .../manpages-es_1.55-9_all.deb) ...
Selecting previously deselected package manpages-es-extra.
Unpacking manpages-es-extra (from .../manpages-es-extra_0.8a-16_all.deb) ...
Setting up manpages-es (1.55-9) ...
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
LANGUAGE = (unset),
LC_ALL = (unset),
LANG = "es_ES.UTF-8"
are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
locale: Cannot set LC_CTYPE to default locale: No such file or directory
locale: Cannot set LC_MESSAGES to default locale: No such file or directory
locale: Cannot set LC_ALL to default locale: No such file or directory

Setting up manpages-es-extra (0.8a-16) ...
To enable these manpages set LC_MESSAGES to 'es' (or es_ZZ where ZZ is your
contry code). Man will then search for Spanish manpages under
/usr/share/man/es.

Para activar estas p▒ginas de manual ponga LC_MESSAGES a 'es'
(o es_ZZ donde ZZ es el c▒digo de su pais). Man buscar▒ sus
p▒ginas bajo /usr/share/man/es.

Setting up language-pack-es (1:10.04+20100422) ...
Setting up language-pack-es-base (1:10.04+20100422) ...
Generating locales...
es_AR.UTF-8... done
es_BO.UTF-8... done
es_CL.UTF-8... done
es_CO.UTF-8... done
es_CR.UTF-8... done
es_DO.UTF-8... done
es_EC.UTF-8... done
es_ES.UTF-8... done
es_GT.UTF-8... done
es_HN.UTF-8... done
es_MX.UTF-8... done
es_NI.UTF-8... done
es_PA.UTF-8... done
es_PE.UTF-8... done
es_PR.UTF-8... done
es_PY.UTF-8... done
es_SV.UTF-8... done
es_US.UTF-8... done
es_UY.UTF-8... done
es_VE.UTF-8... done
Generation complete.

Ahora, con los paquetes adecuados instalados sólo nos queda un único paso para tener en castellano nuestra ubuntu server: configurar la configuración local. Para ello tecleamos:

root@equipo100:~# update-locale LANG="es_ES.UTF-8" LANGUAGE="es_ES.UTF-8" LC_ALL="es_ES.UTF-8"

Antes de reiniciar nuestra máquina para comprobar que todo ha quedado bien procederemos a configurar la zona horaria:

root@equipo100:~# dpkg-reconfigure tzdata

Nos aparecerá un listado de contenientes en el que deberemos seleccionar "Europe":

Configuración de paquetes

┌───────────────────────┤ Configuración de tzdata ├───────────────────────┐
│ Please select the geographic area in which you live. Subsequent │
│ configuration questions will narrow this down by presenting a list of │
│ cities, representing the time zones in which they are located. │
│ │
│ Geographic area: │
│ │
│ Africa ↑ │
│ America ▒ │
│ Antarctica ▒ │
│ Australia ▒ │
│ Arctic ▮ │
│ Asia ▒ │
│ Atlantic ▒ │
│ Europe ▒ │
│ Indian ↓ │
│ │
│ │

│ │
└─────────────────────────────────────────────────────────────────────────┘

Tras elegir Europa, deberemos seleccionar "Madrid" en el siguiente listado de localizaciones:

Configuración de paquetes

┌────────────────────┤ Configuración de tzdata ├─────────────────────┐
│ Please select the city or region corresponding to your time zone. │
│ │
│ Time zone: │
│ │
│ Kiev ↑ │
│ Lisboa ▒ │
│ Liubliana ▒ │
│ Londres ▒ │
│ Luxemburgo ▮ │
│ Madrid ▒ │
│ Malta ▒ │
│ Mariehamn ▒ │
│ Minsk ▒ │
│ Mónaco ▒ │
│ Moscú ↓ │
│ │
│ │

│ │
└────────────────────────────────────────────────────────────────────┘

Tras configurar la zona horaria nos aparecerá la hora actual para confirmarnos que todo ha ido bien:

Current default time zone: 'Europe/Madrid'
Local time is now: Fri Jul 16 11:45:47 CEST 2010.
Universal Time is now: Fri Jul 16 09:45:47 UTC 2010.

Tras salir y entrar de nuevo a través de SSH veremos que todo (o casi todo) aparece en castellano. Podemos probar el resultado de un "apt-get update" o consultar una página del manual con "man ls" para comprobarlo:

root@anibal:~# ssh 10.0.0.100
root@10.0.0.100's password:
Linux equipo100 2.6.24-28-openvz #1 SMP Thu May 27 04:04:37 UTC 2010 i686 GNU/Linux
Ubuntu 10.04 LTS

Welcome to Ubuntu!
* Documentation: https://help.ubuntu.com/
Last login: Fri Jul 16 09:30:37 2010 from anibal
root@equipo100:~# apt-get update
Obj http://archive.ubuntu.com lucid Release.gpg
Des:1 http://archive.ubuntu.com/ubuntu/ lucid/main Translation-es [658kB]
Des:2 http://archive.ubuntu.com/ubuntu/ lucid/restricted Translation-es [2779B]
Des:3 http://archive.ubuntu.com/ubuntu/ lucid/universe Translation-es [1393kB]
Obj http://archive.ubuntu.com lucid-updates Release.gpg
Ign http://archive.ubuntu.com/ubuntu/ lucid-updates/main Translation-es
Ign http://archive.ubuntu.com/ubuntu/ lucid-updates/restricted Translation-es
Ign http://archive.ubuntu.com/ubuntu/ lucid-updates/universe Translation-es
Obj http://archive.ubuntu.com lucid-security Release.gpg
Ign http://archive.ubuntu.com/ubuntu/ lucid-security/main Translation-es
Ign http://archive.ubuntu.com/ubuntu/ lucid-security/restricted Translation-es
Ign http://archive.ubuntu.com/ubuntu/ lucid-security/universe Translation-es
Obj http://archive.ubuntu.com lucid Release
Obj http://archive.ubuntu.com lucid-updates Release
Obj http://archive.ubuntu.com lucid-security Release
Obj http://archive.ubuntu.com lucid/main Packages
Obj http://archive.ubuntu.com lucid/restricted Packages
Obj http://archive.ubuntu.com lucid/universe Packages
Obj http://archive.ubuntu.com lucid-updates/main Packages
Obj http://archive.ubuntu.com lucid-updates/restricted Packages
Obj http://archive.ubuntu.com lucid-updates/universe Packages
Obj http://archive.ubuntu.com lucid-security/main Packages
Obj http://archive.ubuntu.com lucid-security/restricted Packages
Obj http://archive.ubuntu.com lucid-security/universe Packages
Descargados 2054kB en 7s (293kB/s)
Leyendo lista de paquetes... Hecho
root@equipo100:~#