crontab bailing out

After upgrading ubuntu, crontab stopped working, giving this:

$ crontab -l
cannot chdir(/var/spool/cron), bailing out.
/var/spool/cron: Permission denied

A quick google led me to fix at ubuntuforums. However, setting crontab executable sticky didn’t help. I left it “unsticky”.

The next tryout was to fix permissions /var/spool/cron. Originally there was:

$ sudo find /var/spool/cron -ls
23945429 4 drwx------ 3 root crontab 4096 May 4 20:42 /var/spool/cron
23945599 4 drwx-wx--T 2 root crontab 4096 May 4 20:42 /var/spool/cron/crontabs

I don’t remember where I found the expected permissions, but I applied:

$ sudo chown daemon:daemon /var/spool/cron
$ sudo chmod go+rx /var/spool/cron/

And got:

$ sudo find /var/spool/cron -ls
23945429 4 drwxr-xr-x 3 daemon daemon 4096 May 4 20:42 /var/spool/cron
23945599 4 drwx-wx--T 2 root crontab 4096 May 4 20:42 /var/spool/cron/crontabs

And got:
$ crontab -l
[listing of my crontab]

Excellent.

Coloring shell prompt

Having multiple terminals to different hosts eventually leads to wrong command at wrong terminal. To avoid this, I decided to add some coloring to the prompt. Following great tips at Funtoo.org, I created following scheme (to be put on your .bashrc):

PS1="\[\e]2;\H:\w\a\]${debian_chroot:+($debian_chroot)}\u@\h:\w\[\e[32m\]$\[\e[0m\] "

This keeps terminal’s titlebar to read <user>@<host>:<pwd>. It also colors the dollar/hash sign at prompt. I have different colors for different hosts, giving me indication of the current host. Colors are listed on the Funtoo.org article, and can be altered by changing the 32 value on PS1 (32 is green, for example).

Linux raid: Re-add disk

Today I noticed that one disk had dropped from my 4-disk raid5 configuration. Dmesg told that it had dropped 2 days ago, propably due to loose wire (damn those unlocked connectors). I opened my machine, tightened the wires and booted.

Revealed that sde1 had failed:
$ cat /proc/mdstat
md2 : active raid5 sde1[2](F) sdc1[3] sdd1[0] sdf1[1]
2197715712 blocks level 5, 64k chunk, algorithm 2 [4/3] [UU_U]

I re-added the disk (partition):

$ sudo mdadm --add /dev/md2 /dev/sde1
mdadm: re-added /dev/sde1

And recovery begun:

$ cat /proc/mdstat
md2 : active raid5 sde1[4] sdc1[3] sdd1[0] sdf1[1]
2197715712 blocks level 5, 64k chunk, algorithm 2 [4/3] [UU_U]
[>....................] recovery = 0.2% (1642496/732571904) finish=252.1min speed=48315K/sec

Tools for thesis

Here is a short wrap-up of tools I used for writing my thesis.

Subversion. A must.
Provides: version control, backup, distribution.

Really, any other version control tool will do. I chose SVN, because I was already familiar with it. I set up (svn+ssh) repository to backed-up Linux servers at school, so I didn’t have to care about backups either. The repository is also recommended for people with multiple computers, as it allows easy retrieval and submission of work from any of them.

LaTeX. Viable alternative for WYSIWYG.
Provides: document preparation & typesetting.

I chose to use LaTeX mainly for learning; I hadn’t used it before. I guess I spent about the same time figuring out how to use LaTeX, as I would have spent fighting with OpenOffice (or Microsoft Office). I also estimate that learning LaTeX was much more fun that fighting with OpenOffice would have been. Writing LaTeX is as easy as writing HTML, so if you answer yes to “Would you like to write your thesis with HTML”, you’ll love LaTeX.

Graphviz. Optional.
Provides: graphs.

Graphviz converts textual representations of graphs to graphical presentation of graphs. In other words, you describe what kind of graph you want, and graphviz makes an image of it. Feel free to check out, if you feel like “coding” your graphs.

MagicDraw. Optional.
Provides: Software diagrams.

About the only non-OS tool in the chain. Used for drawing architecture and sequence diagrams of the sample software.

make. Recommended if using LaTeX and Graphviz.
Provides: automation.

Knits together bits and pieces of latex, graphviz and anything else you need to make the pdf.

Apache. Optional.
Provides: Distribution.

Basically, nightly cron job was set up to make deliveries to certain folder, shared with Apache to the world (supervisors and audience of my thesis). In my case, the access was restricted with .htaccess user/password scheme, just to keep bots out of work-in-progress thesis. The job had many tasks; create a tarball of thesis source, compile a pdf of thesis, create a tarball of thesis software, create changelogs of thesis and its software, and to create weekly snapshot of the thesis.

Compiling Qt 4.6 (with bearer management) on Ubuntu 9.10 (or later)

These work for newer Qt and Ubuntu too. Additional notes for 10.04 are marked on the list.

For complete installation instructions, see INSTALL from git. These are just shortcuts how I made it to work.

0. Get dependencies (10.04)

sudo apt-get install git build-essential libxext-dev libxrender-dev

1. Get Qt and configure:

git clone git://gitorious.org/qt/qt.git
cd qt
./configure

Then, compile. It takes a while.
make -j3

2. Install it. By default, this installs it to /usr/local/Trolltech/Qt-4.x.0
sudo make install

3. Modify path. I made this small script to use downloaded environment, without messing with the local (apt-get’d) version of Qt:

QTDIR=/usr/local/Trolltech/Qt-4.7.0 PATH=$QTDIR/bin:$PATH bash

Qt version currently in use can be checked with qmake --version. Remember to change Qt version from the script if necessary.

Now you have Qt installed. Continue for bearer management library. Following instructions may be outdated, they were written Nov/09 while the rest of the post has been updated later.

4. Next, Mobility API’s bearer management library is installed. Download and configure it:

cd .. # To go back from qt git directory.
git clone git://gitorious.org/qt-mobility/bearermanagement.git
cd bearermanagement

5. Make symbolic link to real Qt include directory:
ln -s /usr/local/Trolltech/Qt-4.7.0/include/QtNetwork/ include
This way, when bearer mgmt lib is compiled, headers are automatically exported to the right place.

6. Compile and install bearer managment library.

./configure -examples
make -j3
sudo make install

If this fails, check that desired Qt is in use (step 3).

7. Link libQtBearer.so:

cd /usr/local/Trolltech/Qt-4.7.0/lib
sudo ln -s $OLDPWD/build/Debug/bin/libQtBearer.so.1.0.0
sudo ln -s libQtBearer.so.1.0.0 libQtBearer.so.1.0
sudo ln -s libQtBearer.so.1.0.0 libQtBearer.so.1
sudo ln -s libQtBearer.so.1.0.0 libQtBearer.so

So that the libQtBearer.so in Qt’s /lib points to newly-created .so.

8. To verify setup and get some action, try out examples:

cd - # (To return to build directory)
./bin/examples/bearercloud
./bin/examples/bearermonitor

Raid5 superblock missing

Some days ago my raid5 didnt want to mount due to missing superblock;

mount: wrong fs type, bad option, bad superblock on /dev/md2,
missing codepage or helper program, or other error
In some cases useful info is found in syslog - try
dmesg | tail or so

What helped was

sudo fsck /dev/md2 -y

which fixed the drive but removed the ext3 journal. The journal can be created with

sudo tune2fs -j /dev/md2

After which the drive mounted fine. However, some data was lost, according to lost+found folder.

Dreambox update: 404 error

I bought used dreambox DM500 some days ago. It had gemini 3.60 image inside. Never (4.x) series were available but automatic update didn’t find these with error 404 not found (http://www.i-have-a-dreambox.com/~emucenter/image/catalog.xml). The solution is manual update; download latest image from IHAD site (4.60 on my example), unzip the .img, rename it to one requested by dreambox in manual update, and transfer it with ftp to /tmp on the box. Then proceed with the dreambox instructions.

This may be an old error, but I made this note just in case someone still encounters this.

Dreambox NFS mount

These instructions mount /storage on server (192.168.0.2) to Dreambox’s (192.168.0.3) /hdd directory. By default, the nfs share is accessed as root, but with root_squash and anonuid+anongid it can be accessed with ID’s on the server.

On server, export directory. Add following to /etc/exports. It is one line:

/storage 192.168.0.3(rw,sync,no_subtree_check,root_squash,anonuid=1000,anongid=1000)

Restart nfs:

sudo /etc/init.d/nfs-kernel-server restart

Telnet to dreambox:

telnet 192.168.0.3

Mount the nfs share:

mount -t nfs -o nolock 192.168.0.2:/storage /hdd

To do it automatically on boot, edit (or create) /var/etc/init:

#!/bin/sh
ifconfig eth0 192.168.0.3 netmask 255.255.255.0 up
sleep 5
mount -t nfs -o nolock,rsize=4096,wsize=4096,rw 192.168.0.2:/storage /hdd
sleep 5

rsize and wsize options was added, because with default options, large reads failes.

vi can be used to edit, quick reference: vi /var/etc/init press i (to enter edit mode) and paste all above. Then press esc and (to exit edit mode) and write :wq and press enter to write changes and quit.