Xorg resolution on a Xen guest (domU)

  • english
  • spanish

When installing a Linux system as a Xen guest on a domU and activating the VNC access, hopefully everything runs fine except that you can’t change the resolution. No matter what you do (through the GUI, editing the xorg.conf file) it seems all it can do is 800×600.

After googling for a solution I stumbled upon this post which commented on a new extra=”xenfb.videomem=5,1024 “ option for dealing with guest video RAM (and thus, supported resolutions). But it didn’t worked out. Digging deeper on this approach I realized this “extra” Xen configuration was used for passing extra parameters to the guest’s kernel, so this “xenfb” should be a module on the guest OS. Then I looked for *xen* modules on my Ubuntu guest and found “xen-fbfront”:

$ modinfo xen-fbfront
filename:       /lib/modules/2.6.35-24-generic/kernel/drivers/video/xen-fbfront.ko
alias:          xen:vfb
license:        GPL
description:    Xen virtual framebuffer device frontend
srcversion:     0EB34742ACF8D2559403034
depends:        fb_sys_fops,syscopyarea,sysfillrect,sysimgblt
vermagic:       2.6.35-24-generic SMP mod_unload modversions
parm:           video:Video memory size in MB, width, height in pixels (default 2,800,600) (array of int)

So it looks like the module and the option got renamed along the way. Tried it, and it worked!

So, all in all, what you need to add is this line to your domU config file (/etc/xenDOMAIN.conf) on the dom0, adjusting memory and resolution parameters at will:

extra="xen_fbfront.video=4,1024,768 "

kpartx: Mounting the partitions in a disk image file

  • english
  • spanish

Sometimes it is useful to mount the partitions in a disk image file, e.g. from a backup (or dd) or a virtual machine, without having to use that backup or VM software. These files are usually a 1:1 copy of what should be on an actual disk, so the internal partition table format is the same the operating system would use on a disk and also the format of the partitions themselves are ext2/3/FAT/whatever. So the system should be able to use them, the only problem is that neither this image file nor its partitions are mapped to proper block device files in /dev.

Enter kpartx, a small utility that analyzes a disk image file, detects the partitions in it and creates device files for each partition, so that they can be mounted as if they were real partitions on a physical disk. Usage is very simple: just pass the file to it and kpartx shows the partition table. Add the -a parameter to that and kpartx creates the device files; -d and it deletes them. mount.

Kudos to this page where I learnt about kpartx, and which by the way explains a way to manually map the partitions using the loopback interface. 

Ajustar la hora en servidores Amazon EC2

  • english
  • spanish

Amazon EC2 virtual servers’ internal clock is synchronized with that of their host server. But some host servers seems to be off-date: I’m working on a four-server cluster (will grow to eight when we go into production) and while three of them were perfectly synchronized, the fourth one lagged behind a couple of minutes.

By default you can’t adjust the date with either date nor ntp, the commands execute but do nothing. In order to decouple the VM’s clock from the host’s one and being able to set the time on your system you need to run the following command:

echo 1 > /proc/sys/xen/independent_wallclock

Bear in mind that, as pointed out here, after decoupling your clock from the host’s you can’t go back, you’ll be on your own forever.

Android rooteado

Creo que por aquí no he llegado a comentarlo, pero hace unos meses me pillé un HTC Magic de Vodafone, si, un móvil con Android. Al final he picado, yo que nunca me he llevado bien con los móviles y de hecho hasta entonces tenía el más sencillo que había encontrado en la tienda. :-)

El bicho es una pasada, todo lo que siempre prometieron las PDA pero en mi opinión nunca llegaron a cumplir. Hace un tiempo ya publiqué un artículo sobre mi opinión de todos estos dispositivos, que creo que están más cerca de los ordenadores (prácticamente en la liga de los netbooks) que de las PDA de antaño. Echando la vista atrás al final el iPod Touch se me quedaba pequeño para todo lo que quería hacer, sin Internet un chisme de estos no deja de ser una PDA muy avanzada; con Internet … ¿un pocket-netbook? Y con una gran ventaja si usáis todos los productos de Google (GMail con sus contactos, Calendar, etc.): sincronización automática, :-) uno de los mayores quebraderos de cabeza con cualquier teléfono o PDA resuelto de un plumazo.

El caso es que ayer me decidí a “rootearlo”. En el caso de los Android no lo veo tan necesario como con los iPhones/iPods Touch, el Market de Android es mucho más abierto que la AppStore de Apple pero aún así hay aplicaciones (aceptadas en Market) que necesitan root, la única limitación que tienes con el firmware original. Además de que quería probar algunas de las características de Hero y Donut que llevan las ROMs “cocinadas”, como p.ej. el multitouch. :-)

El proceso en estos momentos es lo más sencillo del mundo: la semana pasada se descubrió un bug en todos los kernels 2.4 y 2.6 de Linux que permite un escalado de privilegios local, y pronto un tipo desarrolló una aplicación para, con un solo click, ejecutarla y conseguir acceso total al sistema operativo del teléfono. Ya no hace falta instalar la SDK, ni andar con cables y consolas de desarrollo. Eso si, es de suponer que en breve las operadoras actualizarán el software de los teléfonos con el parche que corrige este agujero de seguridad, con lo que me dije “ahora o nunca”. Es el momento antes de que con la próxima actualización ya no se pueda rootear tan fácil y haya que volver al método tradicional.

No voy a explicar el proceso porque en El Androide Libre se han currado un tutorial la mar de sencillo para rootear e instalar la ROM de Cyanogen, que por supuesto ya lleva parcheado el bug. Sólo algunos detalles:

  • momento de pánico: al primer intento el móvil se me quedó frito en el arranque después de la actualización. Solución: en el menú del “Recovery Mode” (arrancar con encendido y casita, es una especie de “lilo” que en el 1er paso del rooteo se sustituye por otro más avanzado que permite hacer backups e instalar las ROMs) hacer un wipe antes de instalar. Acojona. :-)
  • se puede volver al firmware original de Vodafone y el móvil queda como si no hubiéramos hecho nada, para eso el paso del  ”Nandroid backup”. De hecho después de la petada hice esto para recuperar un par de puntos de cordura antes de volver a intentar el proceso (previo wipe).
  • tras la instalación el nuevo sistema no está completamente traducido al español, lo típico de cualquier aplicación de Linux, que con la nueva versión no se ha actualizado el .po de gettext y alguna que otra frase sale en inglés.
  • también se pierde la configuración de los APN de Vodafone, con lo que nada más arrancar no hay acceso a Internet (p.ej. el registro de la cuenta de Google falla). La configuración hay que hacerla a mano, datos aquí (si, si, pone Airtel).
  • y parece que se pierde también la configuración de todas las aplicaciones, a pesar de que guardé y luego restauré aplicaciones y datos con el MyBackup. :-/ La configuración del sistema si que la restaura, pero la de las aplicaciones no. :-(

Aparte de eso … como la seda. Aún no le he metido caña con lo que p.ej. lo de que la batería aguanta más no lo he podido comprobar. Pero si que funciona el multitouch (en el navegador se puede hacer zoom “pinchando” como en el iPhone), y si que da la impresión de que todo va más rápido, más fluido. No en vano la Cyanogen se originó en el Dream, con menos memoria que el Magic, así que si está optimizada para funcionar con un dispositivo menos cañero con éste va de lujo.

Ahora a meterle caña al juguete. :-)

Segundo monitor en el Lenovo T400 con Jaunty

  • english
  • spanish

A couple of weeks ago I upgraded the laptop I use at work to Jaunty, and since then I couldn’t get the external monitor to work properly.

This laptop has two graphic cards: an Intel one integrated on the mainboard, which uses few battery power; and an ATI one with all the bells and whistles, which of course takes more battery. On Windows the graphic driver can change from one to the other on the fly, but on Linux you can’t. You need to go to the BIOS and select one, disabling the other one.

So since I upgraded to Ubuntu 9.04, I the Intel card (which is the one I always use, I use this laptop for work only so I’d rather have half an hour of extra battery than ultra-fast OpenGL… heck, I even have compiz disabled) wouldn’t even boot, X hanged while booting when using that card. And with the ATI card and the fglrx driver, getting the external monitor to work is a PITA. And I need it, as from time to time I give presentations and training sessions and need to hook the laptop to a projector.

I finally found the solution on a Ubuntu forum somewhere (lost the link, sorry): uninstall the fglrx driver! Even if I didn’t use it, even if the ATI card was disabled on the BIOS (wouldn’t even show on lspci) and on the xorg.conf file was using the Intel driver and not the fglrx one, if this driver was installed X would crash when using the Intel card. Uninstall it and voila! The Intel card works again and so does the external monitor configuration applet. Weird.

Ubuntu 9.04 en un Lenovo T400

Un par de URLs útiles para acabar de configurar y optimizar el sistema en un Lenovo T400:

Destacar en el 1er enlace por el final, la guía para configurar el aparcado automático de los cabezales del disco duro en función de si el acelerómetro detecta movimiento (APS), al estilo de lo que llevan los MacBook Pro. ¡Funciona!

Seguridad "presencial" con Bluetooth en Linux

Estoy aprovechando estos días para “maquear” un portátil nuevo que me han dado en el curro, y he dado con un programa curioso: blueproximity.

¿Cuántas veces os habéis levantado de delante del ordenador sin bloquear la pantalla y algún compañero gracioso os ha gastado alguna jugarreta (enviar un mail con vuestra cuenta expresando vuestro amor incondicional por el resto de la plantilla, definir un alias ls=”rm -ri /”, o algo así)? ¿O estando en un cliente, se ha quedado información sensible en la pantalla mientras habéis ido a por el café? A mi ya me han gastado más de una de estas con lo que ya tengo el hábito de antes de levantarme, bloquear yo la pantalla. Sin embargo una solución automática no está de más.

La idea detrás de blueproximity es sencilla: bloquear automáticamente la pantalla si no estáis cerca, emparejándose con un dispositivo bluetooth (vuestro móvil) y en función de su proximidad activar o desactivar el salvapantallas. Simple y efectivo. Ahora el problema es si os olvidáis de coger el móvil al bajar a por el café. XD

CrossOver de gratis y otras ¿apuestas? ¿o marketing?

CodeWeavers, los creadores de CrossOver, una versión comercial de Wine que permite ejecutar aplicaciones y juegos nativos de Windows en Linux y MacOS X hicieron una apuesta hace unas semanas: si el precio de la gasolina bajaba de cierto límite, durante un día iban a dar licencias gratis de su software. El precio ha bajado y ese día es hoy. El software se puede bajar de aquí y pedir la licencia aquí, que debido a la sobrecarga de los servidores no se podrá activar hasta mañana (y por lo visto, sólo mañana).

Yo la verdad este tipo de emuladores al final sólo los uso para poder ejecutar Internet Explorer en el Mac y probar cómo se ve alguna web o acceder a otra que le pegue una patada a los estándares y no funcione correctamente con otros navegadores. Y a pesar de que IE se puede instalar también con la versión libre de Darwine e incluso un tío se curró un script para automatizarlo, CrossOver está bastante más pulido y toda la instalación es más simplona, click-click-click y ya tienes el Explorer (o el Word, o el Acrobat, o …) en Mac.

Y esto me recuerda a esa empresa de refrescos que apostó que si Guns N’ Roses cumplía la fecha de noviembre de 2008 para el lanzamiento de su nuevo disco iba a regalar un refresco a cada estadounidense. ¿Qué es ésto? ¿Una nueva forma de márqueting viral? ¿Una forma de conseguir titulares (y entradas en blogs ;-D) de forma gratuita? El tema con CodeWeavers lo veo claro, total es la discusión de siempre, copiar un software no cuesta NADA y menos si se distribuye a través de Internet con lo que no hay un soporte físico, así que dar el software, durante un día… tal vez sirve para hinchar los números de usuarios reales, o para hacerse una idea de los usuairos que realmente tienen (¿cuántos que tienen CrossOver pirata lo “legalizarán” hoy?). Sin embargo los de los refrescos si que van a tener que dar las latas, una a una. Ahí si que hay un gasto. ¿Realmente se esperaban que Axl y compañía cumplieran, o les ha salido el tiro por la culata? Aunque aún está por ver que el disco salga a tiempo, que después de 15 años a ver quién se fia ahora. ;-)

exec

  • english
  • spanish

exec is a built-in shell command that forces a binary to be executed by the currently running shell process instead of forking the process and running the binary on that child process.

When you run a command on a shell-script, it forks a child process and runs the command there. On a syscall level this is the classic:

if( (pid=fork()) == 0) { exec(command); exit(); } wait();

And this is usually what we want, because we will keep running commands after that one. Nevertheless, sometimes this is a problem, like when:

  • we have a program that’s going to monitor a given process, and it doesn’t run properly if there’s an intermediate shell process but we need to run this second process via a shel-script for whatever reasons (to initialize some variables, run the program with nice, whatever)
  • on MacOS we’re running a program via a shell-script and get two icons on the dock, one for the shell and another one for the program

Running a command with exec forces the shell not to fork, but to run the command directly over the shell process. An important thing to note here is that the shell-script will end there, no further commands of the shell script will be executed as the shell process will be substituted by the command process, so to speak.

#!/bin/sh # initialize variables, parse command-line parameters, etc. export IP=$1 exec nice command $*

Mi nuevo servidor

  • english
  • spanish

Ladies and gentleman, let me please introduce you to my new server, the one I’ve been blogging about lately:

dscf0042.JPG dscf0044.JPG

What? You don’t see it? Yes! The small grey box on top of the iomega disk, slightly bigger than the Fonera

In case you don’t know it yet, it’s a Linksys NSLU2, a small device around $100 that comes with two USB2 ports and an ethernet connection. Plug an external USB hard drive to it and it’ll become available over the network like a NAS share. And the best part is: you can flash its firmware and install Debian!! :-D

It’s not that powerful, it has an XScale (ARM) processor at 266Mhz and only 32Mb of RAM. There are pages explaining how to install up to 256Mb. Nevertheless, it works and is small, doesn’t make noise, and has a small electrical consumption.

Up to now I’m running the following on it and it works quite well:

top-nslu2.png

# cat /proc/cpuinfo Processor : XScale-IXP42x Family rev 2 (v5l) BogoMIPS : 266.24 Features : swp half fastmult edsp CPU implementer : 0x69 CPU architecture: 5TE CPU variant : 0x0 CPU part : 0x41f CPU revision : 2 Cache type : undefined 5 Cache clean : undefined 5 Cache lockdown : undefined 5 Cache format : Harvard I size : 32768 I assoc : 32 I line length : 32 I sets : 32 D size : 32768 D assoc : 32 D line length : 32 D sets : 32 Hardware : Linksys NSLU2 Revision : 0000 Serial : 0000000000000000 # free total used free shared buffers cached Mem: 29988 28988 1000 0 404 4808 -/+ buffers/cache: 23776 6212 Swap: 979924 41164 938760 # uname -a Linux eliza 2.6.18-6-ixp4xx #1 Tue Feb 12 00:57:53 UTC 2008 armv5tel GNU/Linux # pstree init-+-afpd---afpd |-atalkd |-atd |-avahi-daemon---avahi-daemon |-cnid_metad |-cron |-dbus-daemon |-events/0 |-getty |-khelper |-klogd |-ksoftirqd/0 |-kthread-+-aio/0 | |-kblockd/0 | |-khubd | |-3*[kjournald] | |-kmirrord | |-kpsmoused | |-kseriod | |-kswapd0 | |-2*[pdflush] | |-scsi_eh_0 | `-usb-storage |-mtdblockd |-nmbd |-papd |-portmap |-rpc.statd |-slpd |-smbd---smbd |-sshd---sshd---sshd---bash---su---bash---pstree |-svscanboot-+-readproctitle | `-svscan-+-supervise---dnscache | |-3*[supervise---multilog] | |-supervise---tinydns | `-supervise---mlnet---mlnet---mlnet |-syslogd `-udevd