How to create a modified Fedora ISO

Posted on

Problem :

My goal is to create a customized fedora 20 netinst iso image. I have done this with scientific linux numerous times in order do add a custom kickstart file to the image.
But fedora seams to work differently in order to support efi.
Which commands are needed to create a bootable fedora image from the modified content of the official iso file?

Solution :

Did you take a look at the Fedora documentation : How to create a Fedora install ISO for testing


This page shows you how to build a Fedora ISO image you can use for testing. The examples reference the Fedora Rawhide repository, but the same instructions apply for any release of Fedora. The tutorial requires that you open a root shell. To access a root shell, open a terminal and run the command su -, and provide the root password.

Setup

In order to create Fedora ISO images, you must use a Fedora release that matches the release of the desired ISO images. For example, to create Fedora Rawhide images, you need to be running Fedora Rawhide. The examples in this document use Package-x-generic-16.pngmock to simulate the target environment and create ISO images. If you already have a system available running the target release, the use of mock is not required.

First, install the necessary packages

yum install mock

Adjust the mock configuration to allow bind mounts needed to support compose image generation. Add the following lines to the appropriate mock configuration. For example, for Fedora Rawhide, update /etc/mock/fedora-rawhide-x86_64.cfg to include the following:

config_opts['plugin_conf']['bind_mount_enable'] = True
config_opts['plugin_conf']['bind_mount_opts']['dirs'].append(('/dev','/dev/'))
config_opts['plugin_conf']['bind_mount_opts']['dirs'].append(('/dev/pts','/dev/pts/'))
config_opts['plugin_conf']['bind_mount_opts']['dirs'].append(('/dev/shm','/dev/shm/'))

Initialize the mock chroot

mock -r fedora-rawhide-$(uname -i) --init

Note.png

Behind the scenes… Mock does a lot of work behind the scenes. If you
want to see what commands it’s running in the chroot, add the
–verbose option.

Prepare the mock chroot for running pungi by installing packages into the chroot

mock -r fedora-rawhide-$(uname -i) --install spin-kickstarts pungi ${EDITOR:-vi}

Create a local mirror (optional)

This section is optional. You can use a nearby official Fedora mirror over a broadband connection. However, you may find it useful to mirror Rawhide locally if you regularly participate in testing. Note that the Package-x-generic-16.pngmirrormanager package may be useful in some situations. Refer to the detailed MirrorManager page for more information.

If you don’t have Rawhide available on a fast, local link, you may want to mirror it locally using rsync. Find a nearby mirror at http://mirrors.fedoraproject.org

mkdir -p /var/www/fedora/linux/development/x86_64/os
cd /var/www/fedora/linux/development/x86_64/os
rsync -Pavy --delete-after <MIRROR_NEAR_YOU>::/pub/fedora/linux/development/rawhide/$(uname -i)/os/ .

In the mock chroot, edit the kickstart configuration file used by pungi.

mock -r fedora-rawhide-$(uname -i) --shell ${EDITOR:-vi} /usr/share/spin-kickstarts/fedora-install-fedora.ks

Remove (or comment out) the existing repo –name=fedora line and add a new entry for the local mirror. Using the example above, you would end up with …

repo --name=fedora --baseurl=file:///var/www/fedora/linux/development/$basearch/os

When finished, save your changes and exit the chroot by pressing Ctrl-D or typing logout

Build a boot.iso

This section assumes you have installed the Package-x-generic-16.pngmock package and prepared the mock chroot as suggested in #Setup. If you haven’t completed those steps, please do so now. This section provides instruction on creating PXEboot and boot.iso images only. To create an installable -DVD.iso image, see #Build_a_DVD_ISO.

Activate a shell inside the mock chroot

mock -r fedora-rawhide-$(uname -i) --shell

Next, create a DVD (this may take a while)

pungi --nosource --nodebuginfo -G -C -B 
  --flavor Fedora --name Fedora --ver rawhide 
  -c /usr/share/spin-kickstarts/fedora-install-fedora.ks

If the previous command completed without errors, you now have PXEboot images and a boot.iso available in your chroot. Exit the mock shell, and copy the ISO image out of the chroot.

mock -r fedora-rawhide-$(uname -i) --copyout /rawhide/Fedora/$(uname -i)/os/images/boot.iso /tmp/

Build a DVD.iso

This section assumes you have installed the Package-x-generic-16.pngmock package and prepared the mock chroot as suggested in #Setup. If you haven’t completed those steps, please do so now.

Activate a shell inside the mock chroot

mock -r fedora-rawhide-$(uname -i) --shell

Next, create a DVD (this may take a while)

pungi --nosource --nodebuginfo 
  --flavor Fedora --name Fedora --ver rawhide 
  -c /usr/share/spin-kickstarts/fedora-install-fedora.ks

If you already followed the steps in #Build_a_boot.iso, you can save time by instructing pungi to only build the -DVD.iso image. When running the pungi command above, add the -I parameter to only build the ISO files, and to skip the previously executed steps.

If the previous command completed without errors, you now have a DVD ISO image in your chroot. Before proceeding, validate the ISO images using the sha256sum command

cd /rawhide/Fedora/$(uname -i)/iso
sha256sum -c Fedora-rawhide-$(uname -i)-CHECKSUM 

Exit the mock shell, and copy the ISO image out of the chroot and have fun …

mock -r fedora-rawhide-$(uname -i) --copyout /rawhide/Fedora/$(uname -i)/iso/Fedora-rawhide-$(uname -i)-DVD.iso /tmp/

Leave a Reply

Your email address will not be published. Required fields are marked *