Contents


Detecting bootable IBM Power server ISO images

Comments

Content series:

This content is part # of # in the series:

Stay tuned for additional content in this series.

This content is part of the series:

Stay tuned for additional content in this series.

The capability of booting a CD-ROM became critical in the middle 90s, when operational systems such as Microsoft® Windows® became too big to fit in floppy disks. ISO 9660, a 1994 specification from Phoenix Technologies and IBM, describes how the BIOS can read a CD-ROM and run the boot procedure. An ISO 9660 extension called El Torito is one of the most used ways to describe the data format of the boot information. Most Intel® firmware follow the El Torito specification.

IBM® Power Systems™, however, do not follow the recommendations of ISO 9660 regarding this boot procedure. To boot an ISO image in an IBM Power® server, the media needs a file named bootinfo.txt inside a directory called 'ppc'. This file contains the instructions that the firmware uses to boot the image.

This difference can add complexity in software that has to deal with multiple architecture images, such as VM managers like Kimchi. Booting an image using trial and error isn't a viable option. Mounting the image can give us a hint of the existence of the file /ppc/bootinfo.txt, but the mount process requires at least the same disk size as the ISO image, special privileges, and it takes time. One alternative solution would be to read the ISO image as is, byte by byte, and try to find the file. This is possible because all ISO files have to implement the ISO9660 file system, providing a standard way to describe the files inside the media. This alternative is explored through the rest of this article, with coding examples.

The next section describes the ISO 9660 standard, which is used by any ISO file regardless of the architecture. The subsequent sections cover how we can access any file in an ISO file by following the ISO 9660 recommendations. The article also provides a coding example in Python language and also discusses other coding alternatives. The final section represents conclusion and discussion of the results.

The ISO 9660 standard

This standard is widely used not only by CD-ROM, but DVD, Blu-Ray disks and even flash drives. Although it has severe limitations for today's needs (which is fixed by its extensions), it describes a rather simple way to store and read the data inside the media.

Starting from the very first byte of the ISO file, the next 32 KB are marked as system area and aren't used. Following the system area, we have several sectors (= 2048 bytes, also called logical blocks) that describes the volumes presented in the image. Each volume has its own type and content, but all follow the same layout:

Figure 1. Generic volume descriptor format in ISO 9660
Figure 1. Generic volume descriptor format in ISO 9660

The most important volume descriptors are the Primary Volume and the Boot Record Volume. The Primary Volume contains information about how to read the remaining of the file system, including location of the directories, number of sectors, and others. The Boot Record Volume tells the BIOS how to start the ISO image. In the El Torito standard, the Boot Record Volume holds the location of the Boot Catalog, which is an index of the available boot images. Note that it is possible for multiple boot images to exist in a single media, and thus the need of such an index. The Set Terminator Volume marks the end of the volume record listing for the ISO file.

Figure 2. ISO 9660 volumes and boot catalog
Figure 2. ISO 9660 volumes and boot catalog

Finding a file in the ISO 9660 file system

As stated in the previous section, the Primary Volume record contains information about the files in that ISO. One of them is the size and location of the path table. This table contains a list of all the records that exists in the media. The format of the data in this path table is as follows:

Figure 3. Path table Model
Figure 3. Path table Model
Figure 3. Path table Model

The length of identifier is the size of the 'directory identifier' field, which is in most cases the name of the directory. The second field provides additional information about the directory and it is used in some extensions of ISO 9660. 'Location of extend' is the logical block of Directory Record that represents this entry. 'Directory number of parent directory' is a pointer of the logical address that represents the parent directory. The padding field is presented (with value = 0) if the length of the directory identifier is odd, not present otherwise. This ensures that each entry begins with an even byte number.

The Path Table is enough to find a directory in the ISO 9660 file system, but to find a specific file, we need to search the corresponding directory record. This record holds all the information about each file and the subdirectories in the directory.

Figure 4. Directory Record model
Figure 4. Directory Record model
Figure 4. Directory Record model

For the purposes of this article we need to analyze the following fields:

  • 'length of directory record', which is the size of this entry
  • 'file flags', a byte that represents the type of the register, such as sub directory, file, or a hidden file. Note that one entry can have more that one flag.
  • 'length of file identifier' and 'file identifier' to read the name of the file/subdir
  • ‘padding’, which exists if the length of the record is an even number

With this information, we can define an algorithm to look for the /ppc/bootinfo.txt file and determine if the ISO is bootable in a Power Systems server.

Figure 5. Algorithm that looks for the '/ppc/bootinfo.txt' file
Figure 5. Algorithm that looks for the '/ppc/bootinfo.txt' file
Figure 5. Algorithm that looks for the '/ppc/bootinfo.txt' file

Note that this algorithm can be adjusted to look for any file – it is just a matter of looking for the file in the reverse order of the path, looking for all the directories until the directory that contains the file we are looking for is reached.

We can see this concept in action in the example code in the next section, where we open a IBM Power server ISO file to detect if it is bootable.

A Python implementation

The following code is a working example of the concepts we've talked so far. This Python script loads the ISO file passed as a parameter and evaluates if the image is bootable by Power Systems firmware. By reading its inline comments, the workflow can be understood. This example is an adaptation of the patch that I submitted to the Kimchi project.

Save the contents in a file called detect_ppc_iso.py and then run the file using the following command.

$ python detect_ppc_iso.py <pc_iso>

Refer to the Download section for the detect_ppc_iso.py file.

Other alternatives

The implementation provided in the previous session opens an ISO image file and reads its contents byte-by-byte using the ISO 9660 standards to find the bootable Power Systems file /ppc/bootinfo.txt.

Alternatively, there are open source libraries that are capable of reading the ISO files and providing the same result. In some Linux® distributions with cdrkit installed, it is possible to use the isoinfo command to retrieve the relevant information from the ISO file, including the presence of the boot file for Power Systems firmware.

Listing 1. Using isoinfo to find the '/ppc/bootinfo.txt' file in an ISO file
$ isoinfo -i RHEL-7.0-20140507.0-Server-ppc64-dvd1.iso  -d

CD-ROM is in ISO 9660 format

System id: PPC

Volume id: RHEL-7.0 Server.ppc64

Volume set id: 

Publisher id: 

Data preparer id: 

Application id: GENISOIMAGE ISO 9660/HFS FILESYSTEM CREATOR (C) 1993 E.YOUNGDALE (C) 1997-2006 
        J.PEARSON/J.SCHILLING (C) 2006-2007 CDRKIT TEAM

Copyright File id: 

Abstract File id: 

Bibliographic File id: 

Volume set size is: 1

Volume set sequence number is: 1

Logical block size is: 2048

Volume size is: 1512366

Joliet with UCS level 3 found

Rock Ridge signatures version 1 found

$  isoinfo -i /var/lib/libvirt/images/RHEL-7.0-20140507.0-Server-ppc64-dvd1.iso  -x /ppc/bootinfo.txt

<chrp-boot> <description>Linux</description> 

<os-name>Linux</os-name> 

<boot-script>boot &device;:\ppc\chrp\yaboot</boot-script> 

(...)

The first command reads the Primary Volume descriptor of the ISO image and retrieves the information in it. The second command looks for the /ppc/bootinfo.txt file and dumps its contents to the standard output.

Although using the isoinfo command or any other alternative might be easier, it pre-req’s on the installation of additional packages in the OS, and generates a dependency on them in the future. Unless your software makes extensive use of the ISO manipulation features that these libraries offer, checking whether an ISO file is bootable on a Power Systems server is a task that can be accomplished by the code in the previous section, which works across operating systems and platforms and depends only on Python core libraries.

Conclusion

This article described the differences between Intel® and IBM POWER® regarding the boot process of ISO images, a brief explanation of how to find a file in the ISO 9660 file system, and a working code demonstrating these concepts. Finally, a potential alternative was presented, but it requires libraries and resources that might not be available.

One conclusion we can take from this work is that for software that makes extensive use of ISO images in raw data, a third-party library or software is recommended. For other tasks (such as detection of the bootability of an ISO image) it is feasible to make a minimalist implementation of the ISO 9660 protocol to accomplish that, with the advantage of not having dependencies on third-party libraries. The Kimchi project has implemented this option.


Downloadable resources


Comments

Sign in or register to add and subscribe to comments.

static.content.url=http://www.ibm.com/developerworks/js/artrating/
SITE_ID=1
Zone=Linux
ArticleID=986202
ArticleTitle=Detecting bootable IBM Power server ISO images
publish-date=10202014