martes, 2 de septiembre de 2014

Fake Raid

Para habilitar el fake raid en Debian GNU/Linux se debe de agregar en el bootloader la opcion dmraid=enable

https://wiki.debian.org/DebianInstaller/SataRaid

Pero al final es más útil y recomendado usar software RAID que el FAKE RAID.

¿Por qué? Si falla el hardware y se mueven los discos, es más fácil y rápido montar un software RAID que un FAKE RAID.

miércoles, 12 de marzo de 2014

Manipulando salidas repetidas del Shell

Alguna vez nos ha pasado que buscamos un error en un log que se repite mas de una vez pero a la vez es variable su contenido, por ejemplo si es correo el error se repite para un mismo correo o mas.

Si deseamos saber las veces totales unicas que el error a aparecido en el servidor es un poco dificil tratar de contarlos, generalmente puede solucionarse con sort y luego con vim eliminar los repetidos de esa salida. Sin embargo es muy rustico.

El comando uniq viene a solventarnos el problema.

Un ejemplo seria lo siguiente:

# grep kernel /var/log/syslog | head -20
Mar 12 08:09:50 myhostname kernel: [345422.277505] hp_wmi: Unknown event_id - 8 - 0x2
Mar 12 10:52:22 myhostname kernel: [355159.298700] CPU2: Core temperature above threshold, cpu clock throttled (total events = 3401)
Mar 12 10:52:22 myhostname kernel: [355159.298705] CPU3: Core temperature above threshold, cpu clock throttled (total events = 3401)
Mar 12 10:52:22 myhostname kernel: [355159.298710] CPU0: Package temperature above threshold, cpu clock throttled (total events = 3464)
Mar 12 10:52:22 myhostname kernel: [355159.298715] CPU1: Package temperature above threshold, cpu clock throttled (total events = 3464)
Mar 12 10:52:22 myhostname kernel: [355159.298720] CPU3: Package temperature above threshold, cpu clock throttled (total events = 3464)
Mar 12 10:52:22 myhostname kernel: [355159.298725] CPU2: Package temperature above threshold, cpu clock throttled (total events = 3464)
Mar 12 10:52:22 myhostname kernel: [355159.299719] CPU0: Package temperature/speed normal
Mar 12 10:52:22 myhostname kernel: [355159.299721] CPU1: Package temperature/speed normal
Mar 12 10:52:22 myhostname kernel: [355159.299725] CPU3: Core temperature/speed normal
Mar 12 10:52:22 myhostname kernel: [355159.299728] CPU2: Core temperature/speed normal
Mar 12 10:52:22 myhostname kernel: [355159.299731] CPU3: Package temperature/speed normal
Mar 12 10:52:22 myhostname kernel: [355159.299734] CPU2: Package temperature/speed normal
Mar 12 10:54:14 myhostname kernel: [355271.844634] [Hardware Error]: Machine check events logged
Mar 12 10:57:43 myhostname kernel: [355480.139160] CPU3: Core temperature above threshold, cpu clock throttled (total events = 3481)
Mar 12 10:57:43 myhostname kernel: [355480.139165] CPU2: Core temperature above threshold, cpu clock throttled (total events = 3481)
Mar 12 10:57:43 myhostname kernel: [355480.139170] CPU1: Package temperature above threshold, cpu clock throttled (total events = 3544)
Mar 12 10:57:43 myhostname kernel: [355480.139176] CPU0: Package temperature above threshold, cpu clock throttled (total events = 3544)
Mar 12 10:57:43 myhostname kernel: [355480.139180] CPU2: Package temperature above threshold, cpu clock throttled (total events = 3544)
Mar 12 10:57:43 myhostname kernel: [355480.139185] CPU3: Package temperature above threshold, cpu clock throttled (total events = 3544)

El problema es que los 6 primeros campos nos son inutiles por lo tanto tendremos que eliminarlos, transformando la consulta a algo mas util:

# grep kernel /var/log/syslog | awk -F"] " '{print $2}'| head -20
hp_wmi: Unknown event_id - 8 - 0x2
CPU2: Core temperature above threshold, cpu clock throttled (total events = 3401)
CPU3: Core temperature above threshold, cpu clock throttled (total events = 3401)
CPU0: Package temperature above threshold, cpu clock throttled (total events = 3464)
CPU1: Package temperature above threshold, cpu clock throttled (total events = 3464)
CPU3: Package temperature above threshold, cpu clock throttled (total events = 3464)
CPU2: Package temperature above threshold, cpu clock throttled (total events = 3464)
CPU0: Package temperature/speed normal
CPU1: Package temperature/speed normal
CPU3: Core temperature/speed normal
CPU2: Core temperature/speed normal
CPU3: Package temperature/speed normal
CPU2: Package temperature/speed normal
[Hardware Error]: Machine check events logged
CPU3: Core temperature above threshold, cpu clock throttled (total events = 3481)
CPU2: Core temperature above threshold, cpu clock throttled (total events = 3481)
CPU1: Package temperature above threshold, cpu clock throttled (total events = 3544)
CPU0: Package temperature above threshold, cpu clock throttled (total events = 3544)
CPU2: Package temperature above threshold, cpu clock throttled (total events = 3544)
CPU3: Package temperature above threshold, cpu clock throttled (total events = 3544)

Agregando el comando sort ordenamos todas las salidas y como veremos es mas sencillo encontrar unificados los problemas y nuestra tarea seria descartar los repetidos:

# grep kernel /var/log/syslog | awk -F"] " '{print $2}'| sort | head -40
CPU0: Package temperature above threshold, cpu clock throttled (total events = 12688)
CPU0: Package temperature above threshold, cpu clock throttled (total events = 12689)
CPU0: Package temperature above threshold, cpu clock throttled (total events = 29267)
CPU0: Package temperature above threshold, cpu clock throttled (total events = 3464)
CPU0: Package temperature above threshold, cpu clock throttled (total events = 3544)
CPU0: Package temperature above threshold, cpu clock throttled (total events = 4977)
CPU0: Package temperature above threshold, cpu clock throttled (total events = 6992)
CPU0: Package temperature above threshold, cpu clock throttled (total events = 8079)
CPU0: Package temperature/speed normal
CPU0: Package temperature/speed normal
CPU0: Package temperature/speed normal
CPU0: Package temperature/speed normal
CPU0: Package temperature/speed normal
CPU0: Package temperature/speed normal
CPU0: Package temperature/speed normal
CPU0: Package temperature/speed normal
CPU0: Package temperature/speed normal
CPU1: Package temperature above threshold, cpu clock throttled (total events = 12688)
CPU1: Package temperature above threshold, cpu clock throttled (total events = 12689)
CPU1: Package temperature above threshold, cpu clock throttled (total events = 29267)
CPU1: Package temperature above threshold, cpu clock throttled (total events = 3464)
CPU1: Package temperature above threshold, cpu clock throttled (total events = 3544)
CPU1: Package temperature above threshold, cpu clock throttled (total events = 4977)
CPU1: Package temperature above threshold, cpu clock throttled (total events = 6992)
CPU1: Package temperature above threshold, cpu clock throttled (total events = 8079)
CPU1: Package temperature/speed normal
CPU1: Package temperature/speed normal
CPU1: Package temperature/speed normal
CPU1: Package temperature/speed normal
CPU1: Package temperature/speed normal
CPU1: Package temperature/speed normal
CPU1: Package temperature/speed normal
CPU1: Package temperature/speed normal
CPU1: Package temperature/speed normal
CPU2: Core temperature above threshold, cpu clock throttled (total events = 12160)
CPU2: Core temperature above threshold, cpu clock throttled (total events = 12161)
CPU2: Core temperature above threshold, cpu clock throttled (total events = 26206)
CPU2: Core temperature above threshold, cpu clock throttled (total events = 3401)
CPU2: Core temperature above threshold, cpu clock throttled (total events = 3481)
CPU2: Core temperature above threshold, cpu clock throttled (total events = 4571)


Para facilitar la tarea usaremos el comando uniq a la salida:

# grep kernel /var/log/syslog | awk -F"] " '{print $2}'| sort | head -40 | uniq -c
      1 CPU0: Package temperature above threshold, cpu clock throttled (total events = 12688)
      1 CPU0: Package temperature above threshold, cpu clock throttled (total events = 12689)
      1 CPU0: Package temperature above threshold, cpu clock throttled (total events = 29267)
      1 CPU0: Package temperature above threshold, cpu clock throttled (total events = 3464)
      1 CPU0: Package temperature above threshold, cpu clock throttled (total events = 3544)
      1 CPU0: Package temperature above threshold, cpu clock throttled (total events = 4977)
      1 CPU0: Package temperature above threshold, cpu clock throttled (total events = 6992)
      1 CPU0: Package temperature above threshold, cpu clock throttled (total events = 8079)
      9 CPU0: Package temperature/speed normal
      1 CPU1: Package temperature above threshold, cpu clock throttled (total events = 12688)
      1 CPU1: Package temperature above threshold, cpu clock throttled (total events = 12689)
      1 CPU1: Package temperature above threshold, cpu clock throttled (total events = 29267)
      1 CPU1: Package temperature above threshold, cpu clock throttled (total events = 3464)
      1 CPU1: Package temperature above threshold, cpu clock throttled (total events = 3544)
      1 CPU1: Package temperature above threshold, cpu clock throttled (total events = 4977)
      1 CPU1: Package temperature above threshold, cpu clock throttled (total events = 6992)
      1 CPU1: Package temperature above threshold, cpu clock throttled (total events = 8079)
      9 CPU1: Package temperature/speed normal
      1 CPU2: Core temperature above threshold, cpu clock throttled (total events = 12160)
      1 CPU2: Core temperature above threshold, cpu clock throttled (total events = 12161)
      1 CPU2: Core temperature above threshold, cpu clock throttled (total events = 26206)
      1 CPU2: Core temperature above threshold, cpu clock throttled (total events = 3401)
      1 CPU2: Core temperature above threshold, cpu clock throttled (total events = 3481)
      1 CPU2: Core temperature above threshold, cpu clock throttled (total events = 4571)

Como vemos ahora es mas sencillo observar los errores, para nuestro ejemplo unifique la salida de los primeros 40, pero tambien podemos unificar la salida de todo el registro y luego mostrar los primeros 40 resultados, veremos que la salida varia un poco y es mas agradable:

# grep kernel /var/log/syslog | awk -F"] " '{print $2}'| sort | uniq -c | head -40
      1 CPU0: Package temperature above threshold, cpu clock throttled (total events = 12688)
      1 CPU0: Package temperature above threshold, cpu clock throttled (total events = 12689)
      1 CPU0: Package temperature above threshold, cpu clock throttled (total events = 29267)
      1 CPU0: Package temperature above threshold, cpu clock throttled (total events = 3464)
      1 CPU0: Package temperature above threshold, cpu clock throttled (total events = 3544)
      1 CPU0: Package temperature above threshold, cpu clock throttled (total events = 4977)
      1 CPU0: Package temperature above threshold, cpu clock throttled (total events = 6992)
      1 CPU0: Package temperature above threshold, cpu clock throttled (total events = 8079)
      9 CPU0: Package temperature/speed normal
      1 CPU1: Package temperature above threshold, cpu clock throttled (total events = 12688)
      1 CPU1: Package temperature above threshold, cpu clock throttled (total events = 12689)
      1 CPU1: Package temperature above threshold, cpu clock throttled (total events = 29267)
      1 CPU1: Package temperature above threshold, cpu clock throttled (total events = 3464)
      1 CPU1: Package temperature above threshold, cpu clock throttled (total events = 3544)
      1 CPU1: Package temperature above threshold, cpu clock throttled (total events = 4977)
      1 CPU1: Package temperature above threshold, cpu clock throttled (total events = 6992)
      1 CPU1: Package temperature above threshold, cpu clock throttled (total events = 8079)
      9 CPU1: Package temperature/speed normal
      1 CPU2: Core temperature above threshold, cpu clock throttled (total events = 12160)
      1 CPU2: Core temperature above threshold, cpu clock throttled (total events = 12161)
      1 CPU2: Core temperature above threshold, cpu clock throttled (total events = 26206)
      1 CPU2: Core temperature above threshold, cpu clock throttled (total events = 3401)
      1 CPU2: Core temperature above threshold, cpu clock throttled (total events = 3481)
      1 CPU2: Core temperature above threshold, cpu clock throttled (total events = 4571)
      1 CPU2: Core temperature above threshold, cpu clock throttled (total events = 6563)
      1 CPU2: Core temperature above threshold, cpu clock throttled (total events = 7636)
      9 CPU2: Core temperature/speed normal
      1 CPU2: Package temperature above threshold, cpu clock throttled (total events = 12688)
      1 CPU2: Package temperature above threshold, cpu clock throttled (total events = 12689)
      1 CPU2: Package temperature above threshold, cpu clock throttled (total events = 29267)
      1 CPU2: Package temperature above threshold, cpu clock throttled (total events = 3464)
      1 CPU2: Package temperature above threshold, cpu clock throttled (total events = 3544)
      1 CPU2: Package temperature above threshold, cpu clock throttled (total events = 4977)
      1 CPU2: Package temperature above threshold, cpu clock throttled (total events = 6992)
      1 CPU2: Package temperature above threshold, cpu clock throttled (total events = 8079)
      9 CPU2: Package temperature/speed normal
      1 CPU3: Core temperature above threshold, cpu clock throttled (total events = 12160)
      1 CPU3: Core temperature above threshold, cpu clock throttled (total events = 12161)
      1 CPU3: Core temperature above threshold, cpu clock throttled (total events = 26206)
      1 CPU3: Core temperature above threshold, cpu clock throttled (total events = 3401)



lunes, 10 de marzo de 2014

Reiniciando el ratón

Si alguna vez por minutos el sistema bloquea el raton o el ratón se freeza y todo sigue funcionando bien la solución es reiniciar el modulo del ratón:

rmmod psmouse
modprobe psmouse

miércoles, 7 de agosto de 2013

Compilando kernel al modo debian

Siempre nos topamos con la pared que muchos temen al momento de escuchar "vamos a compilar el kernel", debian permite compilarlo de una forma sencilla y ajustado al mismo.

Instalar paquetes necesarios:

apt-get install build-essential fakeroot ncurses-dev kernel-package bc

1) Bajar el kernel a compilar
Suponiendo que hemos bajado la version 3.8.2, actualmete la version estable es la 3.10.5, tambien lo he probado con esta última, pero por ahora veamos con la primera.
cd /usr/src
wget -dc https://www.kernel.org/pub/linux/kernel/v3.x/linux-3.8.2.tar.gz
tar -xzpf linux-3.8.2.tar.gz
ln -s /usr/src/linux-3.8.2 /usr/src/linux
cd linux

2) Preparamos el kernel
make dep
make-kpkg clean

3) El siguiente paso es elegir las opciones:
make menuconfig
Aqui agregamos y quitamos lo que no necesitamos.

4) Creamos el paquete .deb
fakeroot make-kpkg --initrd --append-to-version=-custom kernel_image kernel_headers
Tiempo estimado:
real    84m34.915s
user    58m5.118s
sys     14m48.043s

5) En caso de algun error en el paso anterior, caso contrario proceda con el paso (6)
make clean
Y volvemos desde el paso (2)

6) Instalamos los .deb
cd ..
dpkg -i linux-image-3.8.2-*.deb linux-headers-3.8.2-*.deb

Listo ahora tendremos un kernel compilado a la forma debian.

http://www.debian.org/releases/stable/amd64/ch08s06.html.en
http://www.debian.org/releases/stable/i386/ch08s06.html.en

https://www.kernel.org/

jueves, 13 de junio de 2013

Fecha de creación de un fichero

Sobre este tema muy poco se encuentra al respecto y siempre encuentras al menso que dice que no se puede.

Luego de buscar encontre lo siguiente, no es linux el que almacena el tiempo sino el filesystem y para encontrar esta informacion hay que realizar lo siguiente:

debugfs -R 'stat /home/renich' /dev/mapper/VolGroup-lv_root

Es decir la sintaxis sería:

debugfs -R 'stat /$path/$to/$file_$dir' /dev/$partition

Y con esto obtenemos la informacion necesaria. 

miércoles, 12 de junio de 2013

Listado distros debian

¿Alguna vez haz deseado o necesitado una version anterior de debian?

Aqui la url para descargar las siguientes distros:
  • 3.0_r0 to 3.0_r6 (Woody)
  • 3.1_r0 to 3.1_r8 (Sarge)
  • 4.0_r0 to 4.0_r9 (Etch)
  • 5.0.0 to 5.0.10 (Lenny)
  • 6.0.0 to 6.0.10 (Squeeze)
  • 7.0.0 to 7.11.0 (Wheezy)
  • 8.0.0 to 8.11.0 (Jessie)
  • 8.11.1 (Jessie LTS, for some arches only)
  • 9.0.0 to 9.13.0 (Stretch)
  • 10.0.0 to ... (Buster)
  • 11.0.0 to ... (Bullseye)
http://cdimage.debian.org/cdimage/archive/

En mi caso necesito lenny y squeeze.

miércoles, 5 de junio de 2013

DNSSEC y BIND

Antes de continuar ver antes como enjaular el servicio BIND:
http://gnu-linux-opensource.blogspot.com/2011/11/enjaulando-el-bind.html

1) Instalamos dependencias:
apt-get install dnssec-tools libnet-dns-sec-perl libmailtools-perl libcrypt-openssl-random-perl

2) Agregaremos los siguiente en named.conf.options

options {
....
        dnssec-enable yes;
        dnssec-validation yes;
        dnssec-lookaside auto;
} 

include "/etc/bind/bind.keys";
 
3) ahora nos movemos a /var/lib/named/var/cache/bind/master y procedemos a hacer lo siguiente para cada zona:
 
zonesigner -genkeys -usensec3 -zone $dominio $archivo
 
4) Ahora en el llamado del fichero llamamos al que tiene como extension .signed:

file "master/$dominio.signed";
 
5) Para modificar una zona modificamos el fichero original y luego lo volvemos a firmar:
 
zonesigner -zone $dominio $archivo 


Ahora si tenemos un servidor esclavo haremos lo siguiente:

Hacer los pasos 1 y 2 previamente hechos, omitimos el paso 3 del server maestro y pasamos al 4to paso que seria nuestro 3er paso.

3) En el llamado del fichero agregamos la extension.signed:
 
file "slave/$dominio.signed";
 
Hasta este punto ya tenemos nuestros servidores con DNSSEC.
 
Saludes hasta el proximo post.