Tuesday 3 March 2015

Getting an Apple TV to work with an old TV

Before Christmas, I had this great idea that I would help a friend with an old fashioned plasma TV get an Apple TV working. You know the kind, it has a VGA input, an S-VHS input, a set of component video RCA inputs, and a composite RCA input. The big problem was that there was a distinct lack of an HDMI input port. This problem was quickly resolved with one of these HDMI to composite video converters.





Unfortunately my friend is not that technically minded so even though, I gave him an Apple TV, the converter, the cables and the following diagram, he did not attempt to connect things up. Recently I visited him and connected it all up.



The video worked pretty well, except for the fact that the Apple TV showed a purplish hue to the picture.  This issue was resolved by going into the Apple TV menu and changing the Video Output setting to Digital RGB High and then normal colour was displayed.

The other problem that we had was that the Arcam AR200 AV amplifier did not like the outage voltage produced by the RCA outputs of the HDMI to composite converter. This essentially meant that there was no sound. This problem was resolved by purchasing an optical TOSlink fibre optic cable and a TOSlink to Digital RCA adapter box. The TOSlink was connected to the back of the Apple TV and the Digital SPDIF RCA output went to the Arcam AR200 AV amplifier digital input. Once this was connected up we had sound and video.




All these components can be found on ebay for less than ~£20 total. The still picture quality is not brilliant, but the moving picture quality looks fantastic. Just one way to get from A to B.

Monday 27 October 2014

Fun with RHEL 6 kickstart continued

I had to recently go back and look at creating a custom RHEL 6 DVD. Although I had done this in the past, it appeared that the work in my previous post was incomplete. There were many things that I had not realised needed to be correct to allow a RHEL 6 DVD to work. These changes seem to have crept in from RHEL6.1 to RHEL6.5. These were:-

  • The build environment for the RHEL6 DVD
  • The DVD .treeinfo file
  • The different repodata directories on the disk
  • The change of location for the repodata directory
  • The subtle change of format of the files in the repodata directory

RHEL6 build environment

The first problem that I noticed with the build that was using my RHEL5 build environment was that the format of the .xml files created by the createrepo tool were different and did not use the default SHA265 checksums. The only answer was to build a RHEL6 server and add the necessary files to allow the DVD to be created. The installation was on a VM and used the basic RHEL graphical install.

The following packages were added to the install to complete the build environment.

createrepo-0.9.9-22.el6.noarch.rpm
python-deltarpm-3.5-0.5.20090913git.el6.x86_64.rpm
deltarpm-3.5-0.5.20090913git.el6.x86_64.rpm

These were installed using the normal yum command.

yum install -y --nogpgcheck ./deltarpm-3.5-0.5.20090913git.el6.x86_64.rpm
yum install -y --nogpgcheck ./python-deltarpm-3.5-0.5.20090913git.el6.x86_64.rpm

yum install -y --nogpgcheck ./createrepo-0.9.9-22.el6.noarch.rpm


The DVD .treeinfo file

To my surprise this file is now important to the DVD and kickstart. Here is a sample based on my custom RHEL6 DVD.

[general]
family = Red Hat Enterprise Linux
timestamp = 1384196515.415715
variant = Server
totaldiscs = 1
version = 6.5
discnum = 1
packagedir = Packages 
variants = Server
arch = x86_64

[images-x86_64]
initrd = images/pxeboot/initrd.img
kernel = images/pxeboot/vmlinuz

[images-xen]
initrd = images/pxeboot/initrd.img
kernel = images/pxeboot/vmlinuz

[variant-Server]
addons =
repository = repodata

[checksums]
images/pxeboot/initrd.img = sha256:ee05f49df116b74342467fd403c4cddb740c21e29b82ccac33e763ce5a0cc02a
images/efiboot.img = sha256:6facd92cf4b7c572d1e7e7a82aa96e78dca2c074a89cf381d105719d4e5b39be
images/pxeboot/vmlinuz = sha256:92670cf84a593faaafc71b25bc30efc56b742b484c76f254cc9910e9712b98a8
images/install.img = sha256:86a8e1b59eeefd2db84c9ce3b5f29d9a24d3eb6cf7edef366eb80e0b06abd3a1
images/efidisk.img = sha256:b201662c37170f0a290f8484b939d4d474fd60d6ba94b48866c8979154a95bf1
images/product.img = sha256:a18500d76e6faf0df6df8487b05a15116fb13c3ce455be1b9d68a6026eb295bd

[stage2]
mainimage = images/install.img 

From what I can gather this file will point to the base repodata directory which the distribution will use to detail the packages / groups to install. The problem that I found was that there was no definitive explanation to this file format. The following is based on the information at the following URL Fedup .treeinfo.

Some details about the file format:

[general] section: general info about this distro tree.

  • 'timestamp', 'arch', and 'version' are required.
  • 'timestamp' is the build time, in seconds since the Epoch. It may be a floating point number.
  • 'timestamp' should match the timestamp in other .treeinfo files for other arches/variants built as part of the same "compose". (e.g. Fedora 17 x86_64 and Fedora 17 i386 have the same timestamp.)
  • 'version' is a string, not an integer - "17-Beta" is valid.
  • 'family' is the OS/distro family name, 'variant' is name of the distro variant, like "Server" or "Client" or "Workstation".
  • 'packagedir' usually points to the directory containing packages, but in Fedora this is ignored in favor of reading repodata/repomd.xml.
  • 'discnum' and 'totaldiscs' can be used when writing a tree to multiple CD/DVD images.

[stage2] section: installer runtime images.
- 'mainimage' will refer to the main installer runtime image, if one exists.
In Fedora 17 and later the installer uses this to automatically find
its runtime if you boot with 'inst.repo=url://to/os/tree'.

[images-*] sections: list the boot images (kernel, initramfs, boot.iso, etc.)

  • There should be an [images-$arch] section for the arch in [general]. There may be more sections for other major arches the tree supports.
  • [images-xen], by convention, contains the images that should be used when installing into a virtualized guest.
  • Standard keys are 'kernel', 'initrd', and 'boot.iso'.


[checksums] section: checksums of various files in the tree

  • Everything listed in all the [images-*] sections should have a checksum.
  • Each line is of the form: relative/path = hash_algorithm:hex_digest

The different repodata directories on the disk

This was strange to understand because the DVD appeared to have multiple repodata directories. If you look at the top level of an official RHEL6 DVD it has the following directories:-

dr-xr-xr-x   3 root  root    2048 30 Jan  2013 EFI
dr-xr-xr-x   3 root  root    2048 30 Jan  2013 HighAvailability
dr-xr-xr-x   3 root  root    2048 30 Jan  2013 LoadBalancer
dr-xr-xr-x   2 root  root  671744 30 Jan  2013 Packages
dr-xr-xr-x   3 root  root    2048 30 Jan  2013 ResilientStorage
dr-xr-xr-x   3 root  root    2048 30 Jan  2013 ScalableFileSystem
dr-xr-xr-x   3 root  root    2048 30 Jan  2013 Server
dr-xr-xr-x   3 root  root    2048 30 Jan  2013 images
dr-xr-xr-x   2 root  root    2048 30 Jan  2013 isolinux
dr-xr-xr-x   2 root  root    4096 30 Jan  2013 repodata

  • The directory EFI/ contains EFI boot loader.
  • The directory HighAvailability/ contains a repodata directory defining the packages for a high availability system.
  • The directory LoadBalancer/ contains a repodata directory defining the packages for a load balancer system.
  • The directory Packages/ contains the .rpm packages.
  • The directory ResilientStorage/ contains a repodata directory defining the packages for a resilient storage server system.
  • The directory ScalableFileSystem/ contains a repodata directory defining the packages for a server with a scalable file system.
  • The directory Server/ contains a repodata directory defining the packages for a server system.
  • The directory images/ contains the image files used during the Red Hat Enterprise Linux 6 installation process.
  • The directory isolinux/ contains the boot menu configuration files.
  • The directory repodata/ contains the default data to define the packages / groups that are to be installed. 
Note: If you don't plan on using the HighAvailability, LoadBalancer, ResilientStorage, ScalableFileSystem, or Server configurations, these directories and their contents can be removed.

Repodata

The files in the repodata/ directory are built using the createrepo command. The easiest way to do this is to have a master comps-rhel6-Server.xml file. When I set up the build environment I created a directory /isobuild/ and put the master comps-rhel6-Server.xml file under that top level directory. I then created the following /isobuild/custom/ directory for the custom iso contents.

mkdir /isobuild
mkdir -p /isobuild/custom
mkdir /tmp/cdrom
mount /dev/cdrom /tmp/cdrom
cp -R /tmp/cdrom/* /isobuild/custom/
cp -R /tmp/cdrom/.[a-zA-Z]* /tmp/cdrom/

Before clearing out some of the unwanted directories I copied the Server/repodata/*comps-rhel6-Server.xml.gz file to /isobuild/ and called it comps-rhel6-Server.xml.

cd /isobuild
cp custom/Server/repodata/*-comps-rhel6-Server.xml.gz ./comps-rhel6-Server.xml.gz

This then gave me an initial file that I could start editing to remove / add packages to. The files in the DVD repodata directory were created using the following command.

rm -f /isobuild/custom/repodata/*
createrepo -g /isobuild/comps-rhel6-Server.xml -d --unique-md-filenames /isobuild/custom/

This then creates the files with the unique SHA256 checksum in the DVD top level repodata/ directory. An example of this is shown below:-

-r--r--r--  1 root root  463035 17 Oct 14:00 15334241501e71eb54ad91b428a1b9e56aee2824c015ccfdbc065d8b16c04e19-other.xml.gz
-r--r--r--  1 root root  166352 17 Oct 14:00 1995b5df9e976dece7eaedf28d8f908de9d2961cbf1eb4ea6fbca1e6359bac16-comps-rhel6-Server.xml.gz
-r--r--r--  1 root root  427170 17 Oct 14:00 1e9af68d10366dd64ec029ae3b04b1f793d81abfabff9700cedeafa7b1b5faa7-other.sqlite.bz2
-r--r--r--  1 root root  950077 17 Oct 14:00 47feabb6b96315377d52069f3f0a5a415b1204a7607716260c16e69a2c5421b8-primary.sqlite.bz2
-r--r--r--  1 root root  547723 17 Oct 14:00 561799eb2d4d9dac7b13ffab7254742a28e7d9142df6c22ec1ea7784456f93e9-filelists.xml.gz
-r--r--r--  1 root root  950725 17 Oct 14:00 6f4792d5709aafc4a3419ef2a06bee206770d55703abf3d165261d58118feb8d-comps-rhel6-Server.xml
-r--r--r--  1 root root  482240 17 Oct 14:00 8666d0ae94a3cd38e5608753caa33cdad96fbd4ca092e1f55930b584323e1675-primary.xml.gz
-r--r--r--  1 root root    2581 17 Oct 14:00 TRANS.TBL
-r--r--r--  1 root root  708577 17 Oct 14:00 fa3bfef517376f3d28c0e20ce16c0aecb6e4fefd171be5dafdeb18a4a701bda7-filelists.sqlite.bz2
-r--r--r--  1 root root    3739 17 Oct 14:00 repomd.xml

The repomod.xml file that is created differs from the official RedHat version in that it doesn't have an entry for the productid.gz file. The following URL gives the explanation of what this is and why it is used:- productid.gz


When you import the distribution, createrepo runs and recreates repomd.xml, which removes this element from the original:

<data type="productid">
<location href="repodata/productid.gz"/>
<checksum type="sha">c0150e34800edcef42a43d0d0f051b3b3a421b34</checksum><timestamp>1359577376</timestamp>
<open-checksum type="sha">5dfbaa2ef24689b4141ae655d3f352be62a128d7</open-checksum></data>

When the OS installs on the client, it checks the checksum from this element to the checksum of the productid.gz file. If they don't match then the installer cannot identify the OS, which results in the /etc/pki/product/69.pem not being created. 69.pem is just the productid file from the repo. This file is needed to successfully subscribe to the software channel at RHN.

# sha1sum productid.gz
c0150e34800edcef42a43d0d0f051b3b3a421b34  productid.gz

The symptom that this has happened is that if you attempt to subscribe via subscription-manager, then you get "no installed products" type error messages. You can fix the client by manually copying the productid file to /etc/pki/product/69.pem.

If you are not planning to use the RHN for updates because the system that you are building has no access to the public internet then this can be ignored.

Closing Notes

Editing the comps-rhel6-Server.xml file is fraught with problems. Be warned a simple typo can stop the whole kickstart process dead in its tracks with a python exception. My advice is to make small edits and create incremental backups.

Make sure that the .treeinfo file has the following:- repository = repodata otherwise the default repository might not be found.

The following is my build script to recreate the repodata and create the .iso image.

rm -f /isobuild/custom/repodata/*<CR>
createrepo -g /isobuild/comps-rhel6-Server.xml -d --unique-md-filenames /isobuild/custom/<CR>
mkisofs -r -J -T -V "RHEL6 x86_64" -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table -o /isobuild/RHEL6-64-0914.iso /isobuild/custom<CR>
chmod a+rwx /isobuild/RHEL6-64-0914.iso<CR>

Obviously remove the <CR> from the commands. These are just there to show where the line ends because the text wraps round.

Wednesday 13 November 2013

OS X 10.9 (Mavericks) Problems with USB SD card adaptors and a fix

UPDATE - This improves the problem but you get I/O errors when trying to write large amounts of data to the SD card.

One thing that I have noticed with OS X 10.9 is that USB SD card adaptors have stopped working properly. Generally the SD card will mount and then unmount itself. It will get stuck in a cycle of doing this, leaving notification dialog boxes stating that the disk has not ejected properly.

Investigating the issue I noticed that the version of IOUSBMassStorageClass.kext was 3.6.0 that was delivered with 10.9. The version of IOUSBMassStorageClass.kext that is delivered with the 10.8.5 is 3.5.1. The solution that I have found is to revert the IOUSBMassStorageClass.kext extension back to the 10.8.5 version. I find it suspicious that Mavericks has problems with other USB mass storage devices.

To update the IOUSBMassStorageClass.kext

First make a new folder /System/Library/Extensions-Disabled. Move the IOUSBMassStorageClass.kext version 3.6.0 from /System/Library/Extensions to /System/Library/Extensions-Disabled

Copy the IOUSBMassStorageClass.kext version 3.5.1 file to /System/Library/Extensions. Then, open the Terminal app (located in OS X under Applications->Utilities) and type:

cd /System/Library/Extensions

For those unfamiliar with command line, this just changes the directory that Terminal is working on to /System/Library/Extensions. Then type:


sudo chmod -R 755 IOUSBMassStorageClass.kext
sudo chown -R root:wheel IOUSBMassStorageClass.kext

This fixes the kext's permissions.

Then reboot. If everything went well, then hopefully the newly replaced kext will do the job. It  is a good idea to run disk utility and repair the permissions.




Sunday 21 April 2013

Create your own Fusion drive - Mac Pro - Error: 22: POSIX reports: Invalid argument - Fixed

I wanted to create a fusion drive because I had a 120GB disk that I had purchased and then realised it was too small for my home disk. I backed everything up by shuffling files from one drive to another using Carbon Copy Cloner - the best tool for doing these kind of things. This freed up a 1TB drive that I could use. I used the tutorial posted in MacTuts to do the work MacTuts Tutorial

Everything was ready and I ran the magic commands in the terminal on Mac and was stumped.

Check the disks on the system


unknown-00:25:00:f1:a7:2e:~ george$ diskutil list
/dev/disk0
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *120.0 GB   disk0
   1:                        EFI                         209.7 MB   disk0s1
   2:                  Apple_HFS                         119.7 GB   disk0s2
/dev/disk1
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *1.0 TB     disk1
   1:                        EFI                         209.7 MB   disk1s1
   2:                  Apple_HFS MacOS 10.8              332.8 GB   disk1s2
   3:                 Apple_Boot Recovery HD             650.0 MB   disk1s3
   4:                  Apple_HFS MacOS 10.7              332.8 GB   disk1s4
   5:                 Apple_Boot Recovery HD             650.0 MB   disk1s5
   6:                  Apple_HFS MacOS 10.6              319.8 GB   disk1s6
   7:       Microsoft Basic Data TEMP                    12.3 GB    disk1s7
/dev/disk2
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *640.1 GB   disk2
   1:                        EFI                         209.7 MB   disk2s1
   2:                  Apple_HFS                         639.8 GB   disk2s2
/dev/disk3
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *2.0 TB     disk3
   1:                        EFI                         209.7 MB   disk3s1
   2:                  Apple_HFS Data                    1.0 TB     disk3s2
   3:                  Apple_HFS MacOS 10.8 - New        299.5 GB   disk3s3
   4:                 Apple_Boot Recovery HD             784.2 MB   disk3s4
   5:                  Apple_HFS MacOS 10.7 - New        299.5 GB   disk3s5
   6:                 Apple_Boot Recovery HD             784.2 MB   disk3s6
   7:                  Apple_HFS MacOS 10.6 - New        393.5 GB   disk3s7


Now run the command


unknown-00:25:00:f1:a7:2e:~ george$ diskutil corestorage create logvol /dev/disk0 /dev/disk1
Started CoreStorage operation
Unmounting disk0
Repartitioning disk0
Unmounting disk
Creating the partition map
Rediscovering disk0
Error: 22: POSIX reports: Invalid argument

No matter what I tried it kept failing. The secret to getting this to work was to specify the partition that should be used. This was hidden away in a post in the xclr8yourmac web site xlr8yourmac Fusion Drive Discussion.

The answer is to use the disk partition disk0s2 and disk1s2.

unknown-00:25:00:f1:a7:2e:~ george$ diskutil corestorage create logvol /dev/disk0s2 /dev/disk1s2
Started CoreStorage operation
Unmounting disk0s2
Touching partition type on disk0s2
Adding disk0s2 to Logical Volume Group
Unmounting disk1s2
Touching partition type on disk1s2
Adding disk1s2 to Logical Volume Group
Creating Core Storage Logical Volume Group
Switching disk0s2 to Core Storage
Switching disk1s2 to Core Storage
Waiting for Logical Volume Group to appear
Discovered new Logical Volume Group "1D2196F9-F64F-44C9-81EB-6E8EADEC7C9C"
Core Storage LVG UUID: 1D2196F9-F64F-44C9-81EB-6E8EADEC7C9C
Finished CoreStorage operation

It works! You can then follow the rest of the normal instructions.

unknown-00:25:00:f1:a7:2e:~ george$ diskutil corestorage createVolume 1D2196F9-F64F-44C9-81EB-6E8EADEC7C9C jhfs+ "MacOS 10.8" 100%
Started CoreStorage operation
Waiting for Logical Volume to appear
Formatting file system for Logical Volume
Initialized /dev/rdisk5 as a 1 TB HFS Plus volume with a 90112k journal
Mounting disk
Core Storage LV UUID: DB4C7761-25C1-4AA7-91DC-95BD19DD248D
Core Storage disk: disk5
Finished CoreStorage operation

In theory I now have one fusion drive as disk5. I just need to test it out and see if it improves things.

unknown-00:25:00:f1:a7:2e:~ george$ diskutil corestorage list
CoreStorage logical volume groups (1 found)
|
+-- Logical Volume Group 1D2196F9-F64F-44C9-81EB-6E8EADEC7C9C
    =========================================================
    Name:         logvol
    Status:       Online
    Size:         1118901059584 B (1.1 TB)
    Free Space:   73728 B (73.7 KB)
    |
    +-< Physical Volume 0E9BE62C-3A63-464A-9511-2B0C6952B4B6
    |   ----------------------------------------------------
    |   Index:    0
    |   Disk:     disk0s2
    |   Status:   Online
    |   Size:     119690149888 B (119.7 GB)
    |
    +-< Physical Volume 4713D499-C59A-452A-8996-4916C6D5D6E8
    |   ----------------------------------------------------
    |   Index:    1
    |   Disk:     disk1s2
    |   Status:   Online
    |   Size:     999210909696 B (999.2 GB)
    |
    +-> Logical Volume Family ABF926BE-F2ED-432F-99F4-542191127279
        ----------------------------------------------------------
        Encryption Status:       Unlocked
        Encryption Type:         None
        Conversion Status:       NoConversion
        Conversion Direction:    -none-
        Has Encrypted Extents:   No
        Fully Secure:            No
        Passphrase Required:     No
        |
        +-> Logical Volume DB4C7761-25C1-4AA7-91DC-95BD19DD248D
            ---------------------------------------------------
            Disk:               disk5
            Status:             Online
            Size (Total):       1110397812736 B (1.1 TB)
            Size (Converted):   -none-
            Revertible:         No
            LV Name:            MacOS 10.8
            Volume Name:        MacOS 10.8
            Content Hint:       Apple_HFS


Tuesday 26 March 2013

Fun with RHEL 6 kickstart

Why when you want to do something in a hurry do you find that build scripts suddenly stop working? Today I have spent my time trying to resolve issues with repositories and kickstart. The script that I had working for RHEL 5 to build a custom DVD no-longer worked.

RHEL 5 custom DVD creation

To create a custom RHEL 5 DVD do the following.
  • Insert the latest RHEL 5 DVD into the drive of a RHEL 5 Linux machine and copy the contents across to your build directory.
mkdir -p /data/iso-build
cd /data/iso-build
cp -R /media/CDROM/* ./
cp -R /media/CDROM/.[a-zA-Z]* ./
  • You can then edit the ks.cfg and do all sorts of things to customise the install. I won't detail this here.
  • The following is my quick and dirty build script to create the a new .iso file.
createrepo -g /data/iso-build/Server/repodata/comps-rhel6-Server.xml /data/iso-build/Server/
mkisofs -r -J -T -V "RHEL5 32" -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table -o /data/RHEL5-custom.iso /data/iso-build

RHEL 6 custom DVD creation

To create a custom RHEL 6 DVD do the following.
  • Insert the latest RHEL 6 DVD into the drive of a RHEL 5 Linux machine and copy the contents across to your build directory.
mkdir -p /data/iso-build
cd /data/iso-build
cp -R /media/CDROM/* ./
cp -R /media/CDROM/.[a-zA-Z]* ./
  • You can then edit the ks.cfg and do all sorts of things to customise the install. I won't detail this here.
  • The following is my quick and dirty build script to create the a new .iso file
createrepo -s sha -g /data/iso-build/Server/repodata/comps-rhel6-Server.xml /data/iso-build/Server/
cp -Rf /data/iso-build/Server/repodata /data/iso-build/
mkisofs -r -J -T -V "RHEL6 32" -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table -o /data/RHEL6-custom.iso /data/iso-build
  • There are two main differences. One I have to create the files in create repo with SHA1 not SHA256 which is the new default. Two I now have to copy the repodata directory to the top level from the Server directory. This seems to be needed otherwise anaconda has difficulty finding the yum repository. If the repodata directory doesn't also exist under the Server directory, then anaconda has difficulty finding the rpm files.