Emacs on a 1680×1050 display

May 15, 2008 by linos

Emacs is still my favorite editor. So I installed emacs22-gtk and as always it came up really ugly. The default font and window size are not appropriate for people of my age. For quite a couple of years I have been fine with

Emacs.font: -misc-fixed-medium-r-normal--20-200-75-75-c-100-iso8859-15

in my .Xdefaults. With the new display at 1680×1050 pixels and a resolution of 133×133 dots per inch this is far too small for my eyes. So again I started Googling. Soon I found hints, that there is a package emacs-snapshot which is able to use xft-fonts. But it didn’t work. I simply had

lulu:/home/bavn> cat .Xdefaults
Emacs.font: Monospace-13

and I did

lulu:/home/bavn> xrdb -merge .Xdefaults

but it didn’t work. At this time I had the Hardy emacs package emacs22-gtk I started with and the new package emacs-snapshot installed. I purged emacs22-gtk and then Emacs came up with Monospace. WoW !

One last step was missing. I had to call xrdb on the command line. Finally I found that having

lulu:/home/bavn> cat .Xresources
Emacs.font: Monospace-13

solved this last issue. Emacs now works with a nice font on my new Lifebook.

Using tar and netcat to backup filesystems: A pitfall resulting in broken links and how to avoid it

January 16, 2008 by linos

As shown in yesterday’s blog entry, I failed to recover my Feisty laptop due to missing links. Remembering the old saying “Every fool may do a backup” I now managed to find my mistake.

The error may be shown using localhost, so here we go:

First I started the listening netcat like this:

cd /tmp
netcat -l -p 2342 | tar xvf -

Then I backuped /sbin using:

cd /
tar cf - sbin | netcat localhost 2342

Both processes do not stop, until you hit CTRL-C. And at this point I did a mistake: I hit CTRL-C on the receiving side (I saw no further files coming in). DO NOT DO THIS – IT WILL EVENTUALLY LEAVE YOU WITH BROKEN LINKS. E.g. instead of

root@lulu:/tmp# ls -l sbin/ip
lrwxrwxrwx 1 root root 7 2008-01-16 11:33 sbin/ip -> /bin/ip

you will have

root@lulu:/tmp# ls -l sbin/ip
---------- 1 root root 0 2008-01-16 11:28 sbin/ip

Let us dig a little bit deeper using strace. Again start the listening side and then the sending side. Do not hit CTRL-C. Looking at the process list you will see that the sending tar has finished, the receiving tar is still there. Strace this process and hit CTRL-C on the sending side. Check sbin/ip and you will find a link correctly pointing to /bin/ip.

This is the strace output:

root@lulu:/tmp# cat receiving-tar.strace
8394 read(0, "", 10240) = 0
8394 clock_gettime(CLOCK_REALTIME, {1200479622, 923188961}) = 0
8394 clock_gettime(CLOCK_REALTIME, {1200479622, 923263552}) = 0
8394 close(0) = 0
8394 SYS_299(0xffffff9c, 0x808e6a5, 0xbfd650fc, 0x808e6a5, 0xb7f6eff4) = 0
8394 chmod("sbin", 0755) = 0
8394 chown32("sbin", 0, 0) = 0
8394 lstat64("sbin/lsmod", {st_mode=S_IFREG, st_size=0, ...}) = 0
8394 unlink("sbin/lsmod") = 0
8394 symlink("/bin/lsmod", "sbin/lsmod") = 0
8394 lchown32("sbin/lsmod", 0, 0) = 0
8394 lstat64("sbin/ip", {st_mode=S_IFREG, st_size=0, ...}) = 0
8394 unlink("sbin/ip") = 0
8394 symlink("/bin/ip", "sbin/ip") = 0
8394 lchown32("sbin/ip", 0, 0) = 0
8394 close(1) = 0
8394 munmap(0xb7cff000, 4096) = 0
8394 exit_group(0) = ?
root@lulu:/tmp#

Obviously tar handles the symbolic links not in the moment as they appear but in some final procedure. When I hitted CTRL-C on the receiving side I prevented tar to run that final procedure as this strace clearly shows:

root@lulu:/tmp# cat receiving-tar-ctrl-c
8495 read(0, "", 10240) = 0
8495 --- SIGINT (Interrupt) @ 0 (0) ---
root@lulu:/tmp#

So you really must hit CTRL-C only on the sending side, interrupting netcat, which is safe as the sending tar already has gone.

Even better: Use netcat’s q option for the sending netcat, e.g.

Receiving process:

root@lulu:/tmp# netcat -l -p 2342 | tar xvf -

Sending side:

root@lulu:/# tar cf - sbin | netcat -q 2 localhost 2342
root@lulu:/#

With -q 2, netcat stop go away 2 secs after detecting EOF on stdin. The receiving netcat then will go away too.

So my conclusion:

Always use tar + netcat this way:

Receiving side:

netcat -l -p 2342 | tar xvf -

Sending side:

tar cf – whatever-you-want-to-backup | netcat -q 2 localhost 2342

Never omit -q !

Update:

Just a hint for those using e.g. SuSE: Though netcat version is 1.10 (same as in Feisty) option -q ist not available (there are others missing too). So in SuSE you must hit CTRL-C on the right side …

Hard disk failure: Additional sense: Unrecovered read error – auto reallocate failed

January 15, 2008 by linos

Last week my laptop suddenly refused to boot any longer. Having configured nothing as root for quite some time, I read:

grub: Error 29: Disk write error

After restarting I got this error again. So I booted my Feisty cdrom and started to inspect the system. There was no obvious error in the first place. Being in a networked environment I decided to save my $HOME using netcat. This worked fine. So in the next step I backuped the root file system. This too worked fine. I finally tried to save another partition containing data of a virtual machine I use with vmplayer.

This failed spitting out a lot of driver error messages, e.g.

Additional sense: Unrecovered read error - auto reallocate failed

But the tar came back finally, saying:

root@ubuntu:/# tar cf - mnt | netcat cheetah 2342
tar: mnt/now2/now2-s004.vmdk: File shrank by 944635904 bytes; padding with zeros

To make a long story short:

After replacing the disk, restoring the filesystems, fixing grub and /etc/fstab my system came up – but with a lot of error messages. I could log in and after a while I found that all links like this one in /sbin were broken:

lrwxrwxrwx 1 root root 7 2008-01-15 14:30 ip -> /bin/ip

Instead I found:

---------- 1 root root 0 2008-01-15 14:50 ip

I fixed a lot of missing links in /sbin, /bin and all of the run level scripts manually. But finally I gave up because I did not find a method to fix the links in a really reliable way (apt, dpkg do not seem to help here – no way to rerun postinstall scripts IMHO).

So finally I reinstalled my laptop. Fortunately all data in $HOME was fine, so I was up and running again rather soon.

Nevertheless: Why failed my backup procedure ?

Solved: See next blog entry

Boot fails after Windows trouble: Use GRUB from Live-CD to reinstall MBR

December 6, 2007 by linos

The other day a colleague did some maintenance work on a multiboot system. Unfortunately he ended up with a completely unbootable system.

This was the right moment to have the Ubuntu CD ready. We booted Gutsy and then:


sudo su
grub

At the grub prompt, we typed root space left bracket and then the TAB key:


grub> root (hd0,
Possible partitions are:
Partition num: 0, Filesystem type unknown, partition type 0x7
Partition num: 1, Filesystem type unknown, partition type 0x7
Partition num: 2, Filesystem type is ext2fs, partition type 0x83
Partition num: 4, Filesystem type unknown, partition type 0x82

This was an easy decision. There is only one partition, which carries an ext2. So input 2:


grub> root (hd0,2)

Now GRUB knows where to take his files from. The second and final step is to run setup. Again TAB is your friend.


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)"... 17 sectors are embedded.
succeeded
Running "install /boot/grub/stage1 (hd0) (hd0)1+17 p (hd0,2)/boot/grub/stage2
/boot/grub/menu.lst"... succeeded
Done.

Please note that in this case we wanted to replace the MBR. That is why we wrote (hd0).
Finally leave grub with quit.

If for any reason you are not able to use the above described method root + TAB, you may use the find command in GRUB:


grub> find /boot/grub/stage1
(hd0,0)
(hd0,4)

Gutsy completely unusable for me: Hard freeze

December 2, 2007 by linos

Uuuh,

running Feisty quite happily, I installed Gutsy on my laptop on a separate partition ( I use the laptop all the time and can take not risks here).

As always, the first thing I tested was Suspend to disk. It did not work (screen went black in a second. I had to switch off power finally). I then decided to take a deeper look later. When I clicked reboot, again: Screen black. I had to switch off.

Today I found time to test again. At first, I updated the box. Then I started testing. I soon found, that simply logging off sometimes made the box freeze. I logged in via ssh to get more information, but as the ssh session also froze, I decided to start netconsole to get any kernel messages. I activated magic key and then switched from X to console, as I wanted to play with Alt-SysRq.

Oops: The box immediately froze !!!

Luckily this sems to be reproducable, so I filed a bug:

https://bugs.launchpad.net/ubuntu/+source/linux-meta/+bug/173425

vpnc: no response from target finally solved: AuthType=5

November 23, 2007 by linos

Hi,

I used vpnc instead of CISCO’s vpnclient for a long time. This way I could update my box without rebuilding any kernel modules vpnclient relies on.

Everything worked fine.

But suddenly I could not connect to my companies network any longer. I got:

vpnc: no response from target

Activating debug output did not help me. Fortunately a colleague of mine found a solution.

If you find

AuthType=5
CertStore=1

in the relevant pcf-file (vpnclient configuration file, which will be provided by your organization), you cannot use vpnc 0.4.0 or older any longer. You must get vpnc 0.5.1 and it must be compiled to use libcrypto (SSL).

For me ldd gives me:


lulu:/home/bav> ldd /usr/sbin/vpnc
...
libcrypto.so.0.9.8 => /usr/lib/i686/cmov/libcrypto.so.0.9.8 (0xb7dfa000)
...

So after getting the source package, you will have to change to makefile to read:


OPENSSL_GPL_VIOLATION = -DOPENSSL_GPL_VIOLATION
OPENSSLLIBS = -lcrypto

My configuration looks like this:


IPSec ID foo
IPSec obfuscated secret barbarbarbar
IPSec gateway 1.2.3.4
IKE DH Group dh2
Xauth username MYUSERNAME
IKE Authmode hybrid
CA-File /etc/vpnc/rootcert.pem

The file /etc/vpnc/rootcert.pem holds the appropriate certificate.

Gerd

Using DSL with pppd and pppoe in Feisty with suspend and resume

November 19, 2007 by linos

Hi,

the other day I set up a Feisty box directly connected to a DSL modem. So I had to use pppd and pppoe. The setup utility pppoeconf was already on the system (in /usr/sbin), but the package pppoe was missing (does that make sense: pppoeconf without pppoe ???). I installed pppoe and ran pppoeconf.

A minute later I was online.

After rebooting I was online again. But after suspending the box to disk and resuming there was pppd still kind of running – but useless. IMHO this is ok.

But the user expects to be online again of course.

This is what I did:


lulu:/etc/acpi/suspend.d> cat 01-poff.sh
#!/bin/sh
poff

and


lulu:/etc/acpi/resume.d> cat 99-pon.sh
#!/bin/sh
pon

I intended to terminate pppd via poff when suspending and start a fresh pppd when resuming was nearly finished.

This did not really work. I found an error message telling me that the interface was not up. So I added

ifconfig eth0 up

to the script. I thought I was done now, but at least occasionally the link was not up when I started to access the net.

With

lulu:/etc/acpi/resume.d> cat 99-pon.sh
#!/bin/sh
ifconfig eth0 up
sleep 2
pon
sleep 2

this works now fine.

Using

sudo netstat -nlp --inet

I finally closed all ports. (System | Services).

Gerd