Friday, January 22, 2010

Embedded Linux From Scratch in 90 minutes

Goals
- Linux kernel configuring and compiling;
- Root file system creation;
- Busybox compiling and installation;
- Device file creation;
- System initialization scripts: virtual file system, networking;
- Setup of a simple HTTP interface to the system.

1. Download fast processor emulator using a portable dynamic translator.

wget http://download.savannah.gnu.org/releases/qemu/qemu-0.12.2.tar.gz
tar zxvf qemu-0.12.2.tar.gz
cd qemu-0.12.2.tar.gz


Then you configure QEMU and build it (usually no options are needed):

./configure


install zlib if you need (apt-get install zlib1g-dev)

make


Then type as root user:

make install




2. Getting the Kernel sources:
wget http://www.kernel.org/pub/linux/kernel/v2.6/linux-2.6.25.4.tar.gz

Start with a minimalistic kernel configuration
make allnoconfig


Adding settings specific to the embedded system
install ncurses if you need (apt-get install libncurses5-dev)
make menuconfig


Compiling:
make


You will get
arch/x86/boot/bzImage


3. Getting Busybox source
wget http://www.busybox.net/downloads/busybox-1.15.3.tar.gz


Configuring BusyBox
make menuconfig


choosing to build a statically, natively compiled executable.

Compiling busybox
make


Pre-installing busybox (in the _install/ subdirectory):
make install


4. Creating a root filesystem
Creating an empty file with a 1000K size:
dd if=/dev/zero of=rootfs.img bs=1k count=1000

Formating this file for the ext2 filesystem:
mkfs.ext2 -i 1024 -F rootfs.img

5. Populating the root filesystem
logged as root:
Creating a mount point:
mkdir /mnt/tmproot

Mounting the root filesystem image:
mount -o loop rootfs.img /mnt/tmproot

Copying the busybox file structure into the mounted image:
rsync -a busybox/_install/ /mnt/tmproot/
(or cp -ax busybox/_install/ /mnt/tmproot/)
chown -R root:rooot /mnt/tmproot/

Flushing the changes into the mounted filesystem image:
sync

6. Booting the Virtual System
Using the QEMU emulator as a bootloader
qemu -m 32 -hda rootfs.img -kernel linux-2.6.25.4/arch/x86/boot/bzImage -append "root=/dev/hda" -redir tcp:5555::80

click "Applications -> Internet -> Terminal Server Client"then fill in the Computer with "127.0.0.1:5900",and select VNC in the protocol, if VNC grayed, install vncviewer
apt-get install vncviewer

Friday, January 1, 2010

Network Traffic Generation Tool for Linux

Mausezahn is a free fast traffic generator written in C which allows you to send nearly every possible and impossible packet. It is mainly used to test VoIP or multicast networks but also for security audits to check whether your systems are hardened enough for specific attacks.

http://www.perihel.at/sec/mz/index.html

Monday, December 28, 2009

How to "Android"

Environment

Eclipse
Android SDK

add Android SDK to Eclipse - Quick Start

How to start
Lessons

Sunday, February 1, 2009

How to read data from XML file to Crystal Report in C#

private void Form1_Load_1(object sender, EventArgs e)
{
string xmlFilename = "C:\\Project\\XMLCrystalReport\\books.xml";

DataSet newDataSet = new DataSet();
// read the XML document into the DataSet.
newDataSet.ReadXml(xmlFilename);

ReportDocument customerReport = new ReportDocument();
customerReport.Load(@"C:\Project\XMLCrystalReport\collection.rpt");
customerReport.SetDataSource(newDataSet);
crystalReportViewer1.ReportSource = customerReport;
}

Sunday, October 19, 2008

Performance Monitoring

Install performance monitoring tools.

yum install sysstat


Network Performace

sar -n DEV 10 1000


CPUs Performance

mpstat 2 -P ALL


Overview Hardware

lspci

Tuesday, June 17, 2008

How to backup MySQL databases

1. create /backup directory
2. create startbackup.sh script file:

rm -f /backup/mysql*
### System Setup ###
BACKUP=/backup
NOW=$(date +"%d-%m-%Y")

### MySQL Setup ###
MUSER="mysqluser"
MPASS="password"
MHOST="localhost"
MYSQL="$(which mysql)"
MYSQLDUMP="$(which mysqldump)"
GZIP="$(which gzip)"


### Start MySQL Backup ###
# Get all databases name
DBS="$($MYSQL -u $MUSER -h $MHOST -p$MPASS -Bse 'show databases')"
for db in $DBS
do
FILE=$BACKUP/mysql-$db.$NOW-$(date +"%T").gz
$MYSQLDUMP -u $MUSER -h $MHOST -p$MPASS $db | $GZIP -9 > $FILE
done