Skip to content

Entries from September 2010.

Smartctl - a note to myself

A note to my future self as I never seem to remember these smartctl commands (partly and fortunately because I don't need them often):
1. Quick check
/usr/sbin/smartctl -q errorsonly -H -l selftest -l error /dev/sdX
2. Run some tests if the command above reported any errors:
smartctl -t short /dev/sdX && smartctl -l selftest /dev/sdX

Avoid cp overwrite confirmation

Tonight I have to copy and partially overwrite a lot of data on a Centos 5 system and encountered a little problem.
The "cp" command turned out to be a PITA as it was asking me for confirmation each and every time a file was to be overwritten.
Why is this happening? Because RedHat/Centos guys have added the following alias in bash conf files:
alias cp='cp -i'
-i means interactive, or in more words: "prompt before overwrite (overrides a previous -n option)".
The solution to this safe but annoying alias (in this case) is to `unalias` it or just ignore it by prefixing the command with a \.
\cp -a /home/xyz/* /home/zyx/
No more annoying confirmations, now I can go to bed. ZzzZz.

Linux Raid - replacing a physical device

Right now I'm dealing with a broken linux raid 1 in which both physical drives are reporting lots of bad blocks.
I have chosen the drive that exhibited the least problems and I'm having it cloned with dd_rescue on to a new one from a SysRescCD Live CD
dd_rescue /dev/old-b0rk3d-drive /dev/new-clone-drive
It's a good idea to run the above in a screen, especially if you're doing this via the internet.
Once the cloning is completed I simply put the new drive in the original server and expect it to boot - with a degraded but working raid.
In the next step I add a new empty drive, with a similar size (500 GB in my case) and clone the partition table with sfdisk:
sfdisk -d /dev/existing-drive | sfdisk /dev/new-empty-drive
Use `fdisk -l` before and after the partition cloning to be sure you're doing the right thing.
Once we have an identical partition table on both drives we can start adding partitions from the new drive to our linux raid. Assuming the cloned drive is sda and the new drive is sdb, our md setup should loook like this:
root@sysresccd /root % cat /proc/mdstat 
Personalities : [raid0] [raid1] [raid6] [raid5] [raid4] [raid10] 
md3 : active raid1 sda6[1]
      297780736 blocks [2/1] [U_]
      
md1 : active raid1 sda3[1]
      4192896 blocks [2/1] [U_]
      
md2 : active raid1 sda2[1]
      153597376 blocks [2/1] [U_]
      
md0 : active raid1 sda1[1]
      30716160 blocks [2/1] [U_]

And now let's add partitions to our raid layout:
mdadm /dev/md0 --add /dev/sdb1
mdadm /dev/md1 --add /dev/sdb3
mdadm /dev/md2 --add /dev/sdb2
mdadm /dev/md3 --add /dev/sdb6
And that's that, now we can see the raid resync'ing:
cat /proc/mdstat


We're not finished yet!
As this drive (and therefore its clone as well) was secondary (sdb) on the original system I expect problems with grub.
By default, when installing on to a linux raid Centos/Anaconda only installs grub on the first drive (sda in this case) and therefore my drive being sdb will lack this in its MBR.
If this is the case, we won't be able to boot at all from the cloned hdd, so we need to boot again from the Live CD, mount the linux raid from it and then chroot in to the OS and do the grub magic from there.
Assuming everything works nicely form the Live CD and the md devices are properly mounted under /mnt we can start:
export SHELL=/bin/bash
chroot /mnt/clone
#grub
grub> find /boot/grub/stage1
 (hd0,0)
 (hd1,0)
grub> root (hd0,0)
 Filesystem type is ext2fs, partition type 0xfd

grub> setup (hd0)
 Checking if "/boot/grub/stage1" exists... yes
 Checking if "/boot/grub/stage2" exists... yes
 Checking if "/boot/grub/e2fs_stage1_5" exists... yes
 Running "embed /boot/grub/e2fs_stage1_5 (hd0)"...  15 sectors are embedded.
succeeded
 Running "install /boot/grub/stage1 (hd0) (hd0)1+15 p (hd0,0)/boot/grub/stage2 /boot/grub/grub.conf"... succeeded
Done.

grub> root (hd1,0)
 Filesystem type is ext2fs, partition type 0xfd

grub> setup (hd1)
 Checking if "/boot/grub/stage1" exists... yes
 Checking if "/boot/grub/stage2" exists... yes
 Checking if "/boot/grub/e2fs_stage1_5" exists... yes
 Running "embed /boot/grub/e2fs_stage1_5 (hd1)"...  15 sectors are embedded.
succeeded
 Running "install /boot/grub/stage1 (hd1) (hd1)1+15 p (hd1,0)/boot/grub/stage2 /boot/grub/grub.conf"... succeeded
Done.

grub>quit 
And we're done now: reboot.
! - Please pay extra attention when doing this kind of operations, it's very easy to format the wrong HDD etc. :-)

Antena3 Live pe internet, fara flash

De cand numita "televiziune" si-a schimbat metoda de a transmite Live pe internet (de la un cacat de flash la un cacat si mai mare de flash, de data asta externalizat catre mediadirect.ro) nu mai pot viziona nimic - flash player moare cu segmentation fault si pe 32 si pe 64 de biti.
Iata cum putem viziona stream-ul direct cu rtmpdump si mplayer:
http://mandrivausers.ro/node/6190
Enjoy!

Spotify, Spotify...

Today I wanted to give Spotify a try as I have heard they released an alpha native version for linux.
However when I went to their site to download the client I got this:
So how do you get it? We’ve packaged the first release as a Debian Squeeze/Ubuntu 10.04 package.
Wait, what?
Since they don't release any source code you'd think they could at least release some generic unpack & run packages so everyone can use it...
Spotify, If a job is worth doing, it's worth doing well!
Anyway, I converted those deb packages to RPM using alien and you can download them from here:
http://dl.nux.ro/spotify/
I installed them with the following command:
#rpm -ivh spotify-client-qt-0.4.7.132.g9df34c0-2.i386.rpm spotify-client-gnome-support-0.4.7.132.g9df34c0-2.noarch.rpm --nodeps
They appear to install and run, however I cannot login (maybe because I use the free version of the account[1]):
$ spotify 
04:15:40.619 I [offline_authorizer.cpp:156] Unable to login offline: no such user
04:15:42.801 I [ap:1387] Connecting to AP B2.spotify.com:4070
04:15:42.829 I [ap:937] Connected to AP: 78.31.8.17:4070
04:15:42.894 E [ap:3285] Connection error:  406
04:16:04.565 I [offline_authorizer.cpp:156] Unable to login offline: no such user
04:16:05.492 I [ap:1387] Connecting to AP b1.spotify.com:4070
04:16:05.506 I [ap:937] Connected to AP: 78.31.8.15:4070
04:16:05.586 E [ap:3285] Connection error:  406

[1] - Yes, their offer is very good and affordable for most people and many dickheads in the music and film industry should learn from them, however they have no excuse for not releasing a decent linux client. The day they do that I'll seriously consider to pay.

Yahoo Mail

Yahoo mail = fail. Can't wait for this shit service to just die.
Their web interface is horrific, their anti-spam engine misses too much stuff and some times my emails don't reach their recipients (false positives on their part probably) or they hit the inbox severely delayed (I noticed sometimes it can take up to 24h, even more).
Whoever reads this message and is using Yahoo email service: STOP. IT'S JUST NOT RELIABLE.

How to pronounce linux

Apparently some people[1] don't know how to pronounce "Linux".
Here's Linus pronouncing it:
http://dl.nux.ro/audio/linus-says-linux.oga

[1] - http://www.sys-con.com/node/1523620
"What is Linux? Linux (pronounced “Line-ooks”) is a computer Operating System kernel developed by Linus Torvalds."

Handy tools - Fedora paste

echo This is quite handy | fpaste
Uploading (0.1K)...
http://fpaste.org/hTKI/
Would be nice to see this ported on every distribution; should be trivial to do it.

Here's to Davmail

Cheers to the DavMail devs for making my life bearable.
For those of you standard protocols lovers stuck in an Exchange environment this might be of interest:
DavMail is a POP/IMAP/SMTP/Caldav/Carddav/LDAP exchange gateway 
allowing users to use any mail/calendar client 
(e.g. Thunderbird with Lightning or Apple iCal) with an Exchange server,
even from the internet or behind a firewall through Outlook Web Access.

DavMail now includes an LDAP gateway to Exchange global address book
and user personal contacts to allow recipient address completion
in mail compose window and full calendar support with attendees free/busy display.
Enjoy!

Listing your own customers in Spamhaus RBL

Recently I had problems with a web server denying connections (HTTP error 406) from a certain IP address.
At first I thought it was because of some wacky firewall or tcpwrapper rule.
I couldn't be more wrong - It was mod_security verifying the remote IP against Spamhaus RBL...
While it may seem like a good idea at first, turns out it is not:
1. Because it slows down the request (as Apache has to lookup IPs against the RBL all the time).
2. Some IPs are in a RBL for the wrong reason.

As it turns out that particular IP belongs to BT,
and BT in their infinite wisdom decided to list in Spamhaus a good part of their IP space... Cool, huh?
More info here (and a screenshot for posterity here).
You got to love the corporations!

Iodine - TCP over DNS

code.kryo.se/iodine - How have I not heard about this before?
This is brilliant!

PS: Good luck with it, David! :)

The first Mandriva fork?

So it begins...
There is rumour around about forking Mandriva.
If you are not living in a cave, you must know that Mandriva (one of the oldest GNU/Linux distros and one that pioneered Linux as a desktop OS) has been through a lot of financial problems and many people left the company.
Given the above the community is more and more unsettled and there seems to be some desire to start a fork.
More details here, and if you don't speak French here's a Google translation.
We're living interesting times. Personally I'd be delighted to see all the Mandriva communities combine forces and keep the distro alive.

Rubygems is a mess

The gem system is a mess.

Mandriva is forked!

So it happened, a Mandriva fork is on the way and its name is Mageia ("magic").
Curious about how Mandriva S.A. shall respond to this; also curious if this fork will actually prove useful and produce anything (other than dividing the current Mandriva communities).

CVE-2010-3081

CVE-2010-3081 is one ugly son of a b*tch.
If you are running x86_64 Linux kernel make sure to check if you have been pwned.
Details here.
Exploit and diagnostic tool here.

Mandriva is alive and kicking!

Apparently Mandriva is alive and kicking... and they have big plans!
From a desktop point of view, Mandriva intends to be the BEST KDE DISTRIBUTION IN THE WORLD:
easy to use, stable, rich featured and with excellent localization.
Read the whole post for more details.

Someone has seen the light - coming back to Vim

Why would you want to ditch textmate for Vim?
Well, we all know Vim is the mother of all editors, but here's the story for those who don't:
http://stevelosh.com/blog/2010/09/coming-home-to-vim/

The distros killed Python

Have the distros killed python?
Distros keep python alive in the "real" world where you need stuff running reliably and securely for many years!

Not only that, distros will keep any language alive, as long as there is some sort of initiative from its devs to make it available for longer terms (to hell with rubygems since we're at it!).

Get more info about dying processes and run some scripts as well while you're at it

This is sheer coolness. I fuckin love the kernel guys.
Read this article to find out how to get more info about dying processes and how you can run some scripts before they get killed.

Get rid of the orphans in a Centos system

How to find out orphaned packages in your Centos/RHEL system?
yum install yum-utils
package-cleanup --orphans

`man package-cleanup` for more cool stuff

MPAA & AiPlex websites attacked from low orbit

Is it the Klingons? No. Is it the Wraith? No. It's the P2P "pirates"!
Last week the good people at MPAA and AiPlex got themselves an early Christmas present and got attacked by the "anonymous internet". I cannot but grin, as in (a very satisfied) GRIN :-D
Yeah, I know it's childish and all but still...

:-D

More details here.

Remote Centos 5 installation over VNC

Remember, remember... no, not the 5th of November, but to use 6-11 chars passwords for VNC when doing remote Centos installations!

RPMs for Courier email suite

Here's a Centos repo containing RPMs for the Courier suite (imap, mta, authlib etc):
http://dl.nux.ro/rpm/5/courier/
Repo file: http://dl.nux.ro/rpm/nux-courier.repo
The packages have been built directly from the courier tarball, didn't bother to tweak the spec file in any way.
Use them at your own risk etc etc.

RPMs for the Debian whois client

Here's another Centos repo containing RPMs for the Debian whois client (jwhois never works!):
http://dl.nux.ro/rpm/5/whois/
Repo file: http://dl.nux.ro/rpm/nux-whois.repo
PS: This should work on Fedora as well.

Your IP address

Is here.
Short, no ads and to the point.
Cheers!