CentOS : ISO generation script

General support questions
gudge
Posts: 7
Joined: 2015/12/31 15:28:04

CentOS : ISO generation script

Post by gudge » 2015/12/31 15:31:38

Could someone please point me to the ISO generation script which CentOS uses to generate the ISO, specially the command line for mkisofs or genisoimage or xorriso. I have my own CentOS based OS and wish to make a ISO which is UEFI compatible. I already have a OS which I can boot through BIOS mode.

The command line I am using is :

Code: Select all

 xorriso -as mkisofs \
        -o ${DIR_NAME}/${ISO_NAME}.iso \
        -isohybrid-mbr /usr/share/syslinux/isohdpfx.bin \
        -c isolinux/boot.cat \
        -b isolinux/isolinux.bin \
        -no-emul-boot \
        -boot-load-size 4 \ 
        -boot-info-table \
        -eltorito-alt-boot \
        -e images/efiboot.img \
        -no-emul-boot \
        -isohybrid-gpt-basdat \
        DIR

scdbackup
Posts: 11
Joined: 2016/01/01 07:54:07

Re: CentOS : ISO generation script

Post by scdbackup » 2016/01/01 08:03:08

Hi,

thank you for flying xorriso.

The xorriso run looks ok so far (SYSLINUX isohybrid wiki ?).
It advertises the content of file /images/efiboot.img in
El Torito (for CD/DVD) and in MBR partition table (for hard
disk or USB stick). It also does so in a GPT which a standards
compliant EFI should ignore.
This layout stems from Matthew Garret and works well for Debian,
Ubuntu, Arch Linux, at least.

But they all have GRUB equipment in the EFI boot image / system
partition image. Since you possibly read the SYSLINUX wiki, i
have to say that nobody managed to boot SYSLINUX via EFI from
ISO 9660 yet.

As for CentOS ISOs. They differ.
With xorriso >= 1.3.8 one can do:

Code: Select all

  xorriso -hfsplus on -indev ...iso \
          -report_system_area plain -report_el_torito plain
---------------------------------------------------------------------

CentOS-6.7-x86_64-minimal.iso

Code: Select all

System area summary: MBR isohybrid cyl-align-on
...
MBR partition table:   N Status  Type        Start       Blocks
MBR partition      :   1   0x80  0x17            0       808960
...
El Torito images   :   N  Pltf  B   Emul  Ld_seg  Hdpt  Ldsiz         LBA
El Torito boot img :   1  BIOS  y   none  0x0000  0x00      4          82
El Torito boot img :   2  UEFI  y   none  0x0000  0x00    744          94
El Torito img path :   1  /isolinux/isolinux.bin
El Torito img opts :   1  boot-info-table isohybrid-suitable
El Torito img path :   2  /images/efiboot.img
This will boot via BIOS from CDROM and HDD (e.g. USB stick).
EFI only will see the EFI system partition if the ISO is presented
on CD (or DVD, or BD). On HDD there is no hint towards efiboot.img .

One could probably run SYSLINUX program isohybrid.c on it with
option --uefi in order to produce MBR partition and GPT.
http://www.syslinux.org/wiki/index.php/Isohybrid
(Because MBR has a partition other than a single one of type 0xee,
no EFI or partition editor should recognize GPT.)

Code: Select all

  strings /mnt/iso/images/efiboot.img | grep 'GRUB'
yields among other lines

Code: Select all

  GNU GRUB 0.97
I.e. old GRUB Legacy, not GRUB2 as with Debian.
Well if it boots from CD, there is chance it would boot from HDD.
You will hardly find support for it, though.

---------------------------------------------------------------------

CentOS-6.7-x86_64-LiveCD.iso

Code: Select all

System area summary: MBR isohybrid cyl-align-on
...
MBR partition table:   N Status  Type        Start       Blocks
MBR partition      :   1   0x80  0x17            0      1427456
...
El Torito catalog  : 40  1
El Torito cat path : /isolinux/boot.cat
El Torito images   :   N  Pltf  B   Emul  Ld_seg  Hdpt  Ldsiz         LBA
El Torito boot img :   1  BIOS  y   none  0x0000  0x00      4          41
El Torito img path :   1  /EFI/boot/isolinux.bin
El Torito img opts :   1  boot-info-table isohybrid-suitable
This will only boot via BIOS or EFI BIOS emulation.
Despite the directory name "/EFI", the file isolinux.bin is advertised
in El Torito only for BIOS. Further it has a boot-info-table which is
prescribed for ISOLINUX (and GRUB/GRUB2) BIOS El Torito boot images.

---------------------------------------------------------------------

Beginning with xorriso-1.4.0, one may ask for replay proposals:

Code: Select all

  xorriso -hfsplus on -indev CentOS-6.7-x86_64-minimal.iso \
          -report_system_area as_mkisofs
proposes

Code: Select all

  -V 'CentOS_6.7_Final'
  --modification-date='2015080421592400'
  -isohybrid-mbr --interval:local_fs:0s-15s:zero_mbrpt:'CentOS-6.7-x86_64-minimal.iso'
  -partition_cyl_align on
  -partition_offset 0
  -partition_hd_cyl 64
  -partition_sec_hd 32
  -c '/isolinux/boot.cat'
  -b '/isolinux/isolinux.bin'
  -no-emul-boot
  -boot-load-size 4
  -boot-info-table
  -eltorito-alt-boot
  -e '/images/efiboot.img'
  -no-emul-boot
  -boot-load-size 744
The --interval argument will take the first 16 * 2048 bytes from
file CentOS-6.7-x86_64-minimal.iso, zeroize its MBR partition table,
and use it like the ISOLINUX isohdpfx.bin file.

Note that option -isohybrid-gpt-basdat is missing.
This means: no MBR partition of type 0xef points to efiboot.img
and no GPT partition does either.
If you add -isohybrid-gpt-basdat you get what isohybrid.c --uefi
does.

Code: Select all

  xorriso -hfsplus on -indev CentOS-6.7-x86_64-minimal.iso \
          -report_system_area as_mkisofs
proposes

Code: Select all

  -V 'CentOS-6.7-x86_64-LiveCD'
  --modification-date='2015080716342900'
  -isohybrid-mbr --interval:local_fs:0s-15s:zero_mbrpt:'CentOS-6.7-x86_64-LiveCD.iso'
  -partition_cyl_align on
  -partition_offset 0
  -partition_hd_cyl 64
  -partition_sec_hd 32
  -c '/isolinux/boot.cat'
  -b '/EFI/boot/isolinux.bin'
  -no-emul-boot
  -boot-load-size 4
  -boot-info-table
Here we do not even have a second El Torito boot image with option -e.


Have a nice day :)

Thomas

gudge
Posts: 7
Joined: 2015/12/31 15:28:04

Re: CentOS : ISO generation script

Post by gudge » 2016/01/01 18:19:26

Thanks for the command to dump the options for generating the ISO.
I was able to successfully build the ISO and boot from it in UEFI mode.

Following is the command line:

Code: Select all

xorriso -as mkisofs -o ../my_new_iso.iso -V "CentOS 7 x86_64" -isohybrid-mbr --interval:local_fs:0s-15s:zero_mbrpt,zero_gpt:'../../CentOS-7-x86_64-Everything-1503-01.iso' -partition_cyl_align off -partition_offset 0 -c isolinux/boot.cat -b isolinux/isolinux.bin -no-emul-boot -boot-load-size 4 -boot-info-table -eltorito-alt-boot -e '/images/efiboot.img' -no-emul-boot -boot-load-size 12804 -isohybrid-gpt-basdat -R -J .
The xorriso version is 1.4.2.

As part of our production system we use:
xorriso 1.3.6.

The option : --interval:local_fs:0s-15s:zero_mbrpt,zero_gpt:'../../CentOS-7-x86_64-Everything-1503-01.iso' does not exist in 1.3.6.

I think I should be able to build the EFI compatible ISO with 1.3.6 as well or the EFI compatible ISO can only be build with a version higher than 1.3.6.

gudge
Posts: 7
Joined: 2015/12/31 15:28:04

Re: CentOS : ISO generation script

Post by gudge » 2016/01/01 19:42:24

Hi Thomas,
I figured out the options:

xorriso -as mkisofs -o ../centos_modified_cmd_line.iso -V "CentOS 7 x86_64" -c isolinux/boot.cat -b isolinux/isolinux.bin -no-emul-boot -boot-load-size 4 -boot-info-table -eltorito-alt-boot -e images/efiboot.img -no-emul-boot -R -J .

I was able to boot through the image.

Thanks a lot for your help.

Thanks

scdbackup
Posts: 11
Joined: 2016/01/01 07:54:07

Re: CentOS : ISO generation script

Post by scdbackup » 2016/01/02 08:31:53

Hi,

congrats to the success.

Comparing your final command with the one from the initial post
of this thread, i'd assume that the decisive trick was actually

Code: Select all

 -V "CentOS 7 x86_64" 
I.e. that the booting system looks for this Volume Id when
searching the ISO from which it started.

Elsewise the final command is a subset of the features which
would be enabled by the command in your initial post.
Your current ISO will boot only from optical media but not from
hard-disk-like devices.

Code: Select all

-isohybrid-mbr /usr/share/syslinux/isohdpfx.bin
would make it bootable via BIOS from USB stick.

Code: Select all

-isohybrid-gpt-basdat
after -e images/efiboot.img would make it bootable via EFI from USB stick.

Alternatively you could run on the current ISO

Code: Select all

isohybrid --uefi ../centos_modified_cmd_line.iso

Have a nice day :)

Thomas

gudge
Posts: 7
Joined: 2015/12/31 15:28:04

Re: CentOS : ISO generation script

Post by gudge » 2016/01/02 09:12:36

Hi Thomas,
You are correct. Figuring out the correct volume Id was the essential part.

Thanks

gudge
Posts: 7
Joined: 2015/12/31 15:28:04

Re: CentOS : ISO generation script

Post by gudge » 2016/01/02 23:41:28

Code: Select all

            /usr/bin/xorriso as mkisofs -o ${DIR_NAME}/${ISO_NAME}.iso \
                                        -isohybrid-mbr /usr/share/syslinux/isohdpfx.bin \
                                        -volid "${ISO_VOLUME_ID}" \
                                        -b isolinux/isolinux.bin \
                                        -c isolinux/boot.cat \
                                        -input-charset utf-8 \
                                        -no-emul-boot \
                                        -boot-load-size 4 \ 
                                        -boot-info-table \
                                        -eltorito-alt-boot \
                                        -e images/efiboot.img \
                                        -no-emul-boot \
                                        -isohybrid-gpt-basdat \
                                        -R \
                                        -J \
                                        -v \
                                        .
The following command does generate the ISO correctly but I am unable to boot it form a USB on a machine.

The reason is the machine does not see the any files on USB. I am able to boot it on a VM and dumpet
shows it as EFI :

Code: Select all

Section Header Entry:
Header Indicator: 0x91 (Final Section Header Entry)
PlatformId: 0xef (EFI)
Section Entries: 1
ID: ""
Could you please let me know if I need to use or remove any other options.

Thanks

scdbackup
Posts: 11
Joined: 2016/01/01 07:54:07

Re: CentOS : ISO generation script

Post by scdbackup » 2016/01/03 07:55:26

Hi,

> I am able to boot it on a VM

The ISO presented as virtual hard disk ?
(qemu -hdb rather than -cdrom ?)

> dumpet shows it as EFI
> PlatformId: 0xef (EFI)

That's from the El Torito boot catalog. It is in effect only
when the ISO is presented on optical media. E.g. virtual CDROM.

With hard-disk-like media, EFI looks for partition tables.
Your ISO is supposed to have an MBR partition of type 0xef which
contains the FAT filesystem out of efiboot.img.

What do you get from

Code: Select all

/sbin/fdisk -l ../my_new_iso.iso
It is supposed to display something like with this Debian install ISO:

Code: Select all

Device                          Boot Start    End Sectors  Size Id Type
debian-8.2.0-amd64-netinst.iso1 *        0 505855  505856  247M  0 Empty
debian-8.2.0-amd64-netinst.iso2       3984   4815     832  416K ef EFI (FAT-12/16/32)
> The reason is the machine does not see the any files on USB.

Can you mount the ISO filesystem from the base device of the
USB stick (e.g. /dev/sdc) ?

If fdisk reports an EFI partition, can you mount it as FAT
(e.g. /dev/sdc2) ?

Have a nice day :)

Thomas

gudge
Posts: 7
Joined: 2015/12/31 15:28:04

Re: CentOS : ISO generation script

Post by gudge » 2016/01/04 14:49:28

Hi Thomas,
I tried booting the image from CD-ROM on the machine. It was successful. It did not work with USB.
I have the options:

Code: Select all

-isohybrid-mbr /usr/share/syslinux/isohdpfx.bin 
-isohybrid-gpt-basdat

Code: Select all

sudo fdisk -l my_new_iso.iso

Disk my_new_iso.iso: 815 MB, 815792128 bytes, 1593344 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos 
Disk identifier: 0x0ee801d5

             Device Boot      Start         End      Blocks   Id  System
my_new_iso.iso1   *           0     1593343      796672    0  Empty
my_new_iso.iso2             660       13463        6402   ef  EFI (FAT-12/16/32)
I can mount the ISO filesystem from the base device of the USB stick (/dev/sdc)

fdisk does report a EFI partition. I can you mount it as FAT (/dev/sdc2).

Thanks

scdbackup
Posts: 11
Joined: 2016/01/01 07:54:07

Re: CentOS : ISO generation script

Post by scdbackup » 2016/01/04 16:06:17

Hi,

the partition table of the ISO looks ok and the fact that
you can mount base device and partition 2 proves that the
ISO was brought correctly onto the whole USB stick (not into
a partition and not into a filesystem).

Currently i can only imagine that the USB stick is not
considered by the firmware for booting. (With BIOS there
is some menu where to select boot devices. But with EFI
i don't know ...)

Do other operating systems boot from that USB stick in
that USB socket of the computer ?

The nearest relative of CentOS with isohybrid is probably

https://download.fedoraproject.org/pub/ ... _64-23.iso

Its boot equipment is plenty:

Code: Select all

Volume id    : 'Fedora-WS-23-x86_64'
El Torito catalog  : 44  1
El Torito cat path : /isolinux/boot.cat
El Torito images   :   N  Pltf  B   Emul  Ld_seg  Hdpt  Ldsiz         LBA
El Torito boot img :   1  BIOS  y   none  0x0000  0x00      4      208256
El Torito boot img :   2  UEFI  y   none  0x0000  0x00  10780          45
El Torito boot img :   3  UEFI  y   none  0x0000  0x00  43168      171122
El Torito img path :   1  /isolinux/isolinux.bin
El Torito img opts :   1  boot-info-table isohybrid-suitable
El Torito img path :   2  /images/efiboot.img
El Torito img path :   3  /images/macboot.img
System area options: 0x00000102
System area summary: MBR isohybrid cyl-align-on GPT APM
ISO image size/512 : 844528
Partition offset   : 0
MBR heads per cyl  : 64
MBR secs per head  : 32
MBR partition table:   N Status  Type        Start       Blocks
MBR partition      :   1   0x80  0x00            0       845824
MBR partition      :   2   0x00  0xef          180        10780
MBR partition      :   3   0x00  0x00       684488        43168
MBR partition path :   2  /images/efiboot.img
MBR partition path :   3  /images/macboot.img
GPT                :   N  Info
GPT disk GUID      :      2544134511a4c545b120ccf9f988055d
GPT entry array    :      16  128  overlapping
GPT lba range      :      48  845790  845823
GPT partition name :   1  490053004f004800790062007200690064002000490053004f00
GPT partname local :   1  ISOHybrid ISO
GPT partition GUID :   1  639e1f980d5de640ad771229bb88ac5c
GPT type GUID      :   1  a2a0d0ebe5b9334487c068b6b72699c7
GPT partition flags:   1  0x0000000000000000
GPT start and size :   1  0  844528
GPT partition name :   2  490053004f00480079006200720069006400
GPT partname local :   2  ISOHybrid
GPT partition GUID :   2  c2a9136420992c4289062b989989f841
GPT type GUID      :   2  a2a0d0ebe5b9334487c068b6b72699c7
GPT partition flags:   2  0x0000000000000000
GPT start and size :   2  180  10780
GPT partition path :   2  /images/efiboot.img
GPT partition name :   3  490053004f00480079006200720069006400
GPT partname local :   3  ISOHybrid
GPT partition GUID :   3  c2a9136420992c4289062b989989f841
GPT type GUID      :   3  005346480000aa11aa1100306543ecac
GPT partition flags:   3  0x0000000000000000
GPT start and size :   3  684488  43168
GPT partition path :   3  /images/macboot.img
APM                :   N  Info
APM block size     :      2048
APM gap fillers    :      0
APM partition name :   1  EFI
APM partition type :   1  Apple_HFS
APM start and size :   1  45  2695
APM partition path :   1  /images/efiboot.img
APM partition name :   2  EFI
APM partition type :   2  Apple_HFS
APM start and size :   2  171122  10792
APM partition path :   2  /images/macboot.img
It not only has EFI but also a HFS+ filesystem image "macboot.img".
Well, this should not make much difference unless your machine
bears a logo of Apple Inc.

Have a nice day :)

Thomas

Post Reply

Return to “CentOS 7 - General Support”