Saturday, 3 June 2017

Adding OpenMandriva to E2B

The OpenMandriva ISO does not boot as a .ISO file when simply placed on an E2B drive.



Instead we need to make a .mnu file for it and specify the Volume Label of the ISO.

Here is an example menu:


iftitle [if exist $HOME$/OpenMandrivaLx.3.0-PLASMA.x86_64.iso] OpenMandriva 3.0
set ISO=OpenMandrivaLx.3.0-PLASMA.x86_64.iso
set vol=OpenMandrivaLx_3.0

### use for 3.01
#set ISO=OpenMandrivaLx.3.01-PLASMA.x86_64.iso
#set vol=OpenMandrivaLx_3.01

set ISO=$HOME$/%ISO%
map %ISO% (0xff)
map --hook
root (0xff)
set bootd=rootfstype=auto ro rd.luks=0 rd.lvm=0 rd.md=0 rd.dm=0 rd.live.image acpi_osi=Linux acpi_osi='!Windows 2012' acpi_backlight=vendor audit=0 logo.nologo
set bootl=locale.lang=en_US
kernel /boot/vmlinuz0 %bootd% root=live:LABEL=%vol% iso-scan/filename=%ISO% %bootl% quiet rhgb splash=silent
initrd /boot/liveinitrd.img
boot


This version does not require the volume name to be know (thanks to Tu Nguyen):

# Copy ISO and this file to \_ISO\LINUX\MNU folder
# Change set ISO and iftitle line to match your ISO

iftitle [if exist $HOME$/OpenMandrivaLx.3.0-PLASMA.i586.iso] OpenMandriva 3.0
set ISO=OpenMandrivaLx.3.0-PLASMA.i586.iso
#set ISO=OpenMandrivaLx.3.0-PLASMA.x86_64.iso
#set ISO=OpenMandrivaLx.3.01-PLASMA.x86_64.iso

###set language   en_US  en_GB es_ES de_DE uk fr_FR
set l=en_GB

set ISO=$HOME$/%ISO%
map %ISO% (0xff)
map --hook
root (0xff)
#get UUID from ISO modified date
cat --skip=830 --length=4 (0xff)16+1 | set ISO_UUID=
cat --skip=834 --length=2 (0xff)16+1 | set ISO_UUID=%ISO_UUID%-
cat --skip=836 --length=2 (0xff)16+1 | set ISO_UUID=%ISO_UUID%-
cat --skip=838 --length=2 (0xff)16+1 | set ISO_UUID=%ISO_UUID%-
cat --skip=840 --length=2 (0xff)16+1 | set ISO_UUID=%ISO_UUID%-
cat --skip=842 --length=2 (0xff)16+1 | set ISO_UUID=%ISO_UUID%-
cat --skip=844 --length=2 (0xff)16+1 | set ISO_UUID=%ISO_UUID%-
echo ISO UUID=%ISO_UUID%
set bootd=rootfstype=auto ro rd.luks=0 rd.lvm=0 rd.md=0 rd.dm=0 rd.live.image acpi_osi=Linux acpi_osi='!Windows 2012' acpi_backlight=vendor audit=0 logo.nologo
set bootl=locale.lang=%l%
kernel /boot/vmlinuz0 %bootd% root=live:UUID=%ISO_UUID% iso-scan/filename=%ISO% %bootl% quiet rhgb splash=silent
initrd /boot/liveinitrd.img
boot

You can change the variable to your own language.

Use terminal command   locale -a  to list all locales  (or locale -a | grep "fr" | more to find all locales for fr)

UUIDs for ISOs

There does not seem to be a UUID location defined in the ISO9660 specification (as far as I can tell), however grub and Ubuntu use the 'modified date' of the ISO as the UUID.

Here is the byte contents of a Ubuntu ISO (ISOs have 2048 byte sectors).

0x832D = Sector 16 Offset 813 = Created Date = 2016-04-20
0x833E = Sector 16 Offset 830 = Modified Date = 2222-04-20


When you boot from this ISO, Ubuntu shows the UUID as 2222-04-20, thus proving that Ubuntu uses the Modified Date as the UUID.



Volume Labels for ISOs

The ISO9660 specification describes a Primary Descriptor block at (0xff)16+1 and for Joliet there is also an Enhanced descriptor usually at (0xff)18+1.

Now Windows Explorer seems to display the Enhanced Volume label, but linux seems to always use the Primary volume label (even if it is a Joliet ISO). I think that grub2 also uses the Primary Volume label.

so When booting linux ISOs using root=live:LABEL=%vol% we need to use the Primary Volume label.

We can display the labels like this (note: for ISOs, blocks are 2048 bytes not 512 bytes):

map /MyISO.ISO (0xff)
map --hook
echo Primary Descriptor label
cat --hex --skip=0x28 --length=32 (0xff)16+1
echo ;; echo Enhanced Descriptor label (if Joliet)
cat --hex --skip=0x28 --length=32 (0xff)16+1

Unfortunately, grub4dos reports the wrong label at the moment. I have made a bug report to hopefully get this fixed.