Older blog entries for yeupou (starting at number 152)

For a change, today I won’t describe how I did something but how I did not.

I had I mind to use tumblr with a daily automated post of a picture. I devised it would be nice if a daily cronjob on my local server was updating a git directory and then post the first image in the queue.

First, I found out that tumblr refuses to handle mail sent directly by mutt and the local server smtp. So I then tried having mutt sending the mail using gmail authenticated smtp. I did not work either. But it works fine to any other recipient. And it works if directly sent with gmail web interface. We’ve made it incredibly easy to post from your desktop or mobile phone. Just send an email to the custom email address for the blog you’d like to publish to they claimed. Go figure, that probably something they implied by the confusing sentence Send posts directly to your mobile posting email address. You cannot email another email address and then forward the email from there. I understand spam is an issue they have to care about, but how comes that even gmail authentication isn’t proof enough of goodwill?

Anyway I end up with a non working script for the simple task of sending a mail.

Syndicated 2012-05-07 07:58:01 from # cd /scratch

Upgrading Dell Latitude C640 CPU

Just because it’s quite cheap, via ebay, I decided to upgrade my Dell Latitude C640 CPU from a 2.0 GHz P4-M (sl6fk) to a 2.4 GHz one (sl6vc). It could, in theory, get a 2.6 GHz one, but these (like sl6wz) are way more expensive.

The Dell Latitude C640 service manual describe in lenghty details how to actually change the CPUs. There isn’t much point in describing it here. Remove the hard drive, the keyboard, then the CPU thermal cooling assembly and you can easily access the CPU socket.

After that change, the BIOS complained about a “Processor Microde Update Failure – The revision of processor in the system is not supported.”, a non-blocker item. A quick check with dmidecode showed me the current bios were version A08 released 03/04/2003, actually a few month before first releases of the new processor. So I decided to upgrade the BIOS too, following these advices. I downloaded a windows BIOS update from dell website.  On a computer with wine available (not the case of my laptop),  I ran wine ./R71684.exe and stopped after it extracted all the files it contained, then I ran unshield x data1.cab to get the contents of this cabinet. I found a file BiosHeader/C640_A10.HDR that I copied on my laptop. On the laptop, with the package libsmbios-bin installed and the module dell_rbu loaded, I ran dellBiosUpdate -f ./C640_A10.HDR -u which returned:

Supported RBU type for this system: (MONOLITHIC)
Using RBU v2 driver. Initializing Driver. 
Setting RBU type in v2 driver to: MONOLITHIC
Prep driver for data load.
Writing RBU data (4096bytes/dot): .................................................................................................................................
Notify driver data is finished.
Activate CMOS bit to notify BIOS that update is ready on next boot.
Update staged sucessfully. BIOS update will occur on next reboot.

Then rebooted the laptop and it restarted mentioning it was now running BIOS version A10. Cpufreq works fine, everything is in order.

Syndicated 2012-04-26 22:05:16 from # cd /scratch

Cleaning up ogg/mp3 collection (tags, filenames) with lltag

Over years, my music collection started to get annoyingly inconsistent (file names, tags, etc). I wrote two scripts to clean it up, in the form maindir/MusicGenre/Band/Album/songs. The first one identifies albums from files, the second one does the actual job, as lltag wrapper. The point of doing it in two distinct scripts is to separate the part where user input is needed and the part that requires none but takes most CPU time.

Considering there’s an initial directory that contains a subdirectory for each music album that must be sorted out :

  • cleanup-music-directory-01-identify.pl writes a import file (containing style|band|year|album, only the year being optional) in each subdirectory, according to your input. You’ll notably have to select a music genre.
  • cleanup-music-directory-02-rename.pl reads import files and then uses lltag to do the actual job – renaming and updating tags. Best is to run in –debug mode first that will only show the proposed changes without altering anything yet; if some of your files lack the TITLE tag, it can get messy.

These two scripts must be edited first (paths to the collection and user supposedly to retain ownership of the files).

Syndicated 2012-04-18 09:32:45 from # cd /scratch

Using a laptop as alarm clock

My alarm clock died long ago. Since then, I use my cellphone to wake me up. Works ok, except that my current cellphone is total crap and, among numerous issues, its alarm software some morning just stays idle while, the others days when it actually works, a simple movement shuts it off. Believe me, I checked everything, made plenty of test, it’s just bad design and poorly coded software.

Not to mention that I usually wake up with no alarm; so when I use one, it means that I must wake up early, probably with not enough sleep at all. I need the real deal, high sound level and no shortcut to kill it, to actually get up.

Whenever I needed an alarm, I ended up running, on my laptop not to far from my bed, some `sleep XXh XXm && mplayer /path/to/a/song`, check sound volume, followed by CTRL-C in the morning.

Two days ago, I was über-tired, I needed to wake up early next morning and calculating tomorrow waking up time  – current time just pissed me off, not to mention checking the volume level, mute setting and such. It pissed me enough to decide me to write a script to fix the problem. Here comes wakey.pl:

  • it takes as argument the time you’d like to wake up in the form HH:MM or HHh MMm ;
  • it can run as timer (as sleep), useful if you want to take 20min nap, with -t or –timer ;
  • it wakes you up playing a random song picked in ~/.wakey ;
  • it uses mplayer to play the song, so it can be in any format your mplayer supports ;
  • it raises progressively the sound volume when trying to wake you up (you can set –volume-max, in case 100% on Master mixer is too loud) and reset properly mixer settings when finished ;
  • it won’t stop playing the music until you type a 3 to 5 characters word randomly taken from the defaut dictionary installed on your system (/usr/share/dict/words).

I wanted it to deal with any powersave setup to make sure to forbid the laptop to sleep or hibernate, but I found not portable and clean way to do it (my laptop uses KDE with PowerDevil). I’d be happy to hear about any clue/lead in the regard.

# (this assume wakey.pl is executable and in $PATH)
# wakes you up next time its 6 in the morning:
wakey.pl 06:00

# the same
wakey.pl 6h

# wakes you up exactly in 15 minutes
wakey.pl -t  :15

# the same
wakey.l 15m --timer

# the same but make sure the sound volume wont exceed 70%
wakey.l 15m -t -v 70

To run it, make sure you have debian packages libfile-homedir-perl and libterm-readkey-perl installed. You’ll also need mplayer and amixer properly set up.

Syndicated 2012-02-22 10:32:21 from # cd /scratch

Moving a live system from one hard disk to another

Ever found yourself in the situation where you want to move your GNU/Linux from an old hard disk to a new one. Well, it can be done quite easily :-)

First, set up new partitions with parted then mkswap, mkfs (using proper labels). Yes, I assume you’re familiar with these (RTFM).

Mount the new root partition somewhere, like /mnt/tmp in this article.

Create in this new partition all the directories that it would not make sense to copy from the original system (in my case: home being on another partition, stockage containing only NFS mounts):

cd /mnt/tmp
mkdir dev  home  proc  stockage  sys  tmp mnt

Shut down any daemon/service that is up (cron, etc), to avoid copying stuff in an incoherent state.

Then, actually copy the system:

for dir in /*; do if [ ! -e /mnt/tmp/$dir ]; then cp -ax $dir /mnt/tmp/; fi ; done

Edit /mnt/tmp/etc/fstab to use the newly created partitions.

Chroot in the new system to make it bootable with grub:

mount --bind /dev /mnt/tmp/dev
mount --bind /sys /mnt/tmp/sys
mount proc -t proc /mnt/tmp/proc
chroot /mnt/tmp
# (you can run blkid to check the root's unique id of this
# new system shows up in the new system /boot/grub/grub.cfg)
grub-install /dev/XX  # where XX is the new disk, like /dev/sdc or whatever

Reboot on the new system (stating the obvious: change boot drive order in the BIOS). If everything is fine, then copy /home from the old disk to the new partition, without login in with any system (CTRL-ALT-F2 to quite X server and log in as root, for example).

After removing the old device, re-run update-grub so it’ll no longer show up. The end.

Syndicated 2012-02-20 15:35:24 from # cd /scratch

Getting accurate temperature reading for the CPU

On my main workstation, lm-sensors provides apparently contradictory temperature reading for the CPU, depending on the sensor:

Adapter: PCI adapter
GPU Temperature:  +62.0°C  

Adapter: PCI adapter
CPU Temperature:  +17.0°C  (high = +70.0°C)
                           (crit = +70.0°C, hyst = +68.0°C)

Adapter: ACPI interface
CPU FAN Speed:          1890 RPM  (min =    0 RPM)
CPU Temperature:         +32.0°C  (high = +90.0°C, crit = +125.0°C)
MB Temperature:          +42.0°C  (high = +45.0°C, crit = +90.0°C)

17°C, as reported by the CPU sensor, seems very low especially as the temperature of the room the computer is running inside is at least 17°C already. Clearly, the Motherboard sensor (atk0110 / IT8716F chip) readings, same as what the BIOS reports, are more sensible.

There’s actually lot of misinformation on the web. For instance, CoreTemp author, a proprietary software for MS Windows to provide CPU temperature readings, states on his front page that “all major processor manufacturers have implemented a DTS (Digital Thermal Sensor) in their products. The DTS provides more accurate and higher resolution temperature readings than conventional onboard thermal sensors”. Possibly, probably, right: k10temp may be more accurate than atk0110. However, when the same author reply, on his forum, to a user asking about inconsistencies in CPU temperature readings, clearly interested in real and not relative temperature (he wrote :”I’m running water cooling and the temps aren’t high during load but just wondering about the accuracy”, high temperature is meaningless on an undefined relative scale), that “I’d say that Core Temp is more accurate, especially at higher temperatures. The ASUS programs sensors are based on the motherboard and depend on an external chip. The sensors Core Temp reads are located in the CPU itself and the values are read directly from the CPU registers.”, he clearly shows misunderstanding of what superior accuracy CPU sensors really mean.

As documented by AMD mentioned in the k10temp linux module doc, “[k10temp] is the processor temperature control value, used by the platform to  control cooling systems, [...] is a non-physical temperature on an  arbitrary scale measured in degrees, [...] does not represent an actual  physical temperature like die or case temperature. Instead, it specifies  the processor temperature relative to the point at which the system must  supply the maximum cooling for the processor’s specified maximum case  temperature and maximum thermal power dissipation”.

I was about to publish this article without paying attention to Intel sensors, but a quick search lead to me even worse: a comment about Core Temp in a doc titled CPU Monitoring with DTS/PECI stating : “These tools provide a convenient way to see the temperature variation reported by the sensor [...] There are several issues with these tools. First the assumed value for Tj may not be correct and thus impact the accuracy of actual temperature reporting. Secondly the DTS is only accurate when in the adjacency of Tj. Not knowing the intention and effective range of DTS, the tools try to compensate with the inaccuracy of low temperature reading, which may not be a correct interpretation.”

However accurate they may be, relative readings provided by CoreTemp for AMD K10 are almost meaningless to an end user (while great for the system for fancontrol and such), likely expecting to be able to compare them to other (motherboard|hard disk|etc) readings. In my case, surely k10temp mean something (17°C is low) but it makes no sense to compare it to the room (20°C), GPU (62°C), PATA Hard Disk (39°C), Motherboard (42°) or any other else temperature. In short, except if you know exactly what you’re doing, use Motherboard sensors and if you’re looking for an alternative to CoreTemp, try Open Hardware Monitor.

Syndicated 2012-02-18 15:28:31 from # cd /scratch

RSS feeds: new layout for rawdog

Almost two years ago, I posted an article describing how I use rawdog, a minimalist RSS aggregator to get, on my webserver, an HTML output of my Akregator aggregated feeds. Since then, I changed the layout:

  • articles are no longer shown in four columns,
  • articles descriptions are provided directly on the page and no longer on mouse over the title,
  • there are now several indexes pages, one per day (as many necessary to reach the article limit, set to 950) using plugin dated-output.

I won’t re-describe the whole setup, the relevant files to set up this new rawdog layout are here. On my webserver, it goes in /home/rawdog, using the user rawdog (group www-data). Obviously crontab is actually /etc/cron.d/rawdog and should be edited to refer to proper local users.

I won’t harm, by the way, even if by default unnecessary (could prove useful if, by any chance, your server is configured to interpret perl .pl ou python .py files), to restrict access to rawdogs subdirectories that contains scripts, for instance by adding, for nginx, such statements in the server config:

    location /rss/scripts { deny  all; }
    location /rss/plugins { deny  all; }

Syndicated 2012-02-03 08:27:58 from # cd /scratch

Using RAM for transient data

When a system have lots of I/O, trouble may arise. If an optical hard drive is über-solicited, quite easily you may get many kinds of failures, high CPU load, just because of I/O errors. In such case, using RAM as disk, aka RAM disk, may be a good option, as it allows way more I/O than an optical hard drive. Solid State Drive (SSD) addresses partly this issue, but it seems to, still, have way higher access time and latency than RAM. RAM disk, on the other hand,  is non persistent (unlike SSD, though), quite an annoying drawback so even if you write some scripts to save data, you will loose some in case of power failure.

RAM disk is, actually, especially appropriate for temporary data, like /var/run, /var/lock or /tmp. Linux >= 2.4  supports tmpfs, some kind of RAM disk, that (as far I understand) does not reserve blocks of memory (meaning: it does not matter if you have a big tmpfs, unused memory in the tmpfs will still be available to the whole system).

Most of my computers have more than 1 Gb RAM. And, most of the time, they never use the Swap space. For instance (relevant lines are si and so, as swap in, swap out):

bender:$ vmstat
 procs -----------memory---------- ---swap-- -----io---- -system-- ----cpu----
 r  b   swpd   free   buff  cache   si   so    bi    bo   in   cs us sy id wa
 0  0      0 4146984 674704 1309432    0    0     6     9    3   34  2  1 97  0

nibbler:$ vmstat
procs -----------memory---------- ---swap-- -----io---- -system-- ----cpu----
 r  b   swpd   free   buff  cache   si   so    bi    bo   in   cs us sy id wa
 0  0      0 862044  23944  84088    0    0    10     0   42   22  0  0 99  0

moe:$ vmstat
procs -----------memory---------- ---swap-- -----io---- -system-- ----cpu----
 r  b   swpd   free   buff  cache   si   so    bi    bo   in   cs us sy id wa
 1  0      0 280552 166884 1297376    0    0     7    58   73   12  8  2 90  1

So they are good candidates to use tmpfs whenever possible. Do so with Debian GNU/Linux is fast-forward. Just edit /etc/default/rcS as follows (for /var/run & /var/lock):


and add, in /etc/fstab (for /tmp):

tmpfs             /tmp     tmpfs     defaults    0    0

Next time you boot, diskfree should provide you with something like:

  $ df
Filesystem           1K-blocks      Used Available Use% Mounted on
tmpfs                  1033292         0   1033292   0% /lib/init/rw
varrun                 1033292       648   1032644   1% /var/run
varlock                1033292         0   1033292   0% /var/lock
tmpfs                  1033292         4   1033288   1% /dev/shm
tmpfs                  1033292         0   1033292   0% /tmp

Syndicated 2012-01-30 13:57:36 from # cd /scratch

Booting on a SATA drive with ASUS K8N4-E Deluxe mainboard

I noticed the  ASUS K8N4-E Deluxe mainboard, provided with Phoenix Technologies ACPI BIOS Revision 1008 simply won’t boot with a SATA driver while it does fine with a PATA (IDE) one. Not sure what specific part is at fault here.

 00:06.0 IDE interface: nVidia Corporation CK804 IDE (rev f2)
 00:07.0 IDE interface: nVidia Corporation CK804 Serial ATA Controller (rev f3
 00:08.0 IDE interface: nVidia Corporation CK804 Serial ATA Controller (rev f3)
 05:0a.0 RAID bus controller: Silicon Image, Inc. SiI 3114 [SATALink/SATARaid] Serial ATA Controller (rev 02)

It boots with the following linux kernel options: irqpoll nolapic apm=power_off. I added them into /etc/defaut/grub before regenerating grub.cfg:

GRUB_CMDLINE_LINUX_DEFAULT="quiet irqpoll nolapic apm=power_off"

Note that, however, the shutdown does not halt physically the system. I’ll look into that later.

Syndicated 2012-01-27 19:09:20 from # cd /scratch

Avoiding Spams with SPF and greylisting within Exim

A year ago, I posted an article describing a way to slay Spams with both Bogofilter and SpamAssassin embedded in exim. This method was proven effective for my mailboxes:  since then, during a timespan of one year, Bogofilter caught ~ 85 % of actual spams, SpamAssassin (called only if mail not already flagged defavorably by Bogofilter) caught ~ 15 %. Do the math, I had almost none to flag by hand.

Why would I change such setup? For fun, obviously :-)

Actually, I made no change, I just implemented SPF (Sender Policy Framework) and greylisting.

I noticed that plenty of spams were sent to my server @thisdomain claiming to be sent by whoever@thisdomain. These dirty spams were easily caught by the duo Bogofilter / SpamAssassin, but still, it annoyed me that @thisdomain was misused. SPF allows, using DNS records, to list which servers/computers are allowed to send mails from addresses @thisdomain.   SPF checks are predefined in Exim out of the box, so I’ll skip its configuration. The relevant DNS record (with bind9), allowing only two boxes (primary and secondary mail servers) designated by their IP to send mails @thisdomain, looks like:

thisdomain. IN  TXT  "v=spf1 ip4:78.249.xxx.xxx ip4:86.65.xxx.xxx -all"

Result: Since I implemented SPF on my domains, there was no change in the number of spam caughts. However, during this period, my primary server list of temporary bans dropped from 200/100 IPs to 40/20 IPs. I cannot pinpoint with certainty the cause of this evolution because the temporary bans list depends on plenty of things. But, surely, pretending to send mails @thesedomainsgrilledbySPF surely lost some interest for spambots. Implementing SPF is actually not about helping ourselves directly but indirectly: reducing effectiveness of spambots helps everybody.

I use greylisting on my secondary mail server since a while and I noticed over years that this one almost never had to ban IPs. Not that he never received spam, but that he almost never received mails from very obvious spam sources identified at STMP time.  Seems that most very obvious spam sources never insist enough to pass through greylisting. I guess that most spambots are coded to skip any mail server that does not immediatly accept a proper SMTP transaction, because it has no time to waste, considering how little is the percentage of spams sent actually reaching someone real.

This greylisting use the following files (an assumes memcached and libcache-memcached-perl are properly installed):

So I gave a try using greylist my primary mail server, but with a very short waiting time, because 5 minutes, for example, to receive mail from a not-yet-known  source is not acceptable. So I edited the relevant conf.d/main/ file to GREY_MINUTES = 0.5 and GREY_TTL_DAYS = 25.

Result: no changes regarding the number of caught spams. However, like on the secondary mail server, the number of banned IPs is near to none. Looks like most obvious spam sources don’t wait even only 30 seconds – actually, it’s a very acute choice as they would be anyway banned if they did.

Syndicated 2011-12-09 01:21:43 from # cd /scratch

143 older entries...

New Advogato Features

New HTML Parser: The long-awaited libxml2 based HTML parser code is live. It needs further work but already handles most markup better than the original parser.

Keep up with the latest Advogato features by reading the Advogato status blog.

If you're a C programmer with some spare time, take a look at the mod_virgule project page and help us with one of the tasks on the ToDo list!