Category Archives: Posteet

Grepping processes

Grepping ps output will result in grep showing its own process:
[skanx@po-sr-nm ~]$ ps -efH|grep bash
skanx 28142 8787 0 11:59 pts/6 00:00:00 bash
skanx 28346 28142 0 12:01 pts/6 00:00:00 grep –color=auto bash

Instead, use ps -efH|grep [b]ash:
[skanx@po-sr-nm ~]$ ps -efH|grep [b]ash
skanx 28142 8787 0 11:59 pts/6 00:00:00 bash

Remove a deleted virtual disk LUN on a Linux system (MD3000i SAN array)

When you delete a Virtual Disk on a MD3000i array, that was previously used by a Linux system, the device is not removed from the system, and Linux will still try to access it (if you use LVM for example, you’ll see lots of errors while the system scans the disks to identify PVs). This can be very inconvenient if you reassign a previously assigned LUN, as the system won’t detect the new parameters of the device.
I did not find a command similar to hot_add (used to detect new devices) to automatically remove deleted disks.

By trial and error, though, I understood that you can delete a scsi device with this method:
echo "1" > /sys/class/scsi_device/adapter:bus:target:lun/device/delete

I also wrote a small script that will try and guess the paths to your devices, when you tell it the LUN number you just deleted on the SAN array :
md300i_delete_lun bash script
Warning: this script comes with no guarantee and I won’t take any responsibility if you try to use it :-). I could just test it on two RHEL 5.3 systems, and I don’t know if it will work anywhere else. Since it can be a little bit dangerous, it won’t actually delete anything, just tell you what commands you could use to delete the devices. At your own risk. :-)

Get the ip address in a shell script

Using ifconfig was not a good idea at all.
Here is a more distro-agnostic way:

ip addr show eth0 | grep "inet "| awk '{ print $2}' | awk -F '/' '{ print $1 }'


# set the language to English, to avoid translation problems with ifconfig
export LANG=C
# get IP address of eth0 network interface
ifconfig eth0 | awk '/inet addr/ {split ($2,A,":"); print A[2]}'


source

dpkg-reconfigure locales on ubuntu

dpkg-reconfigure locales doesn’t seem ask what locales you want to enable anymore (ubuntu 8.10), whatever the priority of questions you set in debconf…

The locales to be generated are listed in this file : /var/lib/locales/supported.d/local

Just add your locales there, then do a dpkg-reconfigure locales, it should generate you new locales :

skanx@tipica:~$ cat /var/lib/locales/supported.d/local
en_US.UTF-8 UTF-8
fr_FR UTF-8

skanx@tipica:~$ sudo dpkg-reconfigure locales
Generating locales…
en_US.UTF-8… up-to-date
fr_FR.UTF-8… done

atl2 bug on the eeepc: txs packet size do not coinsist with txd

On my eeePC 700 running ubuntu 8.10 (kernel 2.6.27-11-server), I experienced constant network disconnections with the LAN card, and found these messages in the logs :
[ 1355.131236] eth0: txs packet size do not coinsist with txd txd_:0x000005ea, txs_:0x20000754!
[ 1355.131244] txd read ptr: 0x166c
[ 1355.131249] txs-behind:0x000105ea
[ 1355.131254] txs-before:0x000105ea
[ 1365.041754] atl2: eth0 NIC Link is Up<100 Mbps Full Duplex>

I resolved the issue by installing a newer version of the atl2 module :

Get the lastest atl2 driver from: http://people.redhat.com/csnook/atl2/
Make sure you have the linux-header package corresponding to your kernel installed (package linux-headers-2.6.27-11-server in my case)

– Untar the driver source, compile with make
– Backup the atl2 module that shipped with your kernel (/lib/modules/2.6.27-11-server/kernel/ubuntu/atl2/atl2.ko in my case)
– Replace it with your new version
– sudo depmod
– reboot the computer or stop the network and reload the atl2 module

more info: https://bugs.launchpad.net/ubuntu/+source/linux-ubuntu-modules-2.6.24/+bug/147639

edit: http://people.redhat.com/csnook/atl2/ seems to be unavailable… I still have the driver source, but don’t know if I can post it here… If you need it, just ask and I’ll send it by e-mail :)

Compile a debian kernel with make-kpkg

The debian way (etch packages):
# apt-get install linux-source-2.6.18 kernel-package build-essential fakeroot libncurses5-dev
$ cd /usr/local/src
$ tar jxvf /usr/src/linux-source-2.6.18.tar.bz2
$ cp /boot/config-2.6.18-6-686 linux-source-2.6.18/.config
$ cd linux-source-2.6.18
$ make menuconfig
$ fakeroot make-kpkg --initrd clean
$ fakeroot make-kpkg --initrd kernel_image

Examples:
fakeroot make-kpkg --arch amd64 clean
fakeroot make-kpkg --arch amd64 --initrd --append-to-version=-skx.2008082001 kernel_image

Disable a Linux module

The RHEL / Centos way:
edit /etc/modprobe.conf, and add :
alias <modulename> off

The Debian way:
Create a file ‘/etc/modprobe.d/<modulename>’ containing ‘blacklist <modulename>’.
Run ‘depmod -ae’ as root
Recreate your initrd with ‘update-initramfs -u’
/!\ Read http://wiki.debian.org/KernelModuleBlacklisting, then do not use ‘/etc/modprobe.d/blacklist’ and remove ‘/etc/modprobe.conf’ as it supersedes anything in /etc/modprobe.d/*.
source : Debian wiki

The Tobi way:
edit /etc/modprobe.conf, and add :
install <modulename> /bin/true

inspiration: DotMana