Wednesday, September 23, 2009

Screen as window manager

In case that you didn't know screen is a window manager and a very useful one however for consoles ...
This is my .screenrc file

hardstatus alwayslastline
hardstatus string '%{= kG}[ %{G}%H %{g}][%= %{=kw}%?%-Lw%?%{r}(%{W}%n*%f%t%?(%u)%?%{r})%{w}%?%+Lw%?%?%= %{g}][%{B}%Y-%m-%d %{W}%c %{g}]'
# Default screens
screen -t shell1 0
screen -t shell2 1
screen -t shell3 2
screen -t shell4 3

To switch between screens type CTRL+a 0 - goes on screen 0 - replace 0 with 1-3 to end up on a different window(screen)

To detach is a simple CTRL+a d - this will put screen into the background and you can reatach with
screen -r or if you have multiple sessions
screen -ls will list the screens that you have running and then
screen -r sessionName

Monday, September 21, 2009

Simple benchmark programs for Linux

In case that you want to test a new server for disk performance you
can do it very quickly with the following tools

bonnie++ from http://www.coker.com.au/bonnie++/
iozone from http://www.iozone.org/

These two will make different tests to your file systems.

Also you can use hdparam (do hdparam --help for all the options)
This is an example from a very old computer with SATA2

# hdparm -t /dev/sda

/dev/sda:
Timing buffered disk reads: 170 MB in 3.03 seconds = 56.06 MB/sec

Thursday, September 17, 2009

Create from scratch a Xen image [Part-1]

This is a mini howto on creating from scratch a xen domU guest system cloning the
hostOS.

What you need:

- have a host os which runs xen in dom0 (you can install a centOS and choose virtualization as profile)
- some disk space (i put 20Gb for the / and 2 for swap)
- run the following two commands to set the volumes

pvcreate /dev/sda7 -- change the /dev/sda7 with whatever you want to
vgcreate VolGroup00 /dev/sda7 -- change the /dev/sda7 with whatever you want to

if unsure what to do look it on on how to create volumes in linux (google it ... )



The following script will create you and image:

#!/bin/sh

##########################################
echo $0 "Starting"                       #
echo "This script will clone the guestOS #
creating a new xen image"                #
#
# echo "Author: dioda11@gmail.com"       #
##########################################

if [ $@ ne 1 ]; then
echo "please give a numeric identifier for the clone
between 10 and 100"
exit 1;
# if ![ $1 lt 100 ]  
fi

IMGID=$1
BASEDIRMOUNT=/mnt

VOLGROUP=VolGroup00

lvcreate  -L 20G -n   LV_VM$IMGID_RH5.3_ROOT   $VOLGROUP
lvcreate  -L 2G -n   LV_VM$IMGID_RH5.3_SWAP  $VOLGROUP

mkfs.ext3  /dev/$VOLGROUP/LV_VM$IMGID_RH5.3_ROOT
mkswap  /dev/$VOLGROUP/LV_VM$IMGID_RH5.3_SWAP


if [ -d $BASEDIRMOUNT/$IMGID ]; then
mount /dev/$VOLGROUP/LV_VM$IMGID_RH5.3_ROOT $BASEDIRMOUNT/$IMGID
echo "Mounting the /dev/$VOLGROUP/LV_VM$IMGID_RH5.3_ROOT was " $? 
else
mkdir -p $BASEDIRMOUNT/$IMGID
echo "Creating $BASEDIRMOUNT/$IMGID was  " $?
mount /dev/$VOLGROUP/LV_VM$IMGID_RH5.3_ROOT $BASEDIRMOUNT/$IMGID
echo "Mounting the /dev/$VOLGROUP/LV_VM$IMGID_RH5.3_ROOT was " $? 
fi


echo "Cloning the host OS === "

ARCH=`uname -m`

if [ $ARCH == "x86_64" ]; then 
cp -ax /{bin,dev,etc,lib,lib64,root,sbin,usr,var} $BASEDIRMOUNT/$IMGID
else 
cp -ax /{bin,dev,etc,lib,root,sbin,usr,var} $BASEDIRMOUNT/$IMGID
fi

mkdir $BASEDIRMOUNT/$IMGID/{home,proc,opt,sys,tmp}
chmod 777 $BASEDIRMOUNT/$IMGID/tmp

echo "Cloning finished === " $?


echo "At this point you need to fix the /etc/fstab and create the xen config file"

# umount $BASEDIRMOUNT/$IMGID

------------------------