HowTo: Use zram on Fedora 16

Ok, this one is badly documented. Even the kernel docs are outdated.

Here’s how to start using zram on Fedora 16:


# get rpmfusion: http://rpmfusion.org/Configuration
...

# install the staging kmod
su -c 'yum install kmod-staging'

# get zram running (aha!)
su -c 'modprobe zram zram_num_devices=4'

# define the block's size (512 MB each)
echo $((512*1024*1024)) > /sys/block/zram0/disksize
echo $((512*1024*1024)) > /sys/block/zram1/disksize
echo $((512*1024*1024)) > /sys/block/zram2/disksize
echo $((512*1024*1024)) > /sys/block/zram3/disksize

# do some swap initialization
mkswap /dev/zram0
swapon /dev/zram0

mkswap /dev/zram1
swapon /dev7zram1

# create a filesystem on the others ( btrfs ;) )
mkfs.btrfs /dev/zram[34]
mkdir /mnt/zram
mount /dev/zram3 /mnt/zram

# do some testing!
...

# check out some stats
cat /sys/block/zram3/*

Have fun with it!

# references

http://code.google.com/p/compcache/

http://mystilleef.blogspot.com/2011/10/enable-zram-in-fedora.html

HowTo: Appfirst with SELinux enabled

Ok, first off, I hate people that say “turn off SELinux”… man, those idiots might as well tell you to turn off your firewall and open up your servers to the world.

This sounds like a nice gesture but, in today’s internet, it’s a shortcut to online suicide.

Anyway, here’s a mini-howto on how to generate your appfirst policy. This might require that you do it yourself since you might have different plugins/modules/whatever configured.

Anyway, here it goes:

# install the nice tools you need
su -
yum install -y setools-console policycoreutils-python

# remove the selinux_chk from /etc/init.d/afcollector.
...

# clean your audit.log
cat /dev/null > /var/log/audit/audit.log

# start app first while selinux is active
service afcollector start

# wait for it to start and generate a few selinux warnings (and get denied)
...

# now, set enforce off
setenforce 0

# generate a good policy
cat /var/log/audit/audit.log | audit2allow -M appfirst

# activate it
semodule -i appfirst.pp

# set selinux up again
setenforce 1

# check for errors
seaudit-report /var/log/audit/audit.log

# done!

You can copy your appfirst.pp to all your servers. It’s untested but it has worked fine so far for me! ;)

I got this file. Please, comment on it.


# cat appfirst.te

module appfirst 1.0;

require {
type unconfined_t;
type initrc_state_t;
type consoletype_t;
type proc_t;
type user_tmpfs_t;
type systemd_passwd_agent_t;
class process execmem;
class shm { write unix_read getattr unix_write associate read };
class file { write getattr read open };
}

#============= consoletype_t ==============
allow consoletype_t initrc_state_t:file read;

#============= systemd_passwd_agent_t ==============
allow systemd_passwd_agent_t initrc_state_t:file { read getattr open };
allow systemd_passwd_agent_t proc_t:file { read getattr open };
allow systemd_passwd_agent_t self:process execmem;
allow systemd_passwd_agent_t unconfined_t:shm { write unix_read getattr unix_write associate read };
allow systemd_passwd_agent_t user_tmpfs_t:file { read write };

-- end of file; don't copy this --

p.s. never turn off SELinux; that’s major idiot’s way!

HowTo: Removing BtrFS from a bunch of drives (BOD)

Ok, I just discovered how to remove BtrFS from a bunch of drives. It got kind of hard at first but, thanks to the #btrfs channel, I discovered how.

for device in sd{d..g}; do dd if=/dev/zero of=/dev/$device bs=4k count=1 seek=16; done

This will remove a 4k block; starting from 64k. This did it.

Why would you like to do this? Well, just to try some different configurations. Also, I got into a problem while using different labels and stuff…

LemonPOS: Cómo instalarlo en Fedora 16

Un vato (Alejandro), me dijo que quiere instalar LemonPOS y que, éste, está chido.

Me doy cuenta de que lo hace un Mexicano! Ajuá!A webo! Y que está en pinche C++! Mejor! Pinche Java; es pa’ putos y que chingue a su madre!

Lo único que no me gustó es que usa kde4 y qt… wákala…

En todo caso, ahí va como instalarlo en Fedora. Hay que calarlo. Si alguien quiere mantener el paquete en Fedora, que me pida ayuda y con gusto le echo el paro.

Le hice algunas modificaciones para hacerlo más estándar (IMHO). En todo caso, si no jala, me pones un comentario y lo corrijo.

#
## Construcción

# Instalar dependencias
su -c 'yum install kdelibs kdelibs-devel qt qt-devel qt-mysql mysql-server git'

# clonar
git clone git://gitorious.org/lemonpos/lemonpos.git
cd lemonpos
git pull origin persa:persa
git checkout persa

# compilar
mkdir build
cd build
cmake ../ -DCMAKE_INSTALL_PREFIX=$( kde4-config --prefix )
make

# instalar
su -c 'make install'

#
## MySQL

# configurar mysql
systemctl enable mysqld.service
mysql_secure_installation
systemctl start mysqld.service

# instalar DB y usuario de lemonpos
cd ../database_resources/
mysql -u root -p < lemon_mysql.sql
mysql -u root -p < mexico_taxes.sql

# correr el programa (usuario: admin, password: linux)
lemon

# Fuentes

http://lemonpos.org/

http://sourceforge.net/apps/mediawiki/lemonpos/index.php?title=Installation_Guide

HowTo: Substitución de una línea completa con sed

Seguramente, alguna vez en tu vida, has querido reemplazar una línea en 300+ zonas de DNS. Claro, a todos nos ha pasado… ¬_¬… por lo menos a todos los que no tenemos vida, eh?

Gracias a los de #fedora @ freenode por ésto (Jefe fue el autor):

sed -ri 's@SOA@s@^.+$@lo que quieras poner en esa línea@' /path/al/archivo