Wednesday 9 October 2013

How to add OpenELEC XBMC Installer to Easy2Boot

The OpenElec x86_64 installer is based just on two files from the \target folder, KERNEL and SYSTEM. The KERNEL can be loaded by grub4dos but then it will look for the SYSTEM file on the boot volume. This works fine if we just copy these two files from the OpenElec x86_64 download to the root of our FAT32 Easy2Boot drive and then use a simple .mnu file:

title OpenElec Flat-File boot from FAT32
uuid () > nul
set UUID=%?%
echo UUID=%UUID%
kernel /KERNEL boot=UUID=%UUID% installer



However, there is a problem if we have an NTFS Easy2Boot USB drive because the KERNEL does not appear to be able to access the NTFS filesystem to find the SYSTEM file.

See here for OpenELEC Live.

Method 1 - use MakePartImage


1. Use RMPrepUSB - File->Drive and write the  OpenElec.img file to a spare USB Flash drive (this will destroy all contents on the USB drive).

2. Drag-and-drop the USB drive Explorer icon (e.g. J:) onto the MPI_FAT32 desktop shortcut (after installing the MPI Tool Kit).

3. Copy the resulting OpenElec.imgPTN file to your E2B USB flash drive

You can now MBR boot or UEFI boot.

Method 2 - the harder way!


After some trial and error, here is the way I found around this.

1. On a spare USB Flash drive, format it with RMPrepUSB as FAT32 and make the partition size just large enough for the two files + about 10MB. e.g. if the files add up to 92MB make a 110MB FAT32 partition. We need to keep this as small as possible as we are going to create an image from it.

2. Install grub4dos to the MBR

3. Add the two OpenElec boot files, SYSTEM and KERNEL.

4. In RMPrepUSB, press F4 to create a menu.lst file and add these 5 lines

uuid () > nul
set UUID=%?%
kernel /KERNEL boot=UUID=%UUID% installer
# if it exists, set the type 0C 4th ptn entry to 0
cat --locate=\x0c --number=1 --length=1 --skip=0x1f2 --replace=\x00 (hd0)+1

We should have these files on the FAT32 grub4dos Flash drive:
\grldr
\SYSTEM
\KERNEL
\menu.lst

5. Test that it boots to the OpenElec installer by pressing F11 in RMPrepUSB

6. In RMPrepUSB, click on the Drive->File button, choose a destination to save the file (OpenElec.img) and enter P1 for the Start Position on the drive, then P1 for the End Position and then 0 for the File Start position. This will create an image of the entire partition.

7. Copy the OpenElec.img file to \_ISO\MAINMENU\Linux folder of your E2B drive (or any \_ISO\xxx\Linux folder if you want it in a different menu).

8. Create in the same folder  an OpenElec.mnu file containing these contents (cut and paste the 5 lines):

title OpenElec Installer \n This installs OpenElec to a drive
# Write a new entry into the E2B partition table pointing to the OpenElec partition
partnew (hd0,3) 0x0 %MFOLDER%/Linux/OpenElec.img
root (hd0,3)
chainloader (hd0,3)/grldr

Now Run WinContig (RMPrepUSB - Ctrl+F2) and we should now be good to go!

We should now have present on the E2B drive:
\_ISO\MAINMENU\Linux\OpenElec.img
\_ISO\MAINMENU\Linux\OpenElec.mnu

Select the OpenElec Installer entry in the Easy2Boot Main Menu and it should boot.

The trick here is that partnew is used to create a type 0C partition entry in the E2B USB drive partition table so that we do have a real partition on our E2B drive when OpenElec boots, however once it boots to the image and we have loaded the kernel in grub4dos, we can set the partition type to 0 because linux does not look at the partition type number. This means that when E2B reboots, it will not complain about the partition table Entry #4 being in use and refuse to load the main menu. If E2B sees a Type 0 in ptn #4 it will clear the entries for us.

Neat eh!

The installer seems to install OK on a VM hard disk, but the VM seems to fail to fully boot to OpenElec (probably wrong hardware?) and I haven't tried it on a real system as it will trash the system's hard disk.



No comments:

Post a Comment