How To: Downgrade libcairo2 in Debian (and fix Evince)

Evince crashing with a libcairo segfault like this?

It’s a libcairo2 1.12.2-2 issue – which you can thankfully fix by downgrading libcairo2 to a 1.10.2 incarnation – here’s how…

Check package availability

First check you have an alternate version to downgrade to. To do this in Synaptic select the libcairo2 package then click on the Versions tab at the bottom, or you can do the same check via a swift apt-cache policy libcairo2 as shown below:

In this case the older (but functional) package 1.10-2-2ubuntu2 is available. Let’s assume there’s an older package you can use – if not, go get one from elsewhere.

Uninstall and force a different version

Uninstall libcairo2 using any manner you like – this will also force removal of things like Evince as dependencies, unless you see anything spectacular that you know you need just let it.

Then in Synaptic, search for libcairo2, select it (i.e. click on it), then from the Synaptic menu choose Package > Force Version and choose the older, working package, and install it.

Next, you’ll want to lock to that version so it doesn’t get upgraded (at least until there’s a newer working version), so again from the menu just select Package > Lock Version.

Reinstall libcairo-using things

Finally, reinstall what was ailing ya and everything should work fine. In my case at least, this means I can reinstall the Evince PDF viewer and it’ll now print to PDF without segfaulting – Huzzah! =D

I’ve no doubt you can do this entire process from the command line, but it’s easy and works through Synaptic so I’ll leave that as an exercise for the reader.

As an added bonus, if you’re experiencing slow display and/or corrupted text in Iceweasel or Chromium then the downgrade should fix that up too. You can read more about which here.

How To: Properly automount NTFS and vfat partitions in Linux using fstab

This is more for my own notes than anything else, but to properly mount NTFS or vfat (i.e. FAT16/FAT32) partitions in Linux, first find the UUID of the drive using:

For example:

To mount NTFS or vfat partitions properly, you need to specify dmask (directory mask) and fmask (file mask) values, which as you might expect are the MASKS of the values you want to use (i.e. the octal compliments). Yeah, I’m not sure why it’s done this way either, but to calculate the mask value just subtract the value you want from 7.

As long as you know the following you should be just fine:

  • Read is 4,
  • Write is 2, and
  • Execute is 1.

For example:

  • If you want to mount the drive with 777 permissions (owner, group and other all r+w+x), then the mask of that is 000 – i.e. 7-7 = 0 for read, write and execute
  • If you want to mount the drive with 751 permissions (owner r+w+x, group r+x, other x), then the mask is 026 – i.e. 7 – 7 = 0, 7 – 5 = 2, 7 – 1 = 6)

So once you’ve identified your partition, you can add the following to your /etc/fstab file to have it mount automatically on boot:

So if I want to automatically mount my sdb3 partition at boot (which I know is formatted as ntfs) at /media/DATA with 755 permissions (owner r, group r+X, other r+x, i.e. 022 mask), I could use:

For the user ID (uid) or group ID (gid) values, you can use the numerical or actual values, i.e. uid=r3dux,gid=r3dux is fine, as is uid=1000,gid=1000 etc.

The first user account and group ID for any user on a Linux system are generally 1000.

If you’re not sure of your uid or gid values, just enter id in a terminal and it’ll tell you:

Happy NTFS & vfat automouting ;-)

How-To: Install the latest version of Wine in LMDE

Wine Logo transparent backgroundFeb 2013 Update: More recent versions of Wine are now available in the standard LMDE repositories, so skip all the headache below and just install Wine with a s swift sudo apt-get install wine and you’re done!


The Wine “not-emulator” allows you to run Windows software under Linux, but the version in the Debian testing repos (themselves cutting edge) is pretty old, at time of writing it’s a 1.3.6 variant, while Wine 1.5.0+ is now available. Unfortunately, upgrading can be a bit of a pig if you want to build Wine yourself, so a far better solution is to find some Debian binaries and install them. So let’s do that…

Getting the Debian binaries

Wine binaries are available for a whole heap of different platforms, distros and architectures from http://www.winehq.org/download/, but in this case I’m installing on Debian, so if you are too, head on over to http://dev.carbon-project.org/debian/wine-unstable/ and grab the following packages (either 32 or 64 bit, depending on your architecture – I’m using 64-bit LMDE so I’ll use the 64-bit package names for this quick guide):

  • libwine-alsa-unstable_1.5.0-0.2_amd64.deb
  • libwine-bin-unstable_1.5.0-0.2_amd64.deb
  • libwine-capi-unstable_1.5.0-0.2_amd64.deb
  • libwine-cms-unstable_1.5.0-0.2_amd64.deb
  • libwine-dbg-unstable_1.5.0-0.2_amd64.deb
  • libwine-dev-unstable_1.5.0-0.2_amd64.deb
  • libwine-gl-unstable_1.5.0-0.2_amd64.deb
  • libwine-gphoto2-unstable_1.5.0-0.2_amd64.deb
  • libwine-ldap-unstable_1.5.0-0.2_amd64.deb
  • libwine-openal-unstable_1.5.0-0.2_amd64.deb
  • libwine-oss-unstable_1.5.0-0.2_amd64.deb
  • libwine-print-unstable_1.5.0-0.2_amd64.deb
  • libwine-sane-unstable_1.5.0-0.2_amd64.deb
  • libwine-unstable_1.5.0-0.2_amd64.deb
  • wine-bin-unstable_1.5.0-0.2_amd64.deb
  • wine-unstable_1.5.0-0.2_amd64.deb

Satisfying Dependencies

jp helpfully provided details that for the above packages to install without issue, you’ll first need to install the packages:

  • libc6-i386
  • lib32asound2
  • libc6-dev-i386

So do that via your mechanism of choice, for example, if you use apt-get then you can install them though a simple:

Replacing Wine

Before you can install any new Wine stuff, you’ll first have to uninstall the wine package. Do that through whatever means you feel most comfortable with, ya know, synaptic, apt, dpkg etc.

Once that’s done, you’ll want to install all the libwine packages through dpkg (to be honest, you might not need them all – but it doesn’t hurt, and you’ll certainly need most of them).

To install all the libs, open up the location you saved all the .deb files to in the console, and run:

Once that’s completed successfully, in the same location run:

And finally, in the same location again, run:

Almost done!

Getting the gecko engine

At this point we’re 99% complete, we just need to launch winecfg and let it install the Gecko engine for web-browser shenanigans (again, you might not need this – but there’s no harm in it, and Wine’ll moan at you about it if you don’t). So just run:

And when it prompts you about gecko, just click on [Install].

Ta-da!

New cutting-edge Wine goodness is now yours to play with, although from this point on you won’t get automatically updated as wine won’t be installed from any repository. For this reason, it’s worth holding onto all the debs so you can uninstall them with ease via a swift sudo dpkg -P *.deb (-P for purge) if at a later date you want to go back to the repo version.

As Bryant would say – Drink some for me, eh, pal? ;)

How-To: Fix slow reconnection to Wireless after suspend/sleep in Linux

Every time I’d put my LMDE-running machine to sleep the wireless wouldn’t come up for maybe a minute or so, which isn’t ideal. This could be caused by a variety of conditions, but in my case it turned out that the IPv6 “Automatic” setting was trying to use IPv6 DHCP, and was waiting for this to time-out before accepting the IPv4 DHCP lease.

To change this behaviour, you can modify the IPv6 settings from Automatic to Ignore, like this:

Disabling IPv6 in Gnome 3

If you’re not using Gnome Shell (like in the above screenshot), then maybe try modifying /etc/network/interfaces – really, it’ll depend on your Linux distro where the config is located.

Once IPv6 was disabled the IPv4 DHCP lease was accepted immediately on resume – and it could be the case that if you’ve got the same symptom that it’s caused by the same issue. Regardless, it’s certainly one of the easier things worth trying before you go looking into more involved solutions.

Source: https://bugzilla.redhat.com/show_bug.cgi?id=708450.

VPS hosting – Linode FTW

Linode logo transparentWhen I migrated this site from shared hosting to a VPS, I initially went with some really cheap hosting, and I got what I paid for: The site went down often, like every week or so. Sometimes for days at a time. Support tickets went ignored and unanswered, and I was generally a sad puppy.

After a month or two of this I’d had enough, and decided to migrate the site hosting away from Cheap-O-Host to a company called Linode – and I’ve got to say – it’s been absolutely flawless ever since. I can’t even remember the last time the site went down.

This isn’t to say I haven’t had issues with Apache bogging down and basically killing the site by trying to use more RAM than the VPS has available. If I got more concurrent connections than I had RAM for, then some il-advised Apache settings meant that the server would get into swap territory, and the entire thing would grind to a halt from which the only escape was to log into the VPS from the web interface and reboot it. But this wasn’t Linode’s fault – it was mine for trying to do to much with too little.

I finally solved the problem by disabling all the apache modules I didn’t need (which lowered the RAM usage per Apache process, as well as lowering the server’s attack surface), and limiting the concurrent connections to a number that would happily fit within 512MB of RAM – and since then, not a cough or a hiccup. Everything has been running beautifully.

In fact, at the time of writing, my VPS uptime stats are:

244 days without as much as a reboot! Sweet!

I’m just writing this post to commend Linode because I got yet another monthly email (from siteuptime.com) today saying “site up-time: 100%” and… well, if something goes wrong then people (and definitely me included, here) tend to jump up and down and make a noise – but when something goes right – we generally don’t say anything at all. Which makes the cost of failure getting slagged off, and the reward for success merely not getting slagged off.

As that’s not a particularly good system, I wanted to say something positive about Linode, because it’s not an accident that their systems so rarely go down – I’m sure that it’s entirely due to their hard work, professionalism, and investment & re-investment in the company infrastructure. And I absolutely cannot fault them on that.

So well done, Linode! You guys rock! =D

P.S. For anyone trying to minimise their apache footprint, the minimal set of apache modules I found I needed to run a wordpress site are:

  • alias
  • authz_default
  • deflate
  • dir
  • env
  • expires
  • headers
  • mime
  • php5
  • reqtimeout
  • rewrite, and
  • setenvif

And my final, working Apache prefork MPM settings in apache2.conf for a VPS with 512MB of RAM are:

In my experience, the above config will happily serve tens of thousands of hits per day without getting to a stage where a VPS with 512MB of RAM starts to page out excessively, and without dropping incoming connections. Of course, this won’t stop a site getting flattened, but it’s a pretty good middle ground to cope with a large amount of hits with a low amount of RAM.

Cheers!