Category Archives: Linux

Fix for unreadable File System of OpenWrt

If the OpenWrt system reports an unreadable file system try the following:

mtd unlock rootfs_data 

Take over packagelist from one Debian to another

In order to sync the state of installed packages from one Debian or Ubuntu to another one, the following process can be helpful. Make a packagelist on the original machine:

dpkg --get-selections > myselections.txt

Transfer the packagelist (myselections.txt) over to the new machine and do the following there:

apt-get update
dpkg --set-selections < myselections.txt
apt-get -u dselect-upgrade

Setup of Sun Grid Engine

Sun Grid Engine facilitates computing in distributed computer networks. Its setup is just documented here. Its not nearly complete though.

Setup log

Enter the database directory
or hit  to use default [/usr/local/sge-root/default/spooldb] >>
# ------------------
We can install the startup script that will
start berkeleydb at machine boot (y/n) [y] >> 

cp /usr/local/sge-root/default/common/sgebdb /etc/init.d/sgebdb
/usr/sbin/update-rc.d sgebdb
# ------------------
Please give the basic configuration parameters of your Grid Engine
installation:

   

The pathname of the spool directory of the execution hosts. User >sge<
must have the right to create this directory and to write into it.

Default: [/usr/local/sge-root/default/spool] >>
# ------------------
You should now enter the command:

   source /usr/local/sge-root/default/common/settings.csh

if you are a csh/tcsh user or

   # . /usr/local/sge-root/default/common/settings.sh
# ------------------
Please now login to all hosts where you want to run an execution daemon
and start the execution host installation procedure.

If you want to run an execution daemon on this host, please do not forget
to make the execution host installation in this host as well.

All execution hosts must be administrative hosts during the installation.
All hosts which you added to the list of administrative hosts during this
installation procedure can now be installed.

You may verify your administrative hosts with the command

   # qconf -sh

and you may add new administrative hosts with the command

   # qconf -ah 
# ------------------
# Editieren globaler Variablen
qconf -mconf global

Known errors and fixes

To fix

/usr/local/sge-root/util/arch: line 256: [: too many arguments

insert in line 247

libc_string=2.7 

Adjust Cacti for fine grained Input Data

Cacti is a fine graphing solution for all sorts of use cases. It only has problems with with small range inputs. The result are graphs which lack labels, i.e. being hard to read. This code adjustments fixes this. The following lines in /usr/share/cacti/site/lib/rrd.php need to be adjusted:

if ($graph["auto_scale"] == "on") {
    switch ($graph["auto_scale_opts"]) {
        case "1": /* autoscale ignores lower, upper limit */
            $scale = "--alt-autoscale" . RRD_NL;
            break;

The replacement consists of:

if ($graph["auto_scale"] == "on") {
    switch ($graph["auto_scale_opts"]) {
        case "1": /* autoscale ignores lower, upper limit */
            $scale = "--alt-autoscale --alt-y-grid" . RRD_NL;
            break;

Diskless Boot a Linux System (Debian)

 

In order to boot a Linux system disklessly from a server on your local network, these steps outline the necessary steps. Beware that this is just a brain dump. This documentation is not intended to be fool proof nor is it a copy'n paste howto. It just gives an oversimplified guide to the process.

Configure and build grub

First, grub has to be built supporting network boot with a couple of network drivers (pxegrub). Therefore, a patch from http://os.inf.tu-dresden.de/~adam/grub/0.97/ needs to be applied to grub's source. Then, the build process can be done with the following shell script:

#!/bin/bash
export CC=gcc-3.4
for i in 3c90x e1000 eepro100 pcnet32 rtl8139 r8169 tg3; do
        make clean
        ./configure --enable-diskless --enable-pxe --enable-$i
        make
        cp stage2/pxegrub /boot/pxe-boot/pxegrub/pxegrub.$i
done

make clean
./configure --enable-diskless --enable-pxe --enable-3c90x \\
       --enable-e1000 --enable-tg3 --enable-pcnet32
make
cp stage2/pxegrub /boot/pxe-boot/pxegrub/pxegrub.3c90x_e1000_tg3_pcnet32

Kernel build process

Now, a new kernel has to be compiled. Therefore, get the most recent kernel from http://www.kernel.org. Unpack and configure with IP: kernel level autoconfiguration = YES and IP: DHCP support from networking options and nfs from filesystem options.

Compilation is done by

make && make modules && make modules_install

or on AMD64 systems by

make ARCH=x86_64 menuconfig && make ARCH=x86_64 && make ARCH=x86_64 modules && make ARCH=x86_64 modules_install

Now, arch/i386/boot/bzImage can be taken as the new kernel.

Build new initramfs

Edit /etc/initramfs-tools/initramfs.conf to suit the netboot purpose:

MODULES=netboot
BOOT=nfs
NFSROOT=auto

Execute mkinitramfs -o initrd-netboot.img /lib/modules/<kernel_version>

Now, put the new initrd-netboot.img and bzImage into pxegrub's menu.lst.

Preparation of the boot image

The debian package debootstrap help prepping the network boot image, but it need to be installed first:

aptitude install debootstrap

Now, the following line creates a fully functional boot image:

debootstrap --include=nfsbooted,dhcp3-client,procps,passwd,vim,\
                      less,configure-debian,udev,console-common \
            lenny . http://ftp.de.debian.org/debian/

A few customisations and then it's done:

  • edit etc/hostname to your needs
  • create a valid hosts file: cp /etc/hosts etc/hosts
  • change root password by using chroot .
  • copy modules into new root: cp -a /lib/modules/<netboot_kernel_version> lib/modules/
  • boot!
  • Inside the new system: aptitude update && aptitude install openssh-server common-keymap && configure-debian --all

Linux Stress Tests

Several aspects of a Linux system may need a stress test at some point.

To test the whole system:

stress --cpu 16 --io 16 --vm 16 --hdd 16 --timeout 3600

To test Apache either the Selenium-Plugin for Firefox helps or the Apache bench:

ab -n100 -c100 {url}

Ram can be tested with memtester from http://pyropus.ca/software/memtester/

Tar Cheat Sheet

Tar Segmentation

With today's increased flash storage sizes, there may not be many occasions where you need to split files. However, when you do need to do so, I find tar to be a good tool for that task (this hint is also useful if you want to split an archive before burning to DVDs).

The following use of bash's brace expansion makes creating multi-volume tar files easy. To create a multi-file archive of a given length, use this:

tar --tape-length=102400 -cMv file=tar_archive.{tar,tar-{2..100}} [files to tar]

To extract from the archive:

tar -xMv --file=tar_archive.{tar,tar-{2..100}} [files to extract]

To create DVD-sized volumes, use --tape-length=4588544. In the above examples, replace [files to tar] and [files to extract] with the location(s) of the file(s) you wish to segment.

Copying a directory

tar cf - * | ( cd /target; tar xfp -) 

Tar via ssh

tar -czf - {source-dir} | ssh {host} "(cd {target-dir}; tar xzf -)" 

Detailed Hardware Info

Details on a machine's hardware can be printed by using lshw. So information on the bus is collected by:

lshw -businfo

In order to trigger a detailed memory, the following two lines come in handy:

dmidecode -t memory

or

lshw -C memory

Make snmpd’s log more silently

A default snmpd log a bit too much for my taste. Therefore, /etc/default/snmpd can be adjusted. Change the following line from:

SNMPDOPTS='-Lsd -Lf /dev/null -u snmp -I -smux -p /var/run/snmpd.pid 127.0.0.1'

to

SNMPDOPTS='-LS 0-4 d -Lf /dev/null -u snmp -I -smux -p /var/run/snmpd.pid 127.0.0.1'