LVM greatly increases the flexibility you have in managing your storage than traditional physical partitions. This section will provide some brief notes on how to use LVM to create storage space for your video files and how to add additional disk space in the future. There's lots more that can be done with LVM, so check the LVM HOWTO http://tldp.org/HOWTO/LVM-HOWTO/ document for details.
If you don't understand how to partition a drive, or how to change the partition type you should stop and look at documentation on how to perform these steps.
Make sure your kernel configuration includes LVM support or that it's available as a module. Today, most vendors include this by default. You'll also want to ensure that you have a copy of the LVM utilities; check your distribution, or get the latest versions from http://www.sistina.com/products_lvm.htm and build them manually.
Check that the vgscan program is being run at some point during
your boot sequence - most distributions do this by default. Look for a
message during boot up that looks like this: vgscan -- reading all
physical volumes (this may take a while...)
If you don't see any
messages during boot, you may need to install a LVM init script or confirm
that you have all of the LVM packages installed from your distribution.
LVM uses a few concepts you should be familiar with before starting.
The following example assumes that you want to create a LVM partition from a chunk of space in /dev/hda5, using a reiserfs filesystem and mounted on /var/video. You later decide to extend this filesystem by adding a new disk: /dev/hdb.
You need to create at least one LVM partition for a physical volume. Use fdisk or your favorite partition editor to set the type to LVM (0x8e). If you're using an entire disk, create one big partition rather than using the device itself. e.g. use /dev/hdb1 not /dev/hdb.
In the following example, you have a 15GB disk. The first 6GB are set as
your boot partition. /dev/hda2
was added as an extended partition,
and within that partition you created the /dev/hda5
linux (ext2)
partition.
# fdisk /dev/hda
The number of cylinders for this disk is set to 1823.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
(e.g., DOS FDISK, OS/2 FDISK)
Command (m for help): p
Disk /dev/hda: 15.0 GB, 15000330240 bytes
255 heads, 63 sectors/track, 1823 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/hda1 * 1 764 6136798+ 83 Linux
/dev/hda2 765 1823 8506417+ 5 Extended
/dev/hda5 765 1823 8506417 83 Linux
Command (m for help): t
Partition number (1-6): 5
Hex code (type L to list codes): 8e
Command (m for help): p
Disk /dev/hda: 15.0 GB, 15000330240 bytes
255 heads, 63 sectors/track, 1823 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/hda1 * 1 764 6136798+ 83 Linux
/dev/hda2 765 1823 8506417+ 5 Extended
/dev/hda5 765 1823 8506417 8e Linux LVM
Command (m for help): w
#
Create the LVM physical volume from the partitions (repeat if you have multiple partitions to use):
# pvcreate /dev/hda5
Create a LVM volume group out of this physical volume called "VGforMyth" that is
allocated in chunks that are a multiple of 64MB
# vgcreate VGforMyth -s 64m /dev/hda5
Create a logical volume of 5GB called "video" and then create the reiserfs
filesystem and mount it:
# lvcreate --name video --size 5G VGforMyth
# mkreiserfs /dev/VGforMyth/video
# mount /dev/VGforMyth/video /var/video
Now create a 3GB volume for mythmusic files if you like:
# lvcreate --name music --size 3G VGforMyth
# mkreiserfs /dev/VGforMyth/music
# mount /dev/VGforMyth/music /var/music
Display the volume group status:
# vgdisplay -v
Now, lets suppose you want to add a 60GB hard disk to the system as hdb and allocate 50GB of it to video storage.
First, create a single partition /dev/hdb1 covering the whole disk and make it type 0x8e using your partition editor.
# fdisk /dev/hdb
.... create partition, set type, save and reboot if it says you have to
Create the new LVM physical volume:
# pvcreate /dev/hdb1
Add the new physical volume to the volume group:
# vgextend VGforMyth /dev/hdb1
Once you've completed one of the following two procedures, use df to check that you've got more space.
Make the logical volume used for video bigger:
# lvextend --size +50G /dev/VGforMyth/video
Unmount, resize and remount the filesystem. Technically, you don't need to unmount and remount the ReiserFS.
# umount /var/video
# resize_reiserfs /dev/VGforMyth/video
# mount /dev/VGforMyth/video /var/video
LVM comes with a program called resize2fs.
Unmount, resize and remount the filesystem. The filesystem must be unmounted during this procedure.
# umount /var/video
# resize2fs --size +50G /dev/VGforMyth/video
# mount /dev/VGforMyth/video /var/video
XFS does not need to be unmounted to extend the size:
# xfs_growfs /var/video
The partitions that your distribution sets up for you may not be optimized for large files. Using LVM in conjunction with the following techniques can be quite useful.
Unlike a typical filesystem, a MythTV video partition is usually a very large filesystem filled with a fairly small number of large files. Filesystem I/O is usually not an issue, even in multi-tuner and/or multi-frontend setups.
There is however, one aspect of filesystem performance that can have a bearing on the performance of MythTV. In Linux, deleting a file will utilize I/O bandwidth until the deletion has been completed. If deleting the file takes long enough, the video capture buffer may overrun, thereby resulting in dropped frames. Some filesystems are faster at deleting files than others and, for multi-gigabyte MythTV video files, these differences can be significant.
Fortunately, there are published tests ( http://aurora.zemris.fer.hr/filesystems/big.html) that provide insight into filesystem performance under conditions relevant to MythTV usage. In addition, some limited testing (archived at http://www.gossamer-threads.com/lists/mythtv/users/52672) with very large files (10 gigabytes) was reported in the MythTV Users mailing list.
Ext2 was the defacto standard Linux filesystem for many years. It is stable, provides good I/O performance and can quickly delete large files. The primary disadvantage of Ext2 is that it is not a journaling filesystem, so a file system consistency check (fsck, which is normally only performed after a system crash) can take many hours on a filesystem the size of a typical MythTV partition.
Ext3 is Ext2 with a journal, so your biggest gain is that in case of a crash and reboot you won't have to wait very long for your partition to be remounted.
There are options available when formatting an Ext3 partition, as in:
# mkfs.ext3 -T largefile4 /dev/hdb1
This example assumes that /dev/hdb1
has already been created using
fdisk. If you're using LVM, /dev/hdb1
may be something like
/dev/VGforMyth/video
.
The "-T largefile4" option creates one inode per 4 megabytes, which can provide a few percent more storage space. However, tests indicate that using the "-T largefile4" option can drastically increase the amount of time required to delete a large file and thus it should only be used with encoder settings that produce small video files (YMMV).
You can check on your filesystem using the dumpe2fs program. See the man page for details.
The Reiser filesystem is another journaling filesystem commonly distributed with Linux. It is known to be an extremely efficient filesystem and it especially excels at managing partitions containing a large number of small files. However, tests indicate it is not the fastest at deleting very large files. For that reason, it may not be the best choice when using encoder bitrates that produce very large files.
JFS (Journaling File System) is a journaling filesystem originally developed by IBM for AIX which was later released as open source. While not as common as Ext3 or ReiserFS, it is distributed with RedHat 9 (RH9), Fedora Core and Mandriva as well as other distros. According to tests, JFS is the file deletion speed king, deleting virtually any file in under one second, even files as large as 10 gigabytes.
XFS is a journaling file system originally developed by SGI for Irix, and later released as open source. While not a part of the default RedHat Linux 9 or Fedora Core installation (although it is a part of Mandriva and Fedora Core 2+), it can be easily installed via ATrpms. XFS provides deletion speeds for large files only slightly slower than JFS. According to the test results shown at ( http://aurora.zemris.fer.hr/filesystems/big.html), XFS provide higher I/O rates than JFS, albeit at a higher CPU loading. This may cause issues if you do not have the spare CPU capacity to handle XFS, potentially leading to dropped frames.
MythTV v0.20.2 or later is required to natively support Schedules Direct. Code has been included to make the transition as simple as possible.
You do not need to delete your existing video sources or add new ones!
The following steps should work for most users:
MythTV 0.20.2 or later supports caching of downloaded information from Schedules Direct, so devices that share a common source do not require multiple downloads.
Before beginning, perform a backup of your existing database. See Saving or restoring the database for instructions.
In the following scenario, assume that you have the following:
What we are going to do is to create a single lineup at Schedules Direct and then create two Video Sources which use the same login information but have different channels associated with them.
On your Schedules Direct account, create a lineup that has all of the channels that you can receive. Because we have a Set Top Box (STB), choose a Digital lineup. Yes, this means that you may have 900 channels in this lineup, but that's OK.
Use the Schedules Direct channel editor and unselect any channels that you can't tune without the STB. This will usually be channels higher than 125, but check your CATV provider lineup if you're not sure. Once you've deselected them (using a click on the first channel you can't receive and then a shift-click on the last channel you can't receive will deselect all the channels in between those two.) click the Save Changes button at the bottom of the screen.
In mythtv-setup, create a Video Source with an appropriate name. "SD-Analog Only" will be used in this example. Click "Retrieve Lineups" and select the digital lineup you just created at Schedules Direct.
Click "Finish" to return to the Video sources selector and then press the ESC key to go back to the main screen.
Now choose Input Connections. Select the PVR-150 which is connected directly to the CATV. Set the Video Source to "SD-Analog Only" and click "Fetch channels from listings source".
Set the start channel to an appropriate value.
NOTE: There is a bug where the "Fetch" command may not work; you can tell that the Fetch did not retrieve any channels in one of two ways: in the text-mode console, you will see a connection to Schedules Direct, but it doesn't appear to retrieve any channel information:
2007-08-25 15:03:05.526 New DB DataDirect connection
2007-08-25 15:03:05.526 Connected to database 'mythconverg' at host: localhost
2007-08-25 15:03:05.536 DataDirect: Your subscription expires on 11/23/2007 01:12:10 PM
2007-08-25 15:03:05.707 New DB connection, total: 3
2007-08-25 15:03:05.707 Connected to database 'mythconverg' at host: localhost
2007-08-25 15:03:05.708 sourceid 2 has lineup type: CableDigital
2007-08-25 15:03:06.623 Data fetching complete.
2007-08-25 15:03:06.624 DataDirect: Deleting temporary files
or, the "Please add channels to this source" message in the "Starting channel" field stays on the screen.
If either of these happens, save the information on this screen by clicking the "Finish" button. Exit back to the Input connections screen by pressing ESC, then select this Input Connection again. This time the Fetch will work and the "Please add channels to this source" message will disappear.
If you look at the text-mode console, you'll see this if the channel retrieval is working:
2007-08-25 15:04:32.437 New DB DataDirect connection
2007-08-25 15:04:32.437 Connected to database 'mythconverg' at host: localhost
2007-08-25 15:04:32.447 DataDirect: Your subscription expires on 11/23/2007 01:12:10 PM
2007-08-25 15:04:32.622 New DB connection, total: 3
2007-08-25 15:04:32.622 Connected to database 'mythconverg' at host: localhost
2007-08-25 15:04:32.623 sourceid 2 has lineup type: CableDigital
2007-08-25 15:04:33.418 DataDirect: Adding channel 41 'AMC' (AMC).
2007-08-25 15:04:33.422 DataDirect: Adding channel 32 'A & E Network' (AETV).
2007-08-25 15:04:33.425 DataDirect: Adding channel 66 'Black Entertainment Television' (BET).
2007-08-25 15:04:33.427 DataDirect: Adding channel 180 'Bravo' (BRAVO).
2007-08-25 15:04:33.430 DataDirect: Adding channel 51 'ABC Family' (FAM).
2007-08-25 15:04:33.432 DataDirect: Adding channel 146 'Country Music Television' (CMTV).
2007-08-25 15:04:33.435 DataDirect: Adding channel 39 'CNBC' (CNBC).
2007-08-25 15:04:33.437 DataDirect: Adding channel 36 'Cable News Network' (CNN).
2007-08-25 15:04:33.440 DataDirect: Adding channel 35 'CNN Headline News' (CNNH).
Repeat the Input Connection configuration for any other capture devices that are connected directly to the CATV system. You do not need to click Fetch once you've done one successful download of the channel information - the Starting channel should be automatically populated.
Go back to Schedules Direct and re-enable the channels that you had previously deselected, then click Save Changes.
Create a new Video Source, here called "SD-All Digital Channels". Perform the same "Retrieve Listings" you did before.
Go back to the Input Connections screen, select the PVR-250 which is connected to the STB, assign the "SD-All Digital Channels" video source and perform a retrieve channels. This will pull down the complete channel listing, but only for this device.
When mythfilldatabase runs, it will cache the "big" download which is appropriate for the STB, and then copy the information to the channels that can only be accessed without the STB. But by default mythfilldatabase is going to notice that the "Analog only" video source is missing the channels that are in the Digital lineup you created at Schedules Direct, so we need to override the addition of new channels.
When you run mythfilldatabase to populate your database, you'll need to run it like this:
$ mythfilldatabase --remove-new-channels
You will also need to modify how the mythbackend calls mythfilldatabase when it performs its automatic listings update.
In mythfrontend, select "Setup" -> "General".
Continue press ENTER until you reach the Mythfilldatabase configuration screen. In the "mythfilldatabase Arguments" field, type --remove-new-channels
then press the TAB key until you reach Finish, then press ENTER to save. You can then press ESC until you return to the main screen.