Linux Crumbs
Custom Search

Migrating Existing MythTV 0.24 on HDD to MythTV 0.25 on SSD

Summary

This tutorial outlines the process of migrating a Mythbuntu installation from one hard drive to another, while at the same time upgrading MythTV. In the steps detailed below, the Mythbuntu installation is migrated from a Hard Disk Drive (HDD) to a Solid State Drive (SSD). Please note that these instructions can also be used to migrate from one hard drive to another while keeping the same MythTV version.

This tutorial is the second in a mini series that started with Why Consider RAID for PVR Recordings and Solid State Drive for Mythbuntu Operating System.

The original series of articles that outline the path of creating a custom-built PVR can be found at the following links:

Contents

Migrate MythTV to New Drive

After having experienced a couple of hard drive failures, my spouse and I wanted to increase the reliability and robustness of our PVR. To accomplish this we decided to separate the Mythbuntu Operating System (OS) from the TV show recordings. We did this by first migrating the OS to a new Solid State Drive (SSD) and secondly by building a RAID and migrating the recordings to the RAID. Since our original installation used Mythbuntu 11.04 (with MythTV 0.24) we decided to upgrade to Mythbuntu 12.04 (with MythTV 0.25) at the same time.

This tutorial covers the aforementioned first step of migrating the Mythbuntu OS while keeping the existing MythTV settings and using the recordings as they exist on the original Mythbuntu installation. Note that an added benefit of migrating Mythbuntu to a new drive is that because we do not touch the original Mythbuntu installation, we keep open the option of immediately switching back should the upgrade not go well, or otherwise not meet with our expectations.

TIP:   Perform Steps When Not Recording Shows

The migration process can take several hours and during this time the PVR will not be available to record shows. Hence it is advisable to choose a block of time in which your PVR has no scheduled recordings.

Export existing MythTV database to a file

When creating the export file, be sure to save the file (or a copy) of the resulting backup someplace that will survive re-installs and/or disk failures. In this example we use the /data/mythtv/db_backups directory. Note that the default location in an unmodified Mythbuntu install is /var/lib/mythtv/db_backups.

  1. Open a terminal window and create an export of the existing MythTV database.

    /usr/share/mythtv/mythconverg_backup.pl --verbose \
      --directory=/data/mythtv/db_backups

    Note that this directory likely contains other automatic MythTV database export files. Ours will be the most recent file.

Install new drive (HDD or SSD) in PVR

In my computer I plugged the drives into the SATA ports in the following order:

  • /dev/sda - new SSD for Mythbuntu 12.04 OS.
  • /dev/sdb - original HDD containing Mythbuntu (11.04) and recordings.
  • /dev/sr0 - original DVD R/W optical drive.

Install Mythbuntu on new drive

  1. Alter BIOS to place the new drive (SSD) higher in boot order than other HDDs.
  2. Install Mythbuntu 12.04 on drive (SSD).

    TIP:   Only Two Partitions Needed (OS and Swap)

    Note that we only need partitions for Mythbuntu OS and swap space on the new drive. The recordings stored in /data will be left on the original drive.


    Follow the Installing Mythbuntu 12.04.2 with MythTV 0.25 instructions, but stop at step T. Create Scheduled Direct Acccount [Optional]. We stop at step "T" because we will be importing the MythTV database settings.

  3. Ensure /etc/fstab set to mount /data from original HDD.
  4. Ensure correct new ownership of mythtv.mythtv for files and folders in /data.

    In a terminal window, enter the following command:

    sudo chown -R mythtv.mythtv /data

    It is important to ensure the correct ownership because different installs of Mythbuntu might use a different number for the mythtv userid or mythtv group.

Optimize OS installation for SSD [Optional]

Solid State Drives (SSDs) are completely different than standard spinning hard disk drives. As such I spent some time researching SSDs and discovered some optimization tips. The general recommended practice is to lessen write activity where possible, and to reserve ~10% unallocated space when partitioning (some newer SSDs supposedly do this already -- maybe that explains the difference in SSD sizes such as 60 GB versus 64 GB).

Following are the tips I implemented on my Mythbuntu PVR.

  1. Add "noatime" to SSD file system mounts to inhibit last access time updates.

    Edit /etc/fstab

    sudo leafpad /etc/fstab

    and add "noatime" parameter to "/" mount. The resulting line should look something like the following:

    ---------- begin /etc/fstab lines ----------
    # / was on /dev/sda1 during installation
    UUID=d819744e-5a07-4039-95b8-9d322954b065 / ext4 noatime,errors=remount-ro 0 1
    ---------- end /etc/fstab lines ----------

    NOTE:   Some Recommend Adding "discard" or Scheduling TRIM

    From my research some people advise adding "discard" to /etc/fstab to help with wear levelling. However I have read that this can increase the time to perform a delete.

    Some other people advise scheduling regular TRIM operations to perform this same wear levelling.

    Since I was unsure of all the implications, I opted to not implement either method and instead take a wait-and-see approach. So far my PVR has been running without these "discard/TRIM" settings since May 2013 and I have not experienced any noticeable degradation in SSD performance.

  2. Limit swap space wear and tear by reducing the inclination to swap.

    Edit /etc/sysctl.conf

    sudo /etc/sysctl.conf

    and add the following 5 lines to end of file:

    ---------- begin 5 /etc/sysctl.conf lines ----------
    #
    # Sharply reduce swap inclination
    vm.swappiness=1
    # Don't shrink the inode cache aggressively
    vm.vfs_cache_pressure=50
    ---------- end 5 /etc/sysctl.conf lines ----------
  3. Limit write actions in Firefox.

    Start Applications -> Internet -> Firefox Web Browser.

    Select Edit -> Preferences -> Advanced
      On Network tab
        Click on Clear Now
        Override automatic cache management:
          Limit cache to 0 MB of space
      Click on Close
    Exit Firefox

Import exported file into new MythTV database

  1. Stop the MythTV backend.

    In a terminal window enter the following command:

    sudo stop mythtv-backend
  2. Locate the recently created database export file.

    ls -lt /data/mythtv/db_backups | head

    The most recent file is listed at the top with a name in the form:

      mythconverg-1264-20130408134231.sql.gz

    Note that the date and timestamp is contained in the filename.
  3. Import the previously created export file into the new MythTV database.

    /usr/share/mythtv/mythconverg_restore.pl \
      --drop-database --create-database \
      --directory=/data/mythtv/db_backups \
      --filename=mythconverg-1264-20130408134231.sql.gz

    Remember to replace the filename mythconverg... with the one you created previously.
  4. Start the MythTV backend again.

    sudo start mythtv-backend

    If prompted "Warning: MythTV wants to upgrade your database", then use the arrow keys to select upgrade, and then press Enter to accept.

Re-configure MythTV automatic wakeup and shutdown [Optional]

If you previously configured MythTV to automatically shutdown when idle and later wakeup to record shows, then ensure that all necessary scripts and setting exist by following the steps for Configuring MythTV Automatic Wakeup and Shutdown.

Test MythTV Operation

At this point I highly recommending rebooting your Mythbuntu PVR and confirming proper MythTV operation, such as viewing TV shows. In this way you can help ensure that you do not miss any upcoming recordings.

Back Out Steps [Optional]

If for any reason you wish to return to your previous setup, then now is the time because the MythTV database should still match the recordings stored in the /data directory. The steps to return to your previous configuration are as follows:

  1. Alter BIOS to place the original drive with Mythbuntu higher in boot order than other HDDs.
  2. Reboot.
  3. Ensure correct ownership of mythtv.mythtv for files and folders in /data.

    In a terminal window, enter the following command:

    sudo chown -R mythtv.mythtv /data

Migration Complete

With the completion of the above steps, you should now have your Mythbuntu setup migrated to a new drive. For myself I performed these steps to migrate to a newer Mythbuntu OS installation on a faster Solid State Drive (SSD). This was the first step in my goal of increasing the reliability and robustness of my Mythbuntu PVR. In the near future I plan to cover the next step to setup a RAID level 1 mirror and migrate my existing PVR recordings to the RAID.

References

While migrating my Mythbuntu installation to a new SSD I found the following references useful:

Future Articles

In future articles, I plan to cover the following steps of our path:

Medusa Deception novel on sale now
News   Documentation     Copyright (c) 2013-2017 Curtis Gedak

Get GParted at SourceForge.net. Fast, secure and Free
	Open Source software downloads Valid HTML 4.01! Correct CSS! Privacy policy