Archive for the ‘Linux’ Category

File changed as we read it

2008-11-29

I’ve tracked it down, so you don’t have to.

When creating an archive, GNU tar monitors the file it’s reading. If the file’s mtime has changed, it’s reporting that “file changed as we read it”, as defined in create.c in the source code.

Tar’s man page doesn’t say anything about tar system exit codes, but a relevant piece of documentation can be found on-line.

Depending on tar version, it returns different exit codes.

  • tar-1.13 and earlier: 1 or 2
  • tar-1.14: == 0
  • tar-1.15: == 0
  • tar-1.17: == 1 (change)
  • tar-1.19: == 1

The change was recent enough that as of November 2008, you can be still encountering both behaviors.

Bridge and ipv6 autoconfiguration

2008-11-16

“There’s no sound”, said my missus.

Few minutes before, as usual, I picked up my 17-inch laptop and placed it on the second desk, where it can face the room. I don’t really like dragging the armchair every time I want to watch a video together, but the flat isn’t big enough to arrange a place with a permanent setup. (I also don’t own a TV and I’m proud of it.)

This time there was indeed no sound.

“Wait a minute”, I said and opened Gnome Terminal. At my place, there is only one set of speakers connected to one computer, and shared over the local area network. After a while I figured out that mplayer had trouble contacting PulseAudio server. The server wouldn’t respond.

I tried playing sound from a different machine – it worked. So it’s not the server. Next test:

maciej@quince ~ $ ping -c 1 leon
PING leon.home.blizinski.pl (192.168.1.3) 56(84) bytes of data.
64 bytes from leon.home.blizinski.pl (192.168.1.3): icmp_seq=1 ttl=64 time=0.165 ms

— leon.home.blizinski.pl ping statistics —
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 0.165/0.165/0.165/0.000 ms

Next test…

maciej@quince ~ $ telnet leon 4713
Trying 2001:
660:952::20a:e4ff:fe28:a3cf...

Timeout. And… ah. I forgot I was running native IPv6 in my LAN. I tried connecting over IPv4, it worked. I’ve set ${PULSE_SERVER} to the IPv4 address of the PulseAudio server and happily watched the movie together with my missus.

But… what’s going on? Running ping6 ipv6.google.com gives good results – there are answers. But when I ran ping6 leon, I got no answer. How can ping work for an external host but not for a host in my LAN?

After more poking at the machine, I’ve found out that the response packets (ACK) over IPv6 are in fact coming to the slave eth0 interface, but never to the bridge interface, br0.

Then I’ve noticed that IPv6 routing is wrong! There are two routes:

2001:660:952::/64 dev eth0
2001:660:952::/64 dev br0

Packets should leave through br0, not eth0. First idea, restart the bridge. However, the wrong route stayed there even after interface restart. It made me think what happens when I stop the bridge.

Well, eth0 goes back from slave state into a normal state, and then… it’s autoconfigured. That means, it gets a route assigned to it. When the bridge is being started, eth0 becomes a slave of br0, but there probably is no mechanism to remove the route which was assigned during eth0’s autoconfiguration.

A quick ad-hoc fix is:

ip -6 route del 2001:660:952::/64 dev eth0

A permanent solution would be better, but I happen to be lazy.

UPDATE 2009-02-01: Jeroen Massar from SixXS offered a better workaround:
put in /etc/sysctl.conf:
net.ipv6.conf.eth0.accept_ra = 0

When talking about this problem, the conversation usually goes like this:
- I have this problem with IPv6 autoconfiguration… (yada yada)
- What distribution are you using?
- Gentoo.
- (laughter)

Well, turns out, they were right. I tried this config on Ubuntu:

maciej@ubuntu-vbox:~$ cat /etc/network/interfaces
auto lo
iface lo inet loopback
 
iface br0 inet dhcp
bridge_ports eth0
 
auto eth0
auto br0

After “/etc/init.d/network restart”, the surplus route was there. But after a reboot, it wasn’t there any more. Ubuntu/Debian somehow handles this case.

Training notes from Atlantic Linux

2008-10-22

Atlantic linux writes:

We started with an Introduction to Linux course after finding some interested customers around the Galway area. (…) we decided to release our training materials under a Creative Commons license (…)

- Introduction to Linux
- Linux System Administration and Support
-
Linux Performance Tuning

Full post and training materials

register365 and scp

2008-06-10

My current hosting provider, hosting365 register365, is a traditional-style shared hosting service, where file upload is still done via FTP with passwords sent as clear text. They provide ssh access on demand, and it has to be manually approved by company’s staff. I don’t understand why don’t they provide shell by default. Maybe it’s part of being a traditional style hosting and trying to avoid the word “shell” or anything like it.

Shell they provide, but what about public key authentication? No, they don’t. As this is turned on by default in all Linux installations, they must have switched this option off. Why did they do that, remains a mystery as public key authentication is no less secure than password entry.

(more…)

Ctrl key not working in VNC

2008-06-03

Continuing my series of short tech notes for future generations.

The problem: ctrl key not working in VNC session. xev command doesn’t show any events coming after pressing ctrl key.

Cause: You’re using Gnome, aren’t you? Gnome has a feature that allows to locate the pointer: if you press and release ctrl key, it will show a small animation around your pointer. Unfortunately, it interferes with vncviewer.

Solution: Few websites, including BBC, offer a fix: System → Preferences → Mouse → Cursors tab…

Problem with the solution: Oh noes! Cursor tab is not there! I can’t change the setting!

Solution to the problem with the solution: Use gconf-editor to change the setting: Applications → System Tools → Configuration Editor. Press CTRL+F. Type: “pointer”. Tick “search also in key names” and press “Find”. Click /desktop/gnome/peripherals/mouse/locate_pointer. Untick the checkbox next to it, on the top right pane.

Python mocker for Gentoo

2008-03-16

Here’s an ebuild for Python mocker. Really cool mock module, which doesn’t come up high on Google.

Converting DVD lectures to mp3

2008-03-09

I don’t study any more since December 2006. I’ve completed my Masters, and… the game seemed to be over. But when a friend has recommended TTC courses to me, I started listening to them… and become addicted. I’ve completed Philosophy of Religion by James Hall, Great Ideas of Psychology by Daniel N. Robinson and Explaining Social Deviance by Paul Root Wolpe. I’m currently listening to Argumentation: The Study of Effective Reasoning by David Zarefsky. I have a few more courses to go through, so I won’t be out of lectures anytime soon.

However, it turned out that watching them as videos doesn’t work well for me. When I’m at home, I have plenty of other things I’d like to do. But they work well in audio, as I can listen to them when commuting. I’m going to buy new courses in audio, but what about those ones I have already in DVD? Can I convert them into audio?

I’ve put together a shell script, which dumps all tracks from DVD and encodes them into mp3 format. It also normalizes volume, so the voice of the speaker has more or less constant volume, which is good when listening in noisy environment.

It was written on Linux, if you’re a Windows user, you can try running it under Cygwin.

USB storage devices and gparted

2008-02-08

USB devices like pendrives and external drives stopped mounting. I couldn’t work out what was the problem. dmesg showed that the USB device was recognized. Gnome volume manager was started. Hal and dbus also working. And my drives just wouldn’t mount automatically.

I’ve finally found a solution on forums.gentoo.org.  The problem was that gparted, which I happened to install a while ago, put this file into hal’s configuration:

/usr/share/hal/fdi/policy/gparted-disable-automount.fdi

I found the „true” part in the file, changed it into „false”, restarted hal, and voila, my drives are being mounted now!

Why was the file put in that place? The story is, gparted puts it there on start so usb devices don’t get in its way. It removes this file on exit. On graceful exit, that is. If it’s killed, it doesn’t remove it and the file just stays there.

Supernatural for Linux users

2008-02-08

 I bet you guys have a hard time figuring out how it works with woo-woos. Here you have it black on white. If a woo-woo would be a sysadmin, they would do more or less:

$ dd if=/dev/urandom of=i-believe bs=1 count=$RANDOM
18676+0 records in
18676+0 records out
18676 bytes (19 kB) copied, 0.172968 s, 108 kB/s
$ chmod 755 i-believe
$ ./i-believe

And voila! All the work is done!

Watching an interlaced DVD with MPlayer

2008-01-30

Resuming my tech-notes blogging…

I’ve recently bought three Studio Ghibli’s movies. I don’t have a TV-set (yes, lenina, I’m still not watching any TV), so I’m watching DVDs on my laptop. DVDs I got are interlaced, when watching them on a computer, you can see small horizontal stripes along the sides of moving objects.

On a TV-set, this is not a problem, actually, interlacing makes animation on TV-set smoother. But on a computer, all you get from interlacing is stripes.

MPlayer comes with few deinterlacing plugins, from which yadif and kerndeint seem to work best (but I’m open to other suggestions). However, my video output is GL:

maciej@clover ~ $ cat .mplayer/config
vo = gl
autosync = 20
monitorpixelaspect = 1
af = volnorm=2:0.6
ao = pulse

The problem with those deinterlace filters is that they don’t cooperate with the gl video output. Fortunately, there’s an easy fix for that: append scale filter.

mplayer -vobsubid 1 -vf kerndeint,scale dvd://5

Replace 5 with your title number. The vobsubid option tells MPlayer to display subtitles. I like to watch Japanese movies with the original soundtrack and English subtitles. Usually, English dubbing reveals too much about the characters and lacks the original expression.