Archivo

Artículos etiquetados y‘Tips’

Archero! optimiza pacman

Julio 18, 2009 msdark 4 comentarios

Pacman, es el poderoso gestor de paquetes que utiliza ArchLinux.. y hoy nevegando por los foros de archlinux.org me encontre con un script para optimizar la base de datos de pacman.

Ya existe un “optimizador” oficial, el script pacman-optimize, pero este script lo supera bastante.

Puedes ver el post oficial aqui.
Y utilizar el script:
#!/bin/bash
#
# pacman-cage
#
# Copyright (c) 2002-2006 by Andrew Rose
# I used Judds pacman-optimise as a framework.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
# USA.
#

myver='2.9.8'
dbroot="/var/lib/pacman"
pacmandb="/var/lib/pacman.db"

usage() {
echo "pacman-cage $myver"
echo "usage: $0 [pacman_db_root]"
echo
echo "pacman-cage creates a loopbacked filesystem in a contigious file."
echo "This will give better response times when using pacman"
echo
}

die() {
echo "pacman-cage: $*" >&2
exit 1
}

die_r() {
rm -f /tmp/pacman.lck
die $*
}

if [ "$1" != "" ]; then
if [ "$1" = "-h" -o "$1" = "--help" ]; then
usage
exit 0
fi
dbroot=$1
fi

if [ "`id -u`" != 0 ]; then
die "You must be root to cage the database"
fi

# make sure pacman isn't running
if [ -f /tmp/pacman.lck ]; then
die "Pacman lockfile was found. Cannot run while pacman is running."
fi
# make sure pacman.db hasnt already been made
if [ -f $pacmandb ]; then
die "$pacmandb already exists!."
fi

if [ ! -d $dbroot ]; then
die "$dbroot does not exist or is not a directory"
fi

# don't let pacman run while we do this
touch /tmp/pacman.lck

# step 1: sum the old db
echo "==> md5sum'ing the old database..."
find $dbroot -type f | sort | xargs md5sum >/tmp/pacsums.old

echo "==> creating pacman.db loopback file..."
dd if=/dev/zero of=$pacmandb bs=1M count=150 > /dev/null 2>&1

echo "==> creating ext2 -O dir_index -b 1024 -m 0 on $pacmandb..."
yes | mkfs.ext2 -O dir_index -b 1024 -m 0 $pacmandb > /dev/null 2>&1

echo "==> creating temporary mount point /mnt/tmp-pacman.."
mkdir /mnt/tmp-pacman

echo "==> mounting pacman.db to temporary mount point..."
mount -o loop $pacmandb /mnt/tmp-pacman

echo "==> copying pacman database to temporary mount point..."
cp -a /var/lib/pacman/. /mnt/tmp-pacman

echo "==> unmounting temporary mount point..."
umount /mnt/tmp-pacman

echo "==> removing temporary mount point..."
rmdir /mnt/tmp-pacman

echo "==> moving old /var/lib/pacman to /var/lib/pacman.bak..."
mv /var/lib/pacman /var/lib/pacman.bak

echo "==> createing new pacman db mount point @ $dbroot..."
mkdir $dbroot

echo "==> Mounting new pacman db..."
mount -o loop $pacmandb $dbroot

echo "==> md5sum'ing the new database..."
find $dbroot -type f | sort | xargs md5sum >/tmp/pacsums.new

echo "==> checking integrity..."
diff /tmp/pacsums.old /tmp/pacsums.new >/dev/null 2>&1
if [ $? -ne 0 ]; then
# failed, move the old one back into place
umount $dbroot
rm $pacmandb
mv $dbroot.bak $dbroot
die_r "integrity check FAILED, reverting to old database"
fi

echo "==> Updating /etc/fstab to reflect changes..."
echo "$pacmandb $dbroot ext2 loop,defaults 0 0" >> /etc/fstab

rm -f /tmp/pacman.lck /tmp/pacsums.old /tmp/pacsums.new

echo
echo "Finished. Your pacman database has been caged!. May the speedy pacman be with you."
echo

exit 0

gracias a ody por este trabajo

Saludos

Categorías:Arch Linux, Tips Etiquetas:, ,

Finit-arc: Acelerando el inicio de Arch!!!

Abril 10, 2009 msdark 5 comentarios

Siempre me ha gustado que mi S.O sea veloz en todo y obviamente eso incluye el proceso de inicio (BootUp)…

Con Archlinux se puede mejorar bastante esa velocidad, arreglando un poco el archivo /etc/rc.sysinit, los tipicos consejos sobre Udev, etc, etc…

Pero con este post del foro oficial de ArchLinux esa velocidad si que se consigue…

Finit-arc es una reimplementacion de fast-init hecho para la eeepc, puedes encontrar ese paquete en AUR

Para instalarlo:

 $ yaourt -S finit-arc

Y ahora viene el tunning del sistema!!

Primero haz un backup de tu /etc/rc.sysinit y luego crea uno nuevo con el siguiente texto
#!/bin/bash
#
# /etc/rc.sysinit
#

. /etc/rc.conf
. /etc/rc.d/functions

echo " "
printhl "Arch Linux - Speedup boot"
printsep

#**************************** WARNING ******************************
# If you're using initramfs for your kernel, uncomment steps 5 and 17
# To improve boot speed it's recommendend to make a static kernel
# without modules and without initramfs.
#
# MAKE STEP 2
# Type in a term from root: ls -l /dev | grep sda
# you'll receive the list of /dev/sda devices
# make your /dev/sda devices in step 2 like the example
#*******************************************************************

# STEP 1 - mount /proc, /sys and our RAM /dev
/bin/mount -n -t ramfs none /dev
/bin/mount -n -t proc none /proc
/bin/mount -n -t sysfs none /sys

# STEP 2 - make static sda nodes for start udevadm --settle in background
/bin/mknod /dev/sda b 8 0
/bin/mknod /dev/sda1 b 8 1
/bin/mknod /dev/sda2 b 8 2
/bin/mknod /dev/sda3 b 8 3
/bin/mknod /dev/sda4 b 8 4
#...5...6..etc..(from your fdisk -l)

# STEP 3 - copy static device nodes to /dev
/bin/cp -a /lib/udev/devices/* /dev/

# STEP 4 - enable rtc access
/sbin/modprobe rtc-cmos >/dev/null 2>&1
if [ -n "$RTC_MAJOR" ]; then
/bin/mkdir /dev/misc/
/bin/mknod /dev/misc/rtc0 c $RTC_MAJOR 0
/bin/ln -s /dev/misc/rtc0 /dev/rtc
fi

# STEP 5 - Load modules from the MODULES array defined in rc.conf
#if ! [ "$load_modules" = "off" ]; then
# if [ -f /proc/modules ]; then
# stat_busy "Loading Modules"
# for mod in "${MODULES[@]}"; do
# if [ "$mod" = "${mod#!}" ]; then
# /sbin/modprobe $mod
# fi
# done
# stat_done
# fi
# if [ -d /proc/acpi ]; then
# stat_busy "Loading standard ACPI modules"
# ACPI_MODULES="ac battery button fan processor thermal"
# k="$(echo $BLACKLIST ${MOD_BLACKLIST[@]} | /bin/sed 's|-|_|g')"
# j="$(echo ${MODULES[@]} | /bin/sed 's|-|_|g')"
# #add disabled MODULES (!) to blacklist - much requested feature
# for m in ${j}; do
# [ "$m" != "${m#!}" ] && k="${k} ${m#!}"
# done
# # add disablemodules= from commandline to blacklist
# k="${k} $(echo ${disablemodules} | /bin/sed 's|-|_|g' | /bin/sed 's|,| |g')"
# for n in ${ACPI_MODULES}; do
# if ! echo ${k} | /bin/grep "\" 2>&1 >/dev/null; then
# /sbin/modprobe $n > /dev/null 2>&1
# fi
# done
# stat_done
# fi
#fi

# STEP 6 - set hardware clock for fs check
{
HWCLOCK_PARAMS="--hctosys"
if [ "$HARDWARECLOCK" = "UTC" ]; then
HWCLOCK_PARAMS="$HWCLOCK_PARAMS --utc"
else
HWCLOCK_PARAMS="$HWCLOCK_PARAMS --localtime"
fi
if [ "$USEDIRECTISA" = "yes" -o "$USEDIRECTISA" = "YES" ]; then
HWCLOCK_PARAMS="$HWCLOCK_PARAMS --directisa"
fi
if [ -f /etc/localtime ]; then
/sbin/hwclock $HWCLOCK_PARAMS --noadjfile
fi
} &

echo > /proc/sys/kernel/hotplug

# STEP 7 - start udevadm trigger and udevd in background
{
if [ -x /sbin/udevadm -a -d /sys/block ]; then
stat_busy "Starting UDev Daemon"
/sbin/udevd --daemon &
/sbin/udevadm trigger &
stat_done
else
status "Using static /dev filesystem" true
fi
} &

# STEP 8 - start udevadm settle in background
/sbin/udevadm settle &

# STEP 9 - make lo interface
{
if [ -d /sys/class/net/lo ]; then
stat_busy "Bringing up loopback interface"
/sbin/ifconfig lo 127.0.0.1 up
if [ $? -ne 0 ]; then
stat_fail
else
stat_done
fi
fi
} &

# STEP 10 - mounting root read-only
status "Mounting Root Read-only" /bin/mount -n -o remount,ro / &

# STEP 11 - filesystem check
FORCEFSCK=
[ -f /forcefsck ] && FORCEFSCK="-- -f"
NETFS="nonfs,nonfs4,nosmbfs,nocifs,nocodafs,noncpfs,nosysfs,noshfs,nofuse,nofuseblk"
fsck_reboot() {
echo "Automatic reboot in progress..."
/bin/umount -a
/bin/mount -n -o remount,ro /
/sbin/reboot -f
exit 0
}
if [ -x /sbin/fsck ]; then
stat_busy "Checking Filesystems"
FSCK_OUT=/dev/stdout
FSCK_ERR=/dev/null
/sbin/fsck -A -T -C -a -t $NETFS $FORCEFSCK >$FSCK_OUT 2>$FSCK_ERR
fsckret=$?
if [ ${fsckret} -gt 1 ]; then
stat_fail
fi
if [ $((${fsckret}&2)) -eq 2 ]; then
echo
echo "********************** REBOOT REQUIRED *********************"
echo "* *"
echo "* The system will be rebooted automatically in 15 seconds. *"
echo "* *"
echo "************************************************************"
echo
/bin/sleep 15
fsck_reboot
fi
if [ ${fsckret} -gt 1 -a ${fsckret} -ne 32 ]; then
echo
echo "***************** FILESYSTEM CHECK FAILED ****************"
echo "* *"
echo "* Please repair manually and reboot. Note that the root *"
echo "* file system is currently mounted read-only. To remount *"
echo "* it read-write type: mount -n -o remount,rw / *"
echo "* When you exit the maintenance shell the system will *"
echo "* reboot automatically. *"
echo "* *"
echo "************************************************************"
echo
/sbin/sulogin -p
fsck_reboot
fi
stat_done
fi

# STEP 12 - remount root and mount local file system
stat_busy "Mounting Local Filesystems"
/bin/mount -n -o remount,rw /
/bin/rm -f /etc/mtab*
/bin/mount -o remount,rw /
if [ -e /proc/mounts ]; then
/bin/grep -e "/proc " -e "/sys " -e "/dev " /proc/mounts >> /etc/mtab
fi
/bin/mount -a -t $NETFS
stat_done

# STEP 13 - activating swap partition
status "Activating Swap" /sbin/swapon -a &

# STEP 14 - set urandom
{
RANDOM_SEED=/var/lib/misc/random-seed
if [ -f $RANDOM_SEED ]; then
stat_busy "Initializing Random Seed"
/bin/cat $RANDOM_SEED > /dev/urandom
stat_done
fi
} &

# STEP 15 - removing temp files
stat_busy "Removing Leftover Files"
/bin/rm -f /etc/nologin &>/dev/null
/bin/rm -f /etc/shutdownpid &>/dev/null
/bin/rm -f /var/lock/* &>/dev/null
/bin/rm -rf /tmp/* /tmp/.* &>/dev/null
/bin/rm -f /forcefsck &>/dev/null
(cd /var/run && /usr/bin/find . ! -type d -exec /bin/rm -f -- {} \; )
: > /var/run/utmp
/bin/chmod 0664 /var/run/utmp
/bin/mkdir /tmp/.ICE-unix && /bin/chmod 1777 /tmp/.ICE-unix
/bin/mkdir /tmp/.X11-unix && /bin/chmod 1777 /tmp/.X11-unix
stat_done

# STEP 16 - set rc.conf hostname
if [ "$HOSTNAME" != "" ]; then
status "Setting Hostname: $HOSTNAME" /bin/hostname $HOSTNAME &
fi

# STEP 17 - load modules depends
#status "Updating Module Dependencies" /sbin/depmod -A &

# STEP 18 - set lang
{
: >/etc/profile.d/locale.sh
/bin/chmod 755 /etc/profile.d/locale.sh
[ -z "$LOCALE" ] && LOCALE="it_IT@euro"
stat_busy "Setting Locale: $LOCALE"
echo "export LANG=$LOCALE" >>/etc/profile.d/locale.sh
stat_done
} &

# STEP 19 - Save our dmesg output from this boot
if [ -f /var/log/dmesg.log ]; then
/bin/rm /var/log/dmesg.log &
fi
/bin/dmesg > /var/log/dmesg.log &

Luego edita tu /boot/grub/menu.lst agregando una entrada para utilizar finit

#(0) Arch Linux
title Arch Linux SpeedBoot
kernel /boot/vmlinuz26 root=/dev/sda2 ro vga=791 splash resume=/dev/sda1 init=/sbin/finit-arc
initrd /boot/kernel26.img

Ojo!!! finit no funciona con los UUID de los discos por lo que debes cambiar tambien tu archivo /etc/fstab para que monte los discos como /dev/sdaX (X es el numero de tu disco)

No olvides darle permisos de ejecución a tu nuevo /etc/rc.sysinit

Finalmente edita el archivo /etc/finit.conf (este es el mio)

##Set user on "login_manager" if you want access
##in a console login manager or GDM,KDM
#user login_manager

##mountdevices before udev (DONT REMOVE IT!)
mountdev

##modules that you want load
#module intel_agp
#module agpgart

##filesystem device that you want check
check /dev/sda2
check /dev/sda3

##hostname
host arch_msdark

##startx command
startx /bin/bash --login -c /usr/bin/startx

y el archivo /usr/sbin/services.sh

#!/bin/sh

#Starts udev events
/sbin/udevd --daemon &>/dev/null &
/sbin/udevadm trigger &>/dev/null &
/sbin/udevadm settle &>/dev/null &

#Make swap (not for ssd)
/sbin/swapon -a &

#Starting background daemons
/etc/rc.d/syslog-ng start &>/dev/null &
/etc/rc.d/hal start &>/dev/null &
/etc/rc.d/laptop-mode start &>/dev/null &
/etc/rc.d/alsa start &>/dev/null &
/etc/rc.d/wicd start &>/dev/null &
/etc/rc.d/fam start &>/dev/null &
/etc/rc.d/klogd start &>/dev/null &
/etc/rc.d/crond start &>/dev/null &

Y listo!!! reinicia y veras como mejoras la velocidad!!!

Saludos!!!

Categorías:Arch Linux, Tips Etiquetas:,

Diferencias… Laptops, Netbooks, Handheld, Ultraportatiles….

Marzo 27, 2009 msdark Deja un comentario

netbook flowchartx Diferencias...

Que tal? entendiste?..
Categorías:General, Tips Etiquetas:,

Tips: Convertir .nrg a .iso

Febrero 5, 2009 msdark Deja un comentario

Si tienes de esas odiosas imagenes en formato .nrg… ese del Nero.. y no tienes como tratarlo… simplemente instala nrg2iso y tienes tu solución.

Primero instalamos nrg2iso:

sudo pacman -S nrg2iso

Luego si estamos en la misma ubicacion que el fichero .nrg hacemos:

nrg2iso imagen.nrg nueva_imagen.iso

Y asi tendremos nuestra imágen en el formato que podemos usar… ISO…

Categorías:Tips Etiquetas:

Debugeando Shell Scripts

Febrero 4, 2009 msdark Deja un comentario

Navegando por ahi (no recuerdo donde… disculpe el autor original), me encontre con un post donde mostraban como hacer debugging en tus shell scripts, y es tan simple…. solo hay que agregar la opción -x y listo!!

 /bin/sh -x mi_script.sh 

O editando la primera linea del script

#!/bin/sh -x

A si de sencillo y útil

Categorías:GNU/Linux, Programación, Tips Etiquetas:

Los mejores repositorios para debian

Mayo 19, 2008 msdark Deja un comentario

Cuando se está utilizando un sistema Debian (o derivados), una de las cosas que más se disfrutan es la herramienta para administración de paquetes APT.

La mayoría, se pasa instalando distintos paquetes, aplicaciones, etc. aveces gastando mucho tiempo en lograr el objetivo (ej: actualizar el sistema), la mayoria de las veces provocado esto por la utilización de repositorios lentos… ¿pero como conozco los mejores repositorios para mi distro? Fácil con apt-spy

Apt-spy es un programa usado para testear el ancho de bande de una serie de mirrors de Debian, generando un archivo /etc/apt/sources.list con los servidores más rápidos. Puedes seleccionar que servidores deseas testear por localización geográfica.

Para poder usarlo, lo primero es instalarlo:
# aptitude install apt-spy

Ahora que ya lo tenemos… simplemente debemos usarlo:

Algunas de sus opciones en linea de comando son:

-d distribución
Indicamos que distribución usamos, puede ser: stable, testing o unstable.

-e n
Indicamos que solo pruebe los primeros n mirrors que funcionan.

-l archivo.list
No sobreescribe nuestro /etc/apt/sources.list, en su lugar usa archivo.list.

-a [africa |asia |europe |north-america |oceania |south-america ]
Identifica la localización geográfica donde buscar servidores

Como ejemplo de uso:
# apt-spy -d unstable -e 10 -l nuevo_sources.list -a south-america
Esto probará los primeros 10 mirrors para sur américa de Debian unstable y los escribira en el archivo nuevo_sources.list

Con esto ya tenemos nuestros nuevos repositorios, simplemente copiamos nuevo_sources.list como /etc/apt/sources.list y listo!!!

Saludos

Categorías:Debian, Tips Etiquetas:,