Brimming with features
Remix a Fedora installation into a distributable distribution.
The secret for creating Fedora-based distros is the livecd-creator script that’s part of the livecd-tools package. Grab it from the Fedora repositories with dnf install livecd-tools . Unlike Bodhibuilder, livecd-creator works solely on the command line.
The scripts use a definition in a Kickstart file to set up your customised Fedora-based distro. In simple terms, a Kickstart file is a text file that contains a list of actions such as the name of packages to install (or remove). The livecd-creator tool compiles your distro as per the instructions in this file. To help you get started, you can download the Kickstart files for several Fedora spins by grabbing the spin-kickstarts package from the Fedora repositories with dnf install spin-kickstarts . Once this is installed, you’ll have a bunch of Kickstart files under the /usr/share/spin-kickstarts directory. You can customise any of these Kickstart files by editing them. They are well documented and fairly easy to comprehend; browse the Fedora wiki ( http:// fedoraproject.org/wiki/Anaconda/Kickstart) to get a hang of the various options. If you need to generate one from scratch, you can save yourself a lot of time by grabbing the KickstartConfigurator tool with dnf install system-config-kickstart . This tool has an easy-tonavigate graphical interface to help create a Kickstart file.
Kick-start the process
For our purpose we’ll create a Mate-based Fedora remix by modifying the fedora-live-mate_compiz.ks file. The three main parameters in a kickstart file are %pre, %post and %packages. You can also pull in instructions from another kickstart file by specifying its name and location with the %include parameter, such as %include fedora-mate-common.ks . You’ll notice three such lines at the top of the fedora-live-mate_compiz.ks file.
The first one calls the fedora-live-base.ks file. This file describes the basic skeleton for creating a Fedora Live CD. The parameters are self-explanatory. There’s one each for the default language, keyboard and timezone followed by security settings that dictate the use of standard shadow passwords and so on. Here, we’d like to note that while the default for SELinux is set to enforcing mode, it hindered with the smooth functioning of some our builds and we had to change the default SELinux policy for the customised distro to the permissive mode.
The xconfig set to --startxonboot asks the live CD to boot straight to a graphical login screen. There’s also an entry to create a root (/) partition and another to enable and disable the default services.
Also included in the fedora-live-mate_compiz.ks file is the fedora-mate-common.ks file that contains a list of packages for the Mate desktop with the Compiz compositor. Any packages you want inside your custom distro needs to be listed under the %packages section. In addition to individual packages, you can also specify groups of packages such as @mate and @libreoffice. If you install a group of packages you can remove individual components inside it by prefixing a minus (-) sign to their name, such as -fedora-icon-theme. These packages are
fetched from Fedora repositories mentioned in the fedora-repo.ks file. You can either directly specify the exact URL for a repository (with the --baseurl option) or let it choose one from a list of mirrors (with the --mirrorlist option).
In case you pull in packages from third-party repositories like RPMFusion or those for fetching proprietary software like the Steam client, Google Chrome, Nvidia graphics and the like, Fedora guidelines mandate you to rebrand your creation. But they’ve made the process simple. All you need to do is remove a bunch of Fedora branding packages, namely -fedora-logos and -fedorarelease* , and then replace them with generic ones, generic-release* and generic-logos .
Lastly there’s the %post section that enables you to run commands after all the packages have been downloaded and installed to the temporary directory. You can add custom users, copy files, configure the network, and do a lot more interesting stuff in this section.
To correctly identify our remixed distro, we’ll rename it in the /etc/fedora-release file, with: %post sed -i -e ‘s/Generic release/LXF Fedora Remix/g’ /etc/fedora-release %end
The commands in the %post section by default run inside a chroot environment against the new filesystem in the Live CD. But there’s also a mechanism for adding files to the LiveCD’s filesystem. The %post --chroot section enables you to interact with your custom distro’s environment from outside. This enables you to copy files from your host Fedora installation to the customised distro.
Kickstart offers two variables for interacting with the custom distro environment. The $INSTALL_ROOT points to the root (/) of the customised distro where all the packages are installed during the build process. This comes in handy for copying files you need in your Live environment. For example: %post --nochroot cp -r /home/bodhi/Pictures/wallpapers/ $INSTALL_ROOT/etc/skel/Pictures/ %end
This will copy a bunch of images housed inside the wallpapers directory on the host to the custom distro. We’ve placed it inside the skeleton directory (/ etc/skel) so that it’s available to all users in the custom distro. You can use the same mechanism to copy over your desktop customisations to the custom distro. First, just like before, configure your desktop as per your requirements on an installed system. When you’re done, simply scoot over the configuration files from your home directory to the /etc/skel directory on the live CD: %post --nochroot cp -r /home/bodhi/.config $INSTALL_ROOT/ etc/skel/ cp -r /home/bodhi/.local $INSTALL_ROOT/ etc/skel/ %end
The other variable is $LIVE_ROOT . This is the root of the Live CD and any files placed here will be available without having to boot the media. Think of all the HTML files in the LinuxFormat DVD that you can view without booting into the month’s featured distro. For instance: %post --nochroot cp -r /home/bodhi/Music $LIVE_ROOT/ Music %end
This will copy over all music files from the host to the root of the customised media. You can also use both variables together to move files from inside the root of the compressed filesystem to the root of the media: %post --nochroot cp $INSTALL_ROOT/usr/share/doc/*- release-*/GPL $LIVE_ROOT/GPL %end
This will extract the GPL license file from your customised distro’s filesystem and place it in the root of the customised media.
After you’ve assembled the kickstart files, you can pass them on to livecd-creator to compile the ISO image of your customised distro. First ensure SELinux on the host is set to the permissive mode with the setenforce 0 command, before you call the livecd-creator script: $ livecd-creator --config=custom-fedora.ks --fslabel=LXF-Remix-28 --cache=/var/cache/ live --verbose
Here, the --config option identifies our custom kickstart file and the --fslabel defines the name of the volume as well as the ISO image. The --cache option defines the directory where the script will download the packages from the repositories and assemble them into a Live environment. Remember to use this cache directory for subsequent builds to avoid having to download the same packages again. The script will only download packages if you’ve added any new ones to the kickstart file after running the initial build.
The time it takes to compile the distro depends, as usual, on the number-crunching prowess of your computer and the number of packages that need to be fetched from the Internet. When it’s done, it’ll leave an ISO file for your customised Fedora remix in the current directory. You can then test it on a virtual machine before passing it around to friends, family and interested colleagues.
The Kickstart Configuration tool is a real time-saver, especially when you want to generate a kick-start file from scratch.
Fedora’s LiveCD tools have been ported to other RPM-based distributions like Mageia.