Inicio   defunct.gatopelao.org(Terminales / Xen / freeNX / etc)
agenda(1)  barrufet(3)  debian(1)  linux(1)  network(2)  rediris(2)  statusnet(3)  storage(2)  xen(4)  xmpp(1)  
weblog gatopelao

Mon, 08 Mar 2010

xen.img a qemu.img

Cuatro pasos para convertir una imagen xen a qemu.
http://fraise.co.nz/node/7


Mira cuanto disco necesitas y crear una nueva imagen QEMU.

qemu-img create /vserver/myroot.img -f raw 10G

Busca una liveCD, prueba http://rip.7bf.de/current/ (sin las X)
y botalo.
kvm -m 256 -cdrom /dev/cdrom -boot d myroot.img
Usando fdisk o cfdisk, crear las particiones que necesitas ( / y swap).
Usa partprobe y formatea las particiones.
Apagala.

Busca el offset del inicio del particion del raiz. Mira la columna 'start' y copia el numero. eg. 208845
fdisk -lu myroot.img

Monta la particion raiz de la imagen qemu.
mkdir -p /vserver/qemuroot
mount -o loop,offset=$(( 208845 * 512 )) -t auto myroot.img /vserver/qemuroot
Monta la imagen xen.
mkdir -p /vserver/xenimage
mount -o loop xen.domU.img /vserver/xenimage

Copia todo desde la imagen xen hasta la raiz de la imagen qemu
cp -a /vserver/xenimage /vserver/qemuroot
umount /vserver/xenimage


Install kernel, modules y configurar tus cosas.
chroot qemuroot
apt-get install linux-image
vim /etc/network/interfaces /etc/fstab /boot/grub/menu.lst
exit
umount /vserver/qemuroot

Para instalar grub en la raiz (hda1) arranco de nuevo desde el liveCD.
kvm -m 256 -cdrom /dev/cdrom -boot d myroot.img

mount /dev/hda1 /mnt
echo '(hd0) /dev/hda1' > /mnt/boot/grub/device.map
grub
grub> find /boot/grub/stage1
grub> root (hd0,0)
grub> setup (hd0)
quit
halt

Montar la red
http://www.thomaskho.com/blog/2006/02/qemu-and-the-network-bridge/

Botar la imagen qemu.

kvm -m 256 -net nic -net tap /vserver/myroot.img

[/xen] permanent link


Mon, 18 Jan 2010

Hardware viejo, router nuevo

Desde el año 2003 tengo un router pentium II, 128MB, corriendo floppyfw http://www.zelow.no/floppyfw/
El hardware era un viejo HP Vectra que destripé y monté en una bandeja para poder enrackarlo.
Ha funcionado estos 7 años 24/7 sin darme problema ninguna. Ha llegado a tener una configuración bastante compleja (para mi), enrutando entre varias redes, sub redes, tunel ipip,  enrutamiento por parametros de origen, NAT, etc.

Ahora doy de baja el sistema operativo floppyfw por instalarlo un Debian en un compact flash para así poder añadirle más software y facilitarme la gestión.
iptraf, iftop, sshd, dnsmasq, postfix, etc, son herramientas muy útiles.
Sobre todo lo hago para poder incluir este router en la esquema de fwbuilder http://www.fwbuilder.org/ que empleo para gestionar los demás routers que administro.

Para poder usar un compact flash, he comprado un adaptador CF a IDE y hago un debian netinst normal sin instalarle nada demás.
La instalación ocupa:
/dev/hda2             3.3G  343M  2.8G  11% /
/dev/hda1             185M   17M  160M  10% /boot

Seguramente un RAID1 hubiera sido una buena opción, pero no pensé en ello y solo compré un adaptador de un slot cuando podía haberme comprado un adaptador de dos slots para así tener dos CFs (master y slave).

Pero ya está comprado.. y ahora, por si un día falle el CF, he hecho una copia del sistema operativo en un segundo CF más o menos así.

Boto el router desde un live CD (sin las X).  http://rip.7bf.de/current/

mount un_nfs_server:/un_dir /tmp/remote
sfdisk -d /dev/hda > /tmp/remote/hda.sfdisk
mount /dev/hda1 /tmp/local
cp -r /tmp/local /tmp/remote/

Apago el router, cambio el CF por la unidad de respaldo, y boto de nuevo desde el live CD.
mount un_nfs_server:/un_dir /tmp/remote
sfdisk /dev/hda < /tmp/remote/hda.sfdisk
partprobe
mkfs.ext3 /dev/hda1
mount /dev/hda1 /tmp/local
cp -r /tmp/remote/* /tmp/local/

Y despues hacerlo botable con grub.
echo ′(hd0) /dev/hda1′ > /tmp/local/boot/grub/device.map
grub
grub> find /boot/grub/stage1
grub> root (hd0,0)
grub> setup (hd0)

Supongo que un dd hubiera sido más elegante.

Y bueno, ahora toca crear las reglas con fwbuilder. :)

[/network] permanent link


Mon, 14 Dec 2009

CF DMA
Como desactivar DMA de un CF al botar.

Estoy montando una cortafuegos. Para que mejore la disponiblidad del equipo monto un raid1.
Los dos discos son uno (hda) de 80GB y un compact flash (hdd) de 8 GB.

/            = 8GB (raid1)
/home   = espacio restante del hda


El problema que tengo es que el hardware no me da la funcionalidad DMA del CF.
Linux, al botar se da cuenta y lo desactiva.

syslog:Dec 11 11:38:53 debian kernel: [    6.888186] hdd: TRANSCEND, ATA DISK drive
syslog:Dec 11 11:38:53 debian kernel: [    6.944128] hdd: host max PIO4 wanted PIO255(auto-tune) selected PIO4
syslog:Dec 11 11:38:53 debian kernel: [    6.944254] hdd: UDMA/66 mode selected
syslog:Dec 11 11:38:53 debian kernel: [    7.756362] hdd: max request size: 128KiB
syslog:Dec 11 11:38:53 debian kernel: [    7.756362] hdd: 15662304 sectors (8019 MB) w/1KiB Cache, CHS=15538/16/63
syslog:Dec 11 11:38:53 debian kernel: [    7.756362]  hdd:hdd: dma_intr: status=0x00 { }
syslog:Dec 11 11:38:53 debian kernel: [   18.053566] hdd: status error: status=0x00 { }
syslog:Dec 11 11:38:53 debian kernel: [   18.053566] hdd: drive not ready for command
syslog:Dec 11 11:38:53 debian kernel: [   27.392935] hdd: dma_intr: status=0x00 { }
syslog:Dec 11 11:38:53 debian kernel: [   27.912064] hdd: status error: status=0x00 { }
syslog:Dec 11 11:38:53 debian kernel: [   27.912064] hdd: DMA disabled
syslog:Dec 11 11:38:53 debian kernel: [   27.912064] hdd: drive not ready for command

Apartir de allí, se puede usar el CF, pero el RAID ya se ha degradado.

syslog:Dec 11 11:38:53 debian kernel: [   28.377689]  hdd1
syslog:Dec 11 11:38:53 debian kernel: [   29.458417] md: bind<hdd1>
syslog:Dec 11 11:38:53 debian kernel: [   29.468013] md: kicking non-fresh hdd1 from array!
syslog:Dec 11 11:38:53 debian kernel: [   29.468013] md: unbind<hdd1>
syslog:Dec 11 11:38:53 debian kernel: [   29.468013] md: export_rdev(hdd1)

Aunque puedo reconstruir el array, cada vez que bote la máquina se degrada de nuevo..
Entonces hay que desactivar el DMA de /dev/hdd antes de que mdadm intente montar el RAID.

Por internet se lee que se puede desactivar DMA desde grub añadiendo 'ide=nodma' como opción del kernel.
En mi caso no funciona porque ide-core no está en el kerenl sino se carga como módulo.

http://forums.debian.net/viewtopic.php?f=10&t=32860&start=15

Paso la opciones al modulo y creo de nuevo el initramfs.

echo 'options ide_core options="hdd=nodma"' > /etc/modprobe.d/ide
update-initramfs -u

Y funciona.

[/storage] permanent link


Wed, 09 Dec 2009

xmpp bot

Llevaba demasiado tiempo con ganas de programar un bot. Ahora que ha salido una razon para hacerlo, me he puesto.

Tenemos un servidor jabber y todos lo usamos mucho desde hace ya unos cuantos años. Ultimamente la gente me ha pedido una manera de enviar un mensaje a un grupo de personas. Los chat rooms son incomodas porque tienes que ir al propósito a la sala para participar. Necesitamos un mecanismo para enviar a la broadcast.

Todos los usuarios y los grupos de usuarios están definidos en un LDAP. El servidor jabber también usa LDAP para saber y autentificar los usuarios.
El bot consulta LDAP para saber los miembros de cada grupo.

La funcionalidad es básica. Con escribirle 'help' al bot nos contesta:

Puedo enviar tus mensajes a un grupo de usuarios. Para saber cuales son tus grupos teclea:
grupos

Para saber los usuarios que pertenecen a un grupo teclea
'users' seguido por el nombre del grupo ej:
users nombre_de_grupo

Para enviar un mensaje a un grupo, empieza el mensaje por el nombre del grupo. ej:
nombre_de_grupo Lunes de nuevo, que palo.

Está programado en python.

He usado la librería xmpppy y no ha sido nada dificil.

Lo único que me ha faltado del ejemplo bot.py es que el bot aceptase subscripciones automáticamente. He encontrado la respuesta en http://grumplicio.us/nihongobot.py

def presenceCB(conn,pres):
    type=pres.getType()
    user=pres.getFrom()
    if type=='subscribe':
        conn.send(xmpp.Presence(user,'subscribed'))
    if type=='unsubscribe':
        conn.send(xmpp.Presence(user,'unsubscribed'))
y lo registramos
conn.RegisterHandler('presence',presenceCB)

Para que los usuarios puedan identificar los grupos con más facilidad, se colora con XHTML
def addColor(message,groupname):
        color=ldapcache.getGroupColor(groupname)
        html_tag="<span style='background: %s;'>%s</span>" % (color,groupname)
        text= message.getBody()

        markedup=replace(text, groupname, html_tag, 1)
        markedup=markedup.encode('utf-8')
        payload=xmpp.simplexml.XML2Node('<body xmlns="%s">%s</body>' %  (XML_NAMESPACE, markedup))
        message.addChild('html', {}, [payload], xmpp.NS_XHTML_IM)

Tengo un pequeño classe que cachea los resultados del LDAP. Para trabajar con LDAP empleo ldaphelper.py que me ayuda a cargar el objeto ldapcache.

El código está aquí.

[/xmpp] permanent link


Thu, 03 Dec 2009

climategate

Un hacker (o alguien de dentro) entró en los servicios informáticos del Climate Research Unit, University of East Anglia, 'robó' miles de correos y documentos, y los publicó en la red.

Parece que la ciencia está al servicio de la empresa que, en este caso, se esconde detrás de la IPCC. La modificación, ocultación, y supresión de datos apoyan los politicos/multinacionales para adelantar su agenda y el programa capitalista 'cap and trade'.

Que pena me da. No especiamente porque vemos de nuevo manipulación y mentiras, sino porque este asunto se manipulará para servir como otra escusa para no cuidar nuestro planeta.


pollution


From Michael E. Mann (retención de información / data):

Dear Phil and Gabi,
I’ve attached a cleaned-up and commented version of the matlab code that I wrote for doing the Mann and Jones (2003) composites. I did this knowing that Phil and I are likely to have to respond to more crap criticisms from the idiots in the near future, so best to clean up the code and provide to some of my close colleagues in case they want to test it, etc. Please feel free to use this code for your own internal purposes, but don’t pass it along where it may get into the hands of the wrong people.


From Nick McKay (modificando data):

The Korttajarvi record was oriented in the reconstruction in the way that McIntyre said. I took a look at the original reference – the temperature proxy we looked at is x-ray density, which the author interprets to be inversely related to temperature. We had higher values as warmer in the reconstruction, so it looks to me like we got it wrong, unless we decided to reinterpret the record which I don’t remember. Darrell, does this sound right to you?


From Phil Jones (modificación de data para ocultar resultados):

I’ve just completed Mike’s Nature trick of adding in the real temps to each series for the last 20 years (ie from 1981 onwards) amd from 1961 for Keith’s to hide the decline.


From Kevin Trenberth (failure of computer models):

The fact is that we can’t account for the lack of warming at the moment and it is a travesty that we can’t. The CERES data published in the August BAMS 09 supplement on 2008 shows there should be even more warming: but the data are surely wrong. Our observing system is inadequate.

From Michael Mann (la verdad no importa):


Perhaps we'll do a simple update to  the Yamal post, e.g. linking Keith/s new page--Gavin t?  As to the issues of robustness, particularly w.r.t. inclusion of the Yamal series, we  actually emphasized that (including the Osborn and Briffa '06 sensitivity test) in our  original post! As we all know, this isn't about truth at all, its about plausibly deniable accusations.

From Phil Jones (retención de información):

The skeptics seem to be building up a head of steam here! ...  The IPCC comes in for a lot of stick. Leave it to you to delete as appropriate! Cheers Phil
PS I’m getting hassled by a couple of people to release the CRU station temperature data. Don’t any of you three tell anybody that the UK has a Freedom of Information Act ! 

From Phil Jones (retención de información):

If FOIA does ever get used by anyone, there is also IPR to consider as well. Data is covered by all the agreements we sign with people, so I will be hiding behind them.


Puedes bajar el archivo aquí: http://www.filedropper.com/foi2009

[/agenda] permanent link


Fri, 27 Nov 2009

Santiago

I've just got back from the JJTT irislibre in Santiago de Compostela.
I went because our coordinator cannot continue in the position and someone needed to be there. And that 'someone' well, it's me.

It has to be the worst JT that I have attended so far. Only three of us were there, but there were however 30 people present. That makes 28 people present who were interested (to some degree), but had no idea of our work to date or our future plans.

I didn't go to make a presentation to strangers but to work with our group.

So, where does this leave us? I don't know. We've had a really bad year with almost no contribution and I (and others) begin to question our 'designated' purpose.

The whole free software movement en the spainsh universities is taking a nasty turn. While the individual groups are working well, we have not achieved (in most cases) any respect or consideration from the instituion. Personal intereses impede the grass root changes I believe in. Universities outsource to 'open source' sales people. These are all bad signs for us.
I fear that if these trends continue, we will have lost the opportunity to make _real_ change.

Let's see how the next six months go.

[/rediris] permanent link


Fri, 20 Nov 2009

my-network-bridge

Así xend iniciará dos bridges. En este ejemplo la segunda interfaz es dummy0.

cd /etc/xen/scripts
vim my-network-bridge
#!/bin/bash
case "$1" in
start)
        /etc/xen/scripts/network-bridge start bridge=eth0 netdev=eth0 vifnum=0 antispoof=no
        #/usr/sbin/ethtool -K eth0 tx off
        /etc/xen/scripts/network-bridge start bridge=dummy0 netdev=dummy0 vifnum=1 antispoof=no
        #/usr/sbin/ethtool -K dummy0 tx off
;;
stop)
        /etc/xen/scripts/network-bridge stop bridge=eth0 netdev=eth0 vifnum=0
        /etc/xen/scripts/network-bridge stop bridge=dummy0 netdev=dummy0 vifnum=1
;;
restart)
$0 stop
$0 start
;;
status)
        /etc/xen/scripts/network-bridge status
;;
*)
echo "usage: $0 {start|stop|restart}"
esac
exit 0

cambia los permisos
chmod u+x /etc/xen/scripts/my-network-bridge

y añadelo a xend-config.sxp
vim /etc/xen/xend-config.sxp

#(network-script network-bridge)
(network-script my-network-bridge)

[/xen] permanent link


March.2010(1)   January.2010(1)   December.2009(3)   November.2009(4)   October.2009(11)  
Blog software: Blosxom.com The unofficial Blosxum user group
RSS Feed rss feed