Archive

Archive for the ‘God Damnit Linux’ Category

Recovering a Corrupted Banshee Database

February 27th, 2011 11 comments

A couple of nights ago, I left Banshee running overnight, filling my phone with music to listen to the next day at work. Sometime during that process, the media player crashed in a big way, and my entire system ground to a halt. When I woke up the next morning, my computer was frozen solid, with no keyboard or mouse input accepted, and the system clock hadn’t advanced since 11:16pm the previous night. I did a hard reboot, hoping that all would be well when it came back up.

Boy was I wrong.

The Problem

It seems that when Banshee went down, it took my library database file with it. Now, whenever I launch the application, I get a lovely dialog box that looks something like this:


Launching the application from the command line provides more details:

jonf@THE-LINUX-EXPERIMENT: ~/.config/banshee-1$ banshee-1
[Info  11:20:32.175] Running Banshee 1.9.0: [source-tarball (linux-gnu, x86_64) @ 2010-12-09 13:07:07 EST]
[Warn  11:20:32.451] Service `Banshee.Database.BansheeDbConnection’ not started: The database disk image is malformed
database disk image is malformed
[Warn  11:20:32.453] Caught an exception – Mono.Data.Sqlite.SqliteException: The database disk image is malformed

Apparently, the SQLite database that forms the backend of Banshee is severely corrupted, and the application can’t open it for reading. Based on the command line output, I figured that Banshee uses SQLite3 for its database, and after a little bit of research, I found out that it stores the database file at ~/.config/banshee-1/banshee.db. After installing the SQLite3 package from my repositories with the command sudo apt-get install sqlite3, I was able to connect to the database without issue. A little bit of reading over at sqlite.org showed me how to do an integrity check on the database, which came back with some nasty results:

jonf@THE-LINUX-EXPERIMENT:~/.config/banshee-1$ sqlite3 -interactive banshee.db
SQLite version 3.6.22
Enter “.help” for instructions
Enter SQL statements terminated with a “;”
sqlite> PRAGMA integrity_check;
*** in database main ***
Main freelist: 2291 of 2292 pages missing from overflow list starting at 18928
On tree page 28 cell 4: Child page depth differs
On tree page 28 cell 6: 2nd reference to page 15475
On tree page 28 cell 6: Child page depth differs

On tree page 16807 cell 25: Child page depth differs
On tree page 16807 cell 26: 2nd reference to page 18171
On tree page 16807 cell 26: Child page depth differs

Each line of this output refers to a broken or corrupted index, with a total of 99 errors reported. Yikes.

The Solution

Before attempting to fix the problem, I made a backup of the broken database, just in case some data could be resurrected from it. To do this, I made sure that Banshee wasn’t running, and then made a copy of the database file with the command cp ~/.config/banshee-1/banshee.db ~/.config/banshee-1/banshee.db.old.

Since the integrity check showed a number of broken or corrupted indices, I thought perhaps I would be able to recover the database by rebuilding all of its indices. A quick scan of the SQLite documentation turned up the REINDEX function. Again, I connected to the database through the command-line interpreter, and gave it a shot:

jonf@THE-LINUX-EXPERIMENT:~/.config/banshee-1$ sqlite3 -interactive banshee.db
SQLite version 3.6.22
Enter “.help” for instructions
Enter SQL statements terminated with a “;”
sqlite> REINDEX;
Error: database disk image is malformed

That clearly didn’t work.

My next thought was to drop and re-create all of the indices in the database, in hopes that I could rebuild them. I used the graphical tool sqliteman (available from your repositories with the command sudo apt-get install sqliteman) to dump the database schema out to a text file and then scrolled through the file looking for each index. I managed to drop all but four of them, but got the image malformed error whenever I tried to drop the remaining four or recreate any of the ones that were successfully dropped.

Out of ideas, I resorted to attempting to recover what data I could from the mangled file. Using sqliteman, I created a dump of my library data to go along with the schema dump that I had created earlier. The good thing about this dump is that it contains all of the data with none of the indices. Next, I opened up a terminal and navigated to the temporary directory where I had saved the database dump. Using the sqlite3 command line interpreter, I built an image of the old database from the dump:

jonf@THE-LINUX-EXPERIMENT:~/Desktop/banshee$ sqlite3 -interactive banshee.db
SQLite version 3.6.22
Enter “.help” for instructions
Enter SQL statements terminated with a “;”
sqlite> .read dump.sql

Finally, I copied the newly created database into the banshee data directory with the command cp ~/Desktop/banshee/banshee.db  ~/.config/banshee-1/banshee.db.

The next time I started the application, all of my data was restored.

Prevention

I’ve put a lot of work into collecting and maintaining all of the music in my Banshee library. In order to avoid losing all of that work, I’ve decided to write a short script that takes a backup image of the library database every so often, and puts it in a safe place on my hard drive. Once I get that put together, I’ll throw it up on here for so that everybody can use it.




On my Laptop, I am running Linux Mint 12.
On my home media server, I am running Ubuntu 12.04
Check out my profile for more information.

Well, Here Goes Nothing

December 14th, 2010 No comments

During a routine update of my Fedora 13 system, I received the following notification:

You’ll notice, upon careful inspection, that the update utility would like to remove my kernel. This ought to be fun.




On my Laptop, I am running Linux Mint 12.
On my home media server, I am running Ubuntu 12.04
Check out my profile for more information.
Categories: God Damnit Linux, Jon F Tags:

Why I Hate Samba

December 12th, 2010 9 comments

This file copy is running over my local wireless network:

Apparently Samba uses less than 1% of available network bandwidth for file copies...

That is all.




On my Laptop, I am running Linux Mint 12.
On my home media server, I am running Ubuntu 12.04
Check out my profile for more information.
Categories: God Damnit Linux, Jon F Tags: , ,

Unwanted Effects on my Line-in Interface

August 26th, 2010 No comments

Shortly after purchasing an xbox360, I wrote a short piece that gave instructions for forwarding your line-in audio through your pc speakers. By using this method and sharing my network connection, I’ve managed to run my xbox as a peripheral to my main computer setup, saving me space and money.

Lately however, the line-in loopback has not been working as expected. At times, it sounds like effects have been applied to the line. In particular, it sounds like somebody has applied a phaser or a delay effect to the input signal.

For the last week or so, I’ve been scratching my head about this issue, trying to figure out what part of my system may have applied effects to my loopback, but not to other audio on the system. Tonight, I was reviewing my original instructions for setting the thing up, and noticed that the module was being loaded on startup after being added to a system config file:

sudo sh -c ' echo "load-module module-loopback" >>  /etc/pulse/default.pa '

On a hunch, I took a look at the end of the file, and found the following lines:

### Make some devices default
#set-default-sink output
#set-default-source input
load-module module-loopback
load-module module-loopback

It looked like the instruction to load the loopback module had ended up in the config file twice! Because of this, the module was being loaded twice on startup.

So what does this have to do with the effects on the line? Well, if you play two copies of the same sound with a half-second gap between them, your ears will be tricked into thinking that you’re hearing one copy of the sound, but that it’s all echoey, as if a delay effect had been applied. If you repeat the experiment but this time decrease the gap between the two sounds even further, say to a few milliseconds, your ears will hear one copy of the sound with a phaser effect applied.

Essentially, when the module loaded twice, it was capturing the mix from the line-in port twice and playing back two separate copies of the audio. Depending on how close together these instances  were, the result sounded normal, phased, or delayed. I fixed the issue by removing one of the lines and then restarting the machine. This time, it started only one copy of the service, and everything sounded fine.

The moral of the story: If you’re loading modules at startup, make sure that you only start one copy of them.




On my Laptop, I am running Linux Mint 12.
On my home media server, I am running Ubuntu 12.04
Check out my profile for more information.

PulseAudio: Monitoring your Line-In Interface

July 11th, 2010 21 comments

At home, my setup consists of three machines -  a laptop, a PC, and an XBOX 360. The latter two share a set of speakers, but I hate having to climb under the desk to switch the cables around, and wanted a better way to switch them back and forth. My good friend Tyler B suggested that I run the line out from the XBOX into the line-in on my sound card, and just let my computer handle the audio in the same way that it handles music and movies. In theory, this works great. In practice, I had one hell of a time figuring out how to force the GNOME sound manager applet into doing my bidding.

After quite a bit of googling, I found the answer on the Ubuntu forums. It turns out that the secret lies in a pulse audio module that isn’t enabled by default. Open up a terminal and use the following commands to permanently enable this behaviour. As always, make sure that you understand what’s up before running random commands that you find on the internet as root:

pactl load-module module-loopback
sudo sh -c ' echo "load-module module-loopback" >>  /etc/pulse/default.pa '

The first line instructs PulseAudio (one of the many ways that your system talks with the underlying sound hardware) to load a module called loopback, which unsurprisingly, loops incoming audio back through your outputs. This means that you can hear everything that comes into your line-in port in real time. Note that this behaviour does not extend to your microphone input by design. The second line simply tells PulseAudio to load this module whenever the system starts.

Now if you’ll excuse me, I have jerks to run over in GTA…




On my Laptop, I am running Linux Mint 12.
On my home media server, I am running Ubuntu 12.04
Check out my profile for more information.

Adobe Air and Fedora 12

March 22nd, 2010 2 comments

This weekend, I installed Fedora 12 (Constantine) on my laptop, and I have to say that so far, I’m impressed. Thanks to the standard GNOME desktop, it looked familiar, and felt like a more polished version of the Debian desktop that I’m used to. The installation only took 15 minutes, and almost everything worked immediately.

One of the only things that I’ve had troubles with thus far is Adobe AIR. Now normally, I avoid Adobe apps like they’re the plague, since the great ones are really expensive (Photoshop, Premiere, etc), and the free ones are awful and full of security holes (Reader, Flash on anything but Windows). In this case however, I got hooked on the AIR framework because of Tweetdeck, an excellent little application that makes managing Twitter feeds a dream.

Unfortunately, it doesn’t work worth a shit on Fedora 12.

Now most AIR apps ship with an installer that will put the framework on your system if you don’t already have it. I’ve always had problems with this method on Linux, and have instead downloaded AIR directly from Adobe as a *.bin file, and installed it manually from a root terminal.

The next step is to install the app. In the case of Tweetdeck, the process is a little bit convoluted because they use a Flash widget on their website (Christ, why?) that starts the installation for you – sketchy from a security standpoint, but it’s always worked well for me in the past. Under Fedora, the installer just crashed.

Hoping for a workaround, I downloaded the *.air installer file to my desktop and tried to use the Adobe AIR Application Installer from my root terminal to do the job. All that got me was a bunch of angry error text. After a quick IxQuicking, I found this blog post with some answers in the comments:

#delete the AIR certs:
rm -rf /etc/opt/Adobe/certificates/crypt/

#install your application like this:
su – /opt/Adobe\ AIR/Versions/1.0/airappinstaller /path/to/install/file.air

While this worked, and the install actually completed (albeit with a bunch of angry error messages yelling at me for deleting the AIR security certs), Tweetdeck failed to function on launch first launch, complaining about Adobe AIR failing, and requesting that I file a bug.

Luckily, one quick restart later, and everything worked perfectly.

So long story short, AIR is kinda dirty on Fedora, and doesn’t work as well as on other distributions. Everything else, however, works great.




On my Laptop, I am running Linux Mint 12.
On my home media server, I am running Ubuntu 12.04
Check out my profile for more information.

Empathy: What a Piece of Garbage

March 20th, 2010 17 comments

The Empathy instant messaging client for Gnome is not yet ready to be the default client on your favourite Gnome-based distribution. In fact, I can’t even make it work! Tyler B originally posted about this problem way back in October, but it doesn’t seem to have been fixed during the interim.

To demonstrate my point, allow me to walk you through the process of adding an MSN account, one of the officially supported protocols, to a clean install of Empathy:

  1. After launching Empathy, select Accounts from the Edit menu:

    The accounts manager for Empathy

    Hey guys, nice UI. Way to give that listbox a default width. And why the hell is this dialogue box so big, anyway?

  2. Select the MSN protocol from the dropdown menu, and hit the create button:

    The list of protocols that Empathy "supports"

    Wow, way to get icons for every protocol, guys. Either have icons, or don't, ok?

  3. Enter your MSN email address and account password, and hit the Connect button:

    Adding my account details to the new MSN account in Empathy

    Hey, see that Add button under the listbox? If I click that, I can add a new account, before even finishing with this one! Wow, recursion in a GUI! Sweet!

  4. With the new account created, hit the Close button, and watch as the authentication of your newly added MSN account fails:

    Authentication of my newly added account failed

    Wouldn't you know it, my freshly minted account failed to authenticate. I wonder what the problem is...

  5. Hit the Edit Account button, and open up the Advanced area of the Account Manager window that pops up:

    The Advanced area of the Account Manager window in Empathy

    Have you ever seen anything communicate over port 0? I haven't

  6. Open up your working copy of the trusty Pidgin instant messenging client, put the correct port number into the Port textbox in Empathy, and try to figure out how to save your changes:

    Empathy notifies me that I have unsaved changes

    Since I couldn't click apply, I hit Close. Empathy warned me that I hadn't saved my changes, and only then enabled the Apply button in the Account Manager window... Fuck me

  7. Watch as, even with the correct Server and Port information, Empathy continues to fail miserably at connecting to an MSN account:

    The contact list again

    Hey, it's still failing to connect. Imagine that.

The Bottom line? This application is buggy, untested, incompatible, falsely-advertised garbage. I want my Pidgin back. It may have some rough edges, but at least it connects. How these glaring errors and this horrible GUI design ever got past the community is beyond me. I do hope that Empathy has something even somewhat mediocre up their sleeves for their 2.29 release, but until then, I’m headed back to Pidgin.




On my Laptop, I am running Linux Mint 12.
On my home media server, I am running Ubuntu 12.04
Check out my profile for more information.

Pulse Audio Nonsense

January 4th, 2010 3 comments

Just a heads up: This isn’t the kind of post that contains answers to your problems. It is, unfortunately, the kind of post that contains a lot of the steps that I took to fix a problem, without much information about the order in which I performed them, why I performed them, or what they did. All that I can tell you is that after doing some or all of these things in an arbitrary order, stuff seemed to work better than it did before.

It’s funny how these posts often seem to come about when trying to get hardware related things working. I distinctly remember writing one of these about getting hardware compositing working on Debian. This one is about getting reliable audio on Kubuntu 9.10.

You see, I have recently been experiencing some odd behaviour from my audio stack in Kubuntu. My machine almost always plays the startup/shutdown noises, Banshee usually provides audio by way of GStreamer, videos playing in VLC are sometimes accompanied by audio, and Flash videos almost never have working sound. Generally speaking, restarting the machine will change one or all of these items, and sometimes none. The system is usuable, but frustrating (although I might be forgiven for saying that having no audio in Flash prevents me from wasting so much time watching youtube videos when I ought to be working).

Tonight, after some time on the #kubuntu IRC channel and the #pulseaudio channel on freenode, I managed to fix all of that, and my system now supports full 5.1 surround audio, at all times, and from all applications. Cool, no? Basically, the fix was to install some PulseAudio apps:

sudo apt-get install pulseaudio pavucontrol padevchooser

Next, go to System Settings > Multimedia, and set PulseAudio as the preferred audio device in each of the categories on the left. Finally, restart the machine a couple of times. If you’re lucky, once you restart and run pavucontrol from the terminal, you’ll see a dialog box called Volume Control. Head over to the Configuration tab, and start choosing different profiles until you can hear some audio from your system. Also, I found that most of these profiles were muted by default – you can change that on the Output Devices tab. If one of the profiles works for  you, congratulations! If not, well, I guess you’re no worse off than you were before. I warned you that this was that kind of post.

Also, while attempting to fix my audio problems, I found some neat sites:

  • Colin Guthrie – I spoke to this guy on IRC, and he was really helpful. He also seems to write a lot of stuff for the PulseAudio/Phonon stack in KDE. His site is a wealth of information about the stack that I really don’t understand, but makes for good reading.
  • Musings on Maintaining Ubuntu – Some guy named Dan who seems to be a lead audio developer for the Ubuntu project. Also a very interesting read, and full of interesting information about audio support in Karmic.
  • A Script that Profiles your Audio Setup – This bash script compiles a readout of what your machine thinks is going on with your audio hardware, and automatically hosts it on the web so that you can share it with people trying to help you out.
  • A Handy Diagram of the Linux Audio Stack – This really explains a lot about what the hell is going on when an application tries to play audio in the Linux.
  • What the Linux Audio Stack Seems Like – This diagram reflects my level of understanding of Linux audio. It also reminds me of XKCD.
  • Ardour – The Digital Audio Workstation – In the classic tradition of running before walking, I just have to try this app out.



On my Laptop, I am running Linux Mint 12.
On my home media server, I am running Ubuntu 12.04
Check out my profile for more information.

Kubuntu 9.10 (Part II)

January 4th, 2010 No comments

Well I managed to fix my compositing problem but I honestly don’t know why it worked. Basically I went into the System Settings > Desktop > Desktop Effects menu and manually turned off all desktop effects. Next I used jockey-text to disable the ATI driver. After a quick restart I re-enabled the ATI driver and restarted again. Once I logged in I went back into the System Settings > Desktop > Desktop Effects menu and enabled desktop effects. This magically worked… but only until I restarted. In order to actually get it to start enabled I had to go back into System Settings > Desktop > Desktop Effects and then click on the Advanced tab and then disable functionality checks. I am sure this is dangerous or something but its the only way I can get my computer to restart with the effects enabled by default.

I’m really starting to hate this graphics card…




I am currently running a variety of distributions, primarily Linux Mint 17.
Previously I was running KDE 4.3.3 on top of Fedora 11 (for the first experiment) and KDE 4.6.5 on top of Gentoo (for the second experiment).
Check out my profile for more information.

Linux Saves the Day

December 23rd, 2009 5 comments

Earlier this week I had an experience where using Linux got me out of trouble in a relatively quick and easy manner. The catch? It was kind of Linux’s fault that I was in trouble in the first place.

Around halfway through November my Linux install on my laptop crapped out, and really fucked things up hard. However, my Windows install wasn’t affected, so I started using Windows on my laptop primarily, while switching to an openSUSE VM on my desktop for my home computing needs.

About a week back I decided it was time to reinstall Linux on my laptop, since exams and my 600 hojillion final projects were out of the way. I booted into Win7, nuked the partitions being used by Linux and… went and got some pizza and forgot to finish my install. Turns out I hadn’t restarted my PC anywhere between that day and when shit hit the fan. When I did restart, I was informed to the merry tune of a PC Speaker screech that my computer had no bootable media.

… Well shit.

My first reaction was to try again, my second was to check to make sure the hard drive was plugged in firmly. After doing this a few times, I was so enraged about my lost data that I was about ready to repave the whole drive when I had the good sense to throw in a BartPE live CD and check to see if there was any data left on the drive. To my elation, all of my data was still in tact! It was at this precise moment I thought to myself “Oh drat, I bet I uninstalled that darned GRUB bootloader. Fiddlesticks!”

However, all was not lost. I know that Linux is great and is capable of finding other OS installs during its install and setting them up in GRUB without me having to look around for a windows boot point and do it myself. 20 minutes and an openSUSE install later, everything was back to normal on my laptop, Win7 and openSUSE 11.1 included!

As we speak I’m attempting an in-place upgrade to openSUSE 11.2 so hopefully I get lucky and everything goes smoothly!