Linux backup/restore and grub2 reinstall

July 23, 2012 Leave a comment

Not exactly related to MythTV, but very useful because MythTV often breaks when upgrading, so you want to be able to easily restore an old version.

In order to backup linux, I use dump and restore.

You can backup your system drive by booting into rescue mode and running the following:

/sbin/dump -0 -v -a -y -f- -L “Linux root partition” /dev/sda1 1>filename.dump 2>filename.log

To restore, use the rescue mode of the installation DVD and mount the drive you want to restore to. Then go to the root directory of that drive and type:

/sbin/restore -r -f /location-of-dump-file/filename.dump

I’ve used this approach successfully for a long time. Now with the switch to grub2, I had to figure out how to reinstall grub2 on the disk after doing the restore.

After a lot of googling, I finally figured it out and wrote the following script:

read -p “Press ENTER to restore grub2…”

echo Mounting /dev/sda1 to /mnt/sda1 – these may already be mounted
mkdir /mnt/sda1
mount /dev/sda1 /mnt/sda1

echo Mounting bindings
mount –bind /dev /mnt/sda1/dev
mount –bind /proc /mnt/sda1/proc
mount –bind /sys /mnt/sda1/sys

read -p “Press ENTER to install grub”;
echo Installing grub and configuring it for local drive
chroot /mnt/sda1/ /bin/sh -c “/sbin/grub2-install /dev/sda; /sbin/grub2-mkconfig -o /boot/grub2/grub.cfg”

WARNING 1: You will want to change your drives/partitions listed in these scripts.

WARNING 2: Always do regular test runs of backup and restore – you want to be 100% sure they work when you need them! This is easy if you get an extra harddrive that you can test with.

WARNING 3: I’m not responsible for your data or the correctness of the scripts above. Use the above scripts/commands at your own risk!


MythTV EIT language

July 23, 2012 Leave a comment

I just upgraded from MythTV 0.23 to 0.25. One of the issues I noticed was that I started getting DVB EIT data with mixed languages. Living in Finland, we get EIT data in both Finnish and Swedish. I set the preferred languages in the MythTV frontend, but they didn’t have an impact. In my data I had listings in both languages.

This can be quite tricky because it will break recoding rules that record by title. Anyway, to get all of them in one language, I inserted the following configuration:

INSERT INTO settings(value, data) VALUES(‘PreferredLanguages’,’fin’);

You can clear the current EIT data by:

DELETE FROM program where starttime>now();

DELETE FROM eit_cache;

Then restart mythbackend, just to be sure. You should now get all the data in the language you’ve specified.

UPDATE: It seems that settings ‘ISO639Language0’ and ‘ISO639Language1’ must also be set to ‘fin’ in order to get non-mixed Finnish EIT data.

MySQL server has gone away

January 27, 2011 Leave a comment

I recently began getting failed MythTV recordings a few times per week (MythTV version 0.23.1/MySQL version 5.1.47). When I looked in the mythbackend log I found that there was some underlying database connectivity issue. The logs would fill up with error messages like these:

2011-01-16 05:26:30.699 Error preparing query: SELECT chanid, useonairguide FROM channel, dtv_multiplex WHERE serviceid=:SERVICEID AND networkid=:NETWORKID AND transportid=:TRANSPORTID AND channel.mplexid=dtv_multiplex.mplexid AND channel.sourceid=:SOURCEID
2011-01-16 05:26:30.699 Driver error was [2/2006]:
QMYSQL3: Unable to prepare statement
Database error was:
MySQL server has gone away
2011-01-16 05:26:30.700 DB Error (Looking up chanID):
Query was:
SELECT chanid, useonairguide FROM channel, dtv_multiplex WHERE serviceid=:SERVICEID AND networkid=:NETWORKID AND transportid=:TRANSPORTID AND channel.mplexid=dtv_multiplex.mplexid AND channel.sourceid=:SOURCEID
Bindings were:
Driver error was [2/2006]:
QMYSQL: Unable to execute query
Database error was:
MySQL server has gone away

The system did eventually recover (within an hour or so), but all recordings during this time would fail to start. Interestingly enough, they would still manage to get inserted into the table of recordings. To me this indicates that there is still partially functioning database connectivity. Even though the message says that MySQL server has gone away, I could perfectly well connect to the database during the time that mythbackend was filling my logs with these kind of errors. My conclusion was that the problem was with the database connections between mythbackend and MySQL, not with MySQL itself.

So, I began investigating what could be the cause of these errors. What I found was that MySQL has a timeout on all database connections that’s by default set to 28800 seconds (8 hours).

To see your connection timeouts, do this:

mysql> SELECT @@global.wait_timeout, @@session.wait_timeout;
| @@global.wait_timeout | @@session.wait_timeout |
|                 28800 |                  28800 |
1 row in set (0.00 sec)

Read more…

Technotrend C-1500+Technotrend CI+Conax CAM

January 19, 2011 5 comments

I finally received my Technotrend CI module + Conax CAM order. So now I have the following hardware working (with some minor tweaks below): Technotrend C-1500 + Technotrend CI module + Conax CAM. These are my software versions: Fedora 12, kernel and MythTV 0.23.1.

Initially, I had some issues with recordings sometimes failing with the following error message in mythbackend.log:

2011-01-18 21:48:18.268 PID 0x1f9c status: Encrypted
2011-01-18 21:48:18.798 PID 0x1f9b status: Encrypted
2011-01-18 22:00:07.363 PID 0x44d status: Encrypted

Once I got this message, all subsequent recordings failed. What I quickly discovered was that if I restarted mythbackend, then the recordings would start working again. There seems to be some issue with the CAM or mythtv going into an invalid state if the DVB card/CAM is kept open for a long time.

So I changed the following mythtvsetup options under “2. Capture cards“:

Open DVB card on demand -> turned on
Use DVB Card for active EIT scan -> turned off
DVB Tuning Delay (msec) -> 2000
Tuning timeout (msec) -> 5000

Read more… (slow) delivery times

January 16, 2011 Leave a comment

I ordered a few items from two weeks ago. All the items were in stock, so I thought I would have them at my doorstep within a few days. Boy was I wrong, it took them over one week just to dispatch the order! I mailed them to check what was going on and they just replied to be patient. To be fair, their service was good in that they answered my e-mail, but one week is just too long to dispatch items that are advertised as being in stock!

Setting up your remote control for MythTV

January 16, 2011 Leave a comment

The remote control receiver I use for my MythTV setup is a 10-15 year old IR-receiver called IRMan, which attaches to the COM-port. The software I use with the receiver is lirc.

You probably want to mainly follow the instructions here. But I’ll list a few pointers here nevertheless, in case you have any issues with the instructions on that page.

  • Make sure you have lirc installed
  • Make sure lircd is not running (in Fedora type service lirc stop)
  • You need to create a configuration file /etc/lirc/lircd.conf that maps all the keys of your remote control, you can do this with the following command:
irrecord --driver=irman --device=/dev/ttyS0 /etc/lirc/lircd

Using your Logitech Harmony remote control with MythTV

January 16, 2011 Leave a comment

I use the Logitech Harmony One with MythTV. Before that, I used the Logitech Harmony 525 for a few years.

The tricky part with setting up a Logitech remote for MythTV is that both the remote and the receiver are programmable! This means that there’s no default remote control keycodes that you can follow.

So basically, you’ll have to select an arbitrary device profile for your Logitech remote and hope that as many buttons as possible are mapped on that device profile. If some buttons are not mapped to a remote control keycode, it means that you can’t use those buttons! This is really stupidly done by Logitech, I e-mailed them asking if there is some device profile that you can use when dealing with programmable infrared receivers, but the helpdesk didn’t have ANY clue what I was talking about. You may not either, unless you have been there :)

I’ve found WINTV-PVR-350 to be the best Logitech device profile because it provides a relatively big number of key mappings. It would be so easy for Logitech to just provider a device profile with all possible buttons mapped to some keycode. Please let me know if you’ve found a better device profile!

UPDATE: After a second attempt to explain my issue to Logitech’s helpdesk, I finally got through enough lines of support to get to someone that understood my problem. They’ve now added 45 additional button mappings to my WINTV-PVR-350 profile! So now I should be able to have as many buttons mapped as I like.