Squeeze LXC container in Debian Squeeze

August 31st, 2011

In Debian Squeeze, the default lxc-debian script installs a Lenny container. The bug was reported and fixed in version 0.7.4 of LXC.
To install Squeeze container first download Syd’s version of LXC (currently 0.7.5-1), unpack it and find the lxc-debian file (lxc_0.7.5-1_amd64.deb —> data.tar.gz -> /usr/lib/lxc/templates/lxc-debian). Copy the file to your machine/server, make it executable and in the same folder run:

./lxc-debian -p /var/lib/lxc/name_of_container

Useful resource:
blog.foaa.de/2010/05/lxc-on-debian-squeeze

Finding duplicate entries in MySQL database

July 7th, 2011

On upgrading my Moodle installation from version 1.9 to 2.1 the upgrade process (initiated from command line) exited with the following error:

!!! Error reading from database !!!
!! Illegal mix of collations (utf8_general_ci,IMPLICIT) and (utf8_unicode_ci,IMPLICIT) for operation '='
SELECT po.id AS oldpage_id, po.pagename AS oldpage_pagename, po.version, po.flags,
                   po.content, po.author, po.userid AS oldpage_userid, po.created, po.lastmodified, po.refs, po.meta, po.hits, po.wiki,
                   p.id AS newpage_id, p.subwikiid, p.title, p.cachedcontent, p.timecreated, p.timemodified AS newpage_timemodified,
                   p.timerendered, p.userid AS newpage_userid, p.pageviews, p.readonly, e.id AS entry_id, e.wikiid, e.course AS entrycourse,
                   e.groupid, e.userid AS entry_userid, e.pagename AS entry_pagename, e.timemodified AS entry_timemodified,
                   w.id AS wiki_id, w.course AS wiki_course, w.name, w.summary AS summary, w.pagename AS wiki_pagename, w.wtype,
                   w.ewikiprinttitle, w.htmlmode, w.ewikiacceptbinary, w.disablecamelcase, w.setpageflags, w.strippages, w.removepages,
                   w.revertchanges, w.initialcontent, w.timemodified AS wiki_timemodified,
                   cm.id AS cmid
              FROM wiki_pages_old po
              LEFT OUTER JOIN wiki_entries_old e ON e.id = po.wiki
              LEFT OUTER JOIN wiki w ON w.id = e.wikiid
              LEFT OUTER JOIN wiki_subwikis s ON e.groupid = s.groupid AND e.wikiid = s.wikiid AND e.userid = s.userid
              LEFT OUTER JOIN wiki_pages p ON po.pagename = p.title AND p.subwikiid = s.id
              JOIN modules m ON m.name = 'wiki'
              JOIN course_modules cm ON (cm.module = m.id AND cm.instance = w.id)

Summed up — an “Illegal mix of collations” was occurring while querying the table wiki_pages_old. A quick search found a possible solution. Unfortunately (for now) I’m not really sure if it helped, since the error persisted, but it is worth of making a note of it until being sure (by migrating the production server).

So I went in with phpMyAdmin and changed the collation on the table manually, which didn’t help either, since it didn’t change the collation of the individual fields. So I changed the fields’ collation manually, except for one field, which — after changing the collation — started to report a duplicate entry. After some trial and error I’ve found a solution.

From the table dump file I’ve deleted the offending key and after importing the table into the database I’ve searched for the offending duplicate entries.

The following MySQL query, from MySQL forum, finds the duplicate entries.

SELECT t1.* FROM t1 INNER JOIN (
SELECT colA,colB,COUNT(*) FROM t1 GROUP BY colA,colB HAVING COUNT(*)>1) as t2
ON t1.cola = t2.cola and t1.colb = t2.colb;

In my case the upper query changes into this:

SELECT wiki_pages_old.* FROM wiki_pages_old INNER JOIN (
SELECT pagename,version,wiki,COUNT(*) FROM wiki_pages_old GROUP BY pagename,version,wiki HAVING COUNT(*)>1) as wiki_t2
ON wiki_pages_old.pagename = wiki_t2.pagename and wiki_pages_old.version = wiki_t2.version and wiki_pages_old.wiki = wiki_t2.wiki;

I’ll write some more details after migrating the production server.

Audio and Video Manipulation With ffmpeg

July 5th, 2011

In order to avoid always re-learning same things I’m listing few useful commands. For more detail and information go here.

Any video/audio to OGG/Vorbis

fmpeg -i source.file -vn -acodec libvorbis -aq 6 audio.ogg

The -vn option disables video recording — omit if source is audio file. The -aq option stands for audio quality. The value of 6 results roughly at 192 kbit/s. For other values check this table.

Any audio/video to mp3

ffmpeg -i source.file -vn -ar 44100 -ac 2 -ab 192 -f mp3 sound.mp3

The -vn option disables video recording — omit if source is audio file; -ar sets the audio sampling frequency; -ac number of audio channels; -ab audio bitrate in bit/s; -f forces mp3 format.

Instaling from source with Checkinstall

January 31st, 2011

If everything goes well, all you need to do is run the commands below.

$ ./configure
$ make
# checkinstall -D make install

You’ll end up with installed package or deb package to install with dpkg. In either case you can simply remove the package and all it’s files with apt-get or other package manager..

References:

Setting up Logwatch

January 31st, 2011

Checking logs is the only way to know what’s happening with your servers and one way to check them is using Logwatch.

Installing it on Debian is easy:
apt-get install logwatch

On my virtual Debian host there was no configuration file in the expected place so I copied it from /usr/share/logwatch/default.conf folder:
cp /usr/share/logwatch/default.conf/logwatch.conf /etc/logwatch/conf/

Things you must change in this file are:

  • Output = mail
  • MailTo = your.mail@example.com
  • Detail = High

The rest is optional and subject to your needs. The logwatch.conf is well documented.

Create folder /var/cache/logwatch needed by logwatch as specified in logwatch.conf.
# mkdir /var/cache/logwatch

Test the setup by running:
# logwatch

To finish the automatism edit the /etc/cron.daily/00logwatch file, removing --mailto: root option to receive mails to the address we specified in logwatch.conf file.

References:

Upgrade Debian over slow Internet connection

October 14th, 2010

It was a moderately cold fall evening when I finally decided to do upgrade to Squeeze on my home computer. I have a 2MB line at home, sharing it with two other users. Apt-get dist-upgrade announced two and half hours of downloading at full speed and as it was evening I didn’t want to cut off other users. I have an 1GB optical line straight from my office to one of Debian mirrors, so I’ve decide to do downloading at work.

After short googling I’ve came accross this comment and this manual. The steps below are a combination of both.

  1. At home I’ve run the following command:
    apt-get --print-uris -y dist-upgrade | grep "^'" | gawk '{ print $1 }' | sed "s/'//g" > packages.lst
  2. Sent myself the packages.lst to the office with fast connection and there run the command below in an empty folder on a portable device. You can use -P option to specify the destination folder.
    wget -i packages.lst
  3. Back at home I’ve run:
    apt-get -o dir::cache::archives="/folder/on/portable/disc/" dist-upgrade

Package and Install PHP extension

May 17th, 2010

No need to use too many words.
Go to wwwdotdeb.org and follow step-by-step instruction for downloading PECL extension, making DEB package and installing it with dpkg.

Fixing Grub in Debian Rescue Mode

December 15th, 2009

Today Grub experienced a hiccup which left me with crippled Grub rescue mode complaining about “symbol ‘grub_printf_’ not found“. Searching Google gave me just one hit — an German forum page from yesterday bearing no solution yet.

After trying many known things I eventually created a satisfiable solution — bootable system. Not knowing how to fix Grub I decided to downgrade Grub 2 to Grub 1 and the only way to do this is using rescue mode on Debian install disc. The procedure goes as follows:

  • Boot from Debian install disc for architecture you use (i.e. amd64). In the boot menu choose help option as it offers you the option to use the “old-style” command line boot options. The default rescue-mode shell lacks some variables needed for installing/removing packages form the system, so it is useful to start rescue-mode with the following boot option (it enables the user input needed during some instal/remove processes): rescue debian-installer/framebuffer=false
    It is also possible to do this later by running TERM=vt100; export TERM in command-line.
  • Follow the procedure that looks pretty much as installation procedure, but after certain point it offers you the option to choose the partition to use as a root system. At this point it is good if you know which one is it. Next menu lets you enter the command line in which you can alter your system.
  • Using apt-get I first removed the Grub 2 installation (just in case leaving behind configuration files) and then installed the grub-legacy package. After some configuring
    #grub
    grub> find /boot/grub/stage1
    (hd0,1)
    (hd1,0)
    grub>root (hd1,0)
    grub>setup (hd1)
    grub>quit

    and

    #update-grub

    the new “good-old” Grub 1 installation was ready for reboot.

Java plugin on 64 bit Debian

April 3rd, 2009

Well, finaly I did it. After installing everything I could imagine it might help and trying out all possible solutions I have Java plugin finally working in Iceweasel.

The solution was found on Java bug #4802695 first reported on 14-JAN-2003. The helpful comment #514 made by cava on 14-DEC-2008 said:

It works finally !!! Just need to link java-6-sun-1.6.0.12/jre/lib/amd64/libnpjp2.so in the Firefox plugins directory and we have it !!!!!!!!!!!!!!!!!!!

The command needed was:
ln -s /usr/lib/jvm/java-6-sun-1.6.0.12/jre/lib/amd64/libnpjp2.so ~/.mozilla/plugins/libjavaplugin.so

Flash player for 64 bit Debian

March 23rd, 2009

Quoting Frederik Kriewitz’s reply on debian-user mailing list:

Download the 64 Bit plugin from
http://labs.adobe.com/downloads/flashplayer10.html
extract it and copy and copy libflashplayer.so to /usr/lib/iceweasel/plugins/

Update (11/25/2009):
The new link to 64-bit version is:
http://labs.adobe.com/technologies/flashplayer10/64bit.html