Linux

exim oneliner

This oneliner is really practical if you’re administering mailsystems with thousands of email accounts.

# exim -bp | grep "<.*>" | awk '{ print $4 }' | sort | uniq -c | sort -n

If you suspect some account is being abused for sending spam you’ll get a quick overview .
It simply returns sorted list of counted mail in queue per user.

lvm redundancy

I’ve read that you can setup redundancy with lvm. I’ve never seen the reason why to do that, since in a server environment I’ve got some kind of raid in the bottom taking care of redundancy anyway .
The reason just came up, I had a situation where a server was setup without raid, and reinstallation was out of the question since developers was already working on the server. So here’s some hints regarding lvm mirroring.
First of all, you create lvm mirroring when creating logical volumes. as long as you got at least 2 physical disks and 1 volume group spread over those disks, all you need to do is add a couple options to lvcreate, for instance:

# lvcreate -m1 -L50G -n mirrored --corelog vg0 /dev/sda1 /dev/sdb1

Would create a 50GB logical volume in Volume Group vg0 with mirroring between /dev/sda1 and /dev/sdb1.
What’s even more cool is to use lvconvert to create a mirror of an already existing logical volume.

#lvconvert --mirrorlog core -m1 vg0/nonmirror

I did lvconvert on the root partition, no reboot required and ‘nobody’ even noticed I fixed redundancy πŸ™‚
Note: both examples uses ‘corelog’ which will write to ram resulting that mirrors will resync after _every_ reboot. NOT a very good thing, but in my opinion it’s better than not having any raid at all .
Lvm, by design, need a third disk for logging when you want mirroring and logs to be persistent over reboots . More info in

# man lvcreate
# apropos lvm

lvm                  (8)  - LVM2 tools
lvm.conf [lvm]       (5)  - Configuration file for LVM2
lvmchange            (8)  - change attributes of the logical volume manager
lvmconf              (8)  - LVM configuration modifier
lvmdiskscan          (8)  - scan for all devices visible to LVM2
lvmdump              (8)  - create lvm2 information dumps for diagnostic purposes
lvmsadc              (8)  - LVM system activity data collector
lvmsar               (8)  - LVM system activity reporter
perlvms              (1)  - VMS-specific documentation for Perl
pvcreate             (8)  - initialize a disk or partition for use by LVM
pvresize             (8)  - resize a disk or partition in use by LVM2

Thanks to tcpdump.com for helping me out here πŸ™‚

Upgrade firmware for perc 5/e in Debian

Dell create easy install firmware, drivers, management utilities and such for Redhat. These seldom work in Debian, often because of the different package management systems they use (rpm for Redhat / dpkg for Debian) .
I had to upgrade the firmware on a PERC 5/E raid controller, and we mainly run Debian where I work, so I’ve poked around for a solution on this issue.
There might have been a solution with creating a floppy or using some Dell utilities boot cd, but I’m 300 kilometres from the server so that wasn’t an option.
Here’s some links that helped me in the process.
http://www.cyberciti.biz/tips/how-to-extract-an-rpm-package-without-installing-it.html
http://linux.dell.com/repo/community/deb/latest/
http://sysadmin.wikia.com/wiki/PERC_firmware_upgrade_on_debian
Sysadmin.wikia.com’s solution didn’t do the trick for me, there was some script that really wanted rpm on my system (?) . I ended up with something like this:

# apt-get install alien
# rpm2cpio srvadmin-storelib-sysfs-7.0.0-4.1.4.el4.i386.rpm | cpio -idmv
# cp -a ../unpack_rpm/opt/lsi/ /opt/
# vi /etc/ld.so.conf.d/lsi_tmp.conf (adding to this file these lines)
/opt/lsi/3rdpartylibs/
/opt/lsi/3rdpartylibs/x86_64
# ./sasdupie -u -s ./payload/

I then got the xml output which told me a reboot was required .

umask in Ubuntu Oneiric

joar@jupiter:~$ umask
0002
joar@jupiter:~$ 

I wonder why they’ve changed umask from 0022 to 0002 in Ubuntu 11.10 .
Look like yet an other ‘make linux userfriendly’ apporach http://www.mail-archive.com/ubuntu-devel-announce@lists.ubuntu.com/msg00628.html
Personally I’m not a fan of files being group writeable when i create them:

joar@jupiter:~$ tail -1 .bashrc 
umask 0022
joar@jupiter:~$ bash
joar@jupiter:~$ umask
0022
joar@jupiter:~$ 

dmesg timestamp

[518950.884021] usb 2-4: new low speed USB device number 23 using ohci_hcd
[518951.108559] input: Trust GM-4200 Gamer Optical Mouse as /devices/pci0000:00/0000:00:0b.0/usb2/2-4/2-4:1.0/input/input24
[518951.108681] generic-usb 0003:145F:011A.0016: input,hidraw1: USB HID v1.11 Mouse [Trust GM-4200 Gamer Optical Mouse] on usb-0000:00:0b.0-4/input0

It’s kind of frustrating with dmesg timestamps. It basically show [seconds.nanoseconds] since last boot … that’s really accurate, and totally useless for humans that can’t do that math in their heads .
This guy at code.saghul.net wrote a great python script as a solution.
With reference to one of the comments at that blog, an even more elegant solution would be to simply use /var/log/kern.log , it’s already there πŸ™‚

Evolution 3, google calendar sync prob.

In ubuntu 11.10 I had problems adding my google calendar .
In gconf-editor, I found the evolution entry in apps/evolution
there is a key called “source” in addressbook and calendar also, and they differ. the calendar had no “google” source. I simply copied it from the addressbook part (double click on sources under addressbook, select the one with name=”Google”, press edit, copy it’s content) and added a new entry to the source key under calendar (same procedure, but press add when editing the key).

Got that from ubuntuforums.org

GPG error with apt-get update

I came over the error:

Reading package lists... Done
W: GPG error: http://ftp.no.debian.org lenny Release: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY AED4B06F473041FA
W: You may want to run apt-get update to correct these problems

When running apt-get update .
The solution is actually to do a

apt-get install debian-archive-keyring

Getting rid of ubuntu violet colors

I dist-upgrade’ed my Ubuntu at my laptop, and I’m again annoyed by the colors. I just can’t get used to the violet colors in debconf . Changing desktop background and colors, lightdm (yeah, they’ve replaced gdm with lightdm in 11.10) or splash (plymouth) themes is not a problem, and there are tons of howto’s out there. I’ve come to routinely replacing all of these things after installing or upgrading Ubuntu. Ubuntu now even has setup violet colors in debconf (!) . At the very least I want it back to Debian default blue .
This task turned out to be rather challenging (and quite stupid to spend time on figuring out) .
I guess my main problem was I didn’t really know which program(s) that was in effect when debconf was running. At first I didn’t even know ‘debconf’ had anything to do with those violet colors .
Long story short: it’s debconf, and some dependency involving libnewt . Thanks to the open source world, when I finally got my google phrase right, the solution was just one click away and I got insight right into the mail between developers that talked about moving away from default Debian blue colors. Have a look at lists.ubuntu.com and you’ll see that it’s all about a symlink in /etc/newt.
Before: violet background

root@juno:/etc/newt# pwd
/etc/newt
root@juno:/etc/newt# ls -l
total 8
lrwxrwxrwx 1 root root  30 2011-10-05 22:00 palette -> /etc/alternatives/newt-palette
-rw-r--r-- 1 root root 309 2011-03-22 14:32 palette.original
-rw-r--r-- 1 root root 336 2011-03-22 14:32 palette.ubuntu
root@juno:/etc/newt# rm palette
root@juno:/etc/newt# ln -s palette.original palette
root@juno:/etc/newt# ls -l
total 8
lrwxrwxrwx 1 root root  16 2011-10-05 22:00 palette -> palette.original
-rw-r--r-- 1 root root 309 2011-03-22 14:32 palette.original
-rw-r--r-- 1 root root 336 2011-03-22 14:32 palette.ubuntu
root@juno:/etc/newt# 

And we’re back at the blue background with debconf.
After: